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.

14420 lines
394KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, a filter can have multiple inputs and multiple
  5. outputs.
  6. To illustrate the sorts of things that are possible, we consider the
  7. following filtergraph.
  8. @verbatim
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end verbatim
  15. This filtergraph splits the input stream in two streams, then sends one
  16. stream through the crop filter and the vflip filter, before merging it
  17. back with the other stream by overlaying it on top. You can use the
  18. following command to achieve this:
  19. @example
  20. ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
  21. @end example
  22. The result will be that the top half of the video is mirrored
  23. onto the bottom half of the output video.
  24. Filters in the same linear chain are separated by commas, and distinct
  25. linear chains of filters are separated by semicolons. In our example,
  26. @var{crop,vflip} are in one linear chain, @var{split} and
  27. @var{overlay} are separately in another. The points where the linear
  28. chains join are labelled by names enclosed in square brackets. In the
  29. example, the split filter generates two outputs that are associated to
  30. the labels @var{[main]} and @var{[tmp]}.
  31. The stream sent to the second output of @var{split}, labelled as
  32. @var{[tmp]}, is processed through the @var{crop} filter, which crops
  33. away the lower half part of the video, and then vertically flipped. The
  34. @var{overlay} filter takes in input the first unchanged output of the
  35. split filter (which was labelled as @var{[main]}), and overlay on its
  36. lower half the output generated by the @var{crop,vflip} filterchain.
  37. Some filters take in input a list of parameters: they are specified
  38. after the filter name and an equal sign, and are separated from each other
  39. by a colon.
  40. There exist so-called @var{source filters} that do not have an
  41. audio/video input, and @var{sink filters} that will not have audio/video
  42. output.
  43. @c man end FILTERING INTRODUCTION
  44. @chapter graph2dot
  45. @c man begin GRAPH2DOT
  46. The @file{graph2dot} program included in the FFmpeg @file{tools}
  47. directory can be used to parse a filtergraph description and issue a
  48. corresponding textual representation in the dot language.
  49. Invoke the command:
  50. @example
  51. graph2dot -h
  52. @end example
  53. to see how to use @file{graph2dot}.
  54. You can then pass the dot description to the @file{dot} program (from
  55. the graphviz suite of programs) and obtain a graphical representation
  56. of the filtergraph.
  57. For example the sequence of commands:
  58. @example
  59. echo @var{GRAPH_DESCRIPTION} | \
  60. tools/graph2dot -o graph.tmp && \
  61. dot -Tpng graph.tmp -o graph.png && \
  62. display graph.png
  63. @end example
  64. can be used to create and display an image representing the graph
  65. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  66. a complete self-contained graph, with its inputs and outputs explicitly defined.
  67. For example if your command line is of the form:
  68. @example
  69. ffmpeg -i infile -vf scale=640:360 outfile
  70. @end example
  71. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  72. @example
  73. nullsrc,scale=640:360,nullsink
  74. @end example
  75. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  76. filter in order to simulate a specific input file.
  77. @c man end GRAPH2DOT
  78. @chapter Filtergraph description
  79. @c man begin FILTERGRAPH DESCRIPTION
  80. A filtergraph is a directed graph of connected filters. It can contain
  81. cycles, and there can be multiple links between a pair of
  82. filters. Each link has one input pad on one side connecting it to one
  83. filter from which it takes its input, and one output pad on the other
  84. side connecting it to one filter accepting its output.
  85. Each filter in a filtergraph is an instance of a filter class
  86. registered in the application, which defines the features and the
  87. number of input and output pads of the filter.
  88. A filter with no input pads is called a "source", and a filter with no
  89. output pads is called a "sink".
  90. @anchor{Filtergraph syntax}
  91. @section Filtergraph syntax
  92. A filtergraph has a textual representation, which is recognized by the
  93. @option{-filter}/@option{-vf}/@option{-af} and
  94. @option{-filter_complex} options in @command{ffmpeg} and
  95. @option{-vf}/@option{-af} in @command{ffplay}, and by the
  96. @code{avfilter_graph_parse_ptr()} function defined in
  97. @file{libavfilter/avfilter.h}.
  98. A filterchain consists of a sequence of connected filters, each one
  99. connected to the previous one in the sequence. A filterchain is
  100. represented by a list of ","-separated filter descriptions.
  101. A filtergraph consists of a sequence of filterchains. A sequence of
  102. filterchains is represented by a list of ";"-separated filterchain
  103. descriptions.
  104. A filter is represented by a string of the form:
  105. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  106. @var{filter_name} is the name of the filter class of which the
  107. described filter is an instance of, and has to be the name of one of
  108. the filter classes registered in the program.
  109. The name of the filter class is optionally followed by a string
  110. "=@var{arguments}".
  111. @var{arguments} is a string which contains the parameters used to
  112. initialize the filter instance. It may have one of two forms:
  113. @itemize
  114. @item
  115. A ':'-separated list of @var{key=value} pairs.
  116. @item
  117. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  118. the option names in the order they are declared. E.g. the @code{fade} filter
  119. declares three options in this order -- @option{type}, @option{start_frame} and
  120. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  121. @var{in} is assigned to the option @option{type}, @var{0} to
  122. @option{start_frame} and @var{30} to @option{nb_frames}.
  123. @item
  124. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  125. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  126. follow the same constraints order of the previous point. The following
  127. @var{key=value} pairs can be set in any preferred order.
  128. @end itemize
  129. If the option value itself is a list of items (e.g. the @code{format} filter
  130. takes a list of pixel formats), the items in the list are usually separated by
  131. @samp{|}.
  132. The list of arguments can be quoted using the character @samp{'} as initial
  133. and ending mark, and the character @samp{\} for escaping the characters
  134. within the quoted text; otherwise the argument string is considered
  135. terminated when the next special character (belonging to the set
  136. @samp{[]=;,}) is encountered.
  137. The name and arguments of the filter are optionally preceded and
  138. followed by a list of link labels.
  139. A link label allows one to name a link and associate it to a filter output
  140. or input pad. The preceding labels @var{in_link_1}
  141. ... @var{in_link_N}, are associated to the filter input pads,
  142. the following labels @var{out_link_1} ... @var{out_link_M}, are
  143. associated to the output pads.
  144. When two link labels with the same name are found in the
  145. filtergraph, a link between the corresponding input and output pad is
  146. created.
  147. If an output pad is not labelled, it is linked by default to the first
  148. unlabelled input pad of the next filter in the filterchain.
  149. For example in the filterchain
  150. @example
  151. nullsrc, split[L1], [L2]overlay, nullsink
  152. @end example
  153. the split filter instance has two output pads, and the overlay filter
  154. instance two input pads. The first output pad of split is labelled
  155. "L1", the first input pad of overlay is labelled "L2", and the second
  156. output pad of split is linked to the second input pad of overlay,
  157. which are both unlabelled.
  158. In a filter description, if the input label of the first filter is not
  159. specified, "in" is assumed; if the output label of the last filter is not
  160. specified, "out" is assumed.
  161. In a complete filterchain all the unlabelled filter input and output
  162. pads must be connected. A filtergraph is considered valid if all the
  163. filter input and output pads of all the filterchains are connected.
  164. Libavfilter will automatically insert @ref{scale} filters where format
  165. conversion is required. It is possible to specify swscale flags
  166. for those automatically inserted scalers by prepending
  167. @code{sws_flags=@var{flags};}
  168. to the filtergraph description.
  169. Here is a BNF description of the filtergraph syntax:
  170. @example
  171. @var{NAME} ::= sequence of alphanumeric characters and '_'
  172. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  173. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  174. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  175. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  176. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  177. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  178. @end example
  179. @section Notes on filtergraph escaping
  180. Filtergraph description composition entails several levels of
  181. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  182. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  183. information about the employed escaping procedure.
  184. A first level escaping affects the content of each filter option
  185. value, which may contain the special character @code{:} used to
  186. separate values, or one of the escaping characters @code{\'}.
  187. A second level escaping affects the whole filter description, which
  188. may contain the escaping characters @code{\'} or the special
  189. characters @code{[],;} used by the filtergraph description.
  190. Finally, when you specify a filtergraph on a shell commandline, you
  191. need to perform a third level escaping for the shell special
  192. characters contained within it.
  193. For example, consider the following string to be embedded in
  194. the @ref{drawtext} filter description @option{text} value:
  195. @example
  196. this is a 'string': may contain one, or more, special characters
  197. @end example
  198. This string contains the @code{'} special escaping character, and the
  199. @code{:} special character, so it needs to be escaped in this way:
  200. @example
  201. text=this is a \'string\'\: may contain one, or more, special characters
  202. @end example
  203. A second level of escaping is required when embedding the filter
  204. description in a filtergraph description, in order to escape all the
  205. filtergraph special characters. Thus the example above becomes:
  206. @example
  207. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  208. @end example
  209. (note that in addition to the @code{\'} escaping special characters,
  210. also @code{,} needs to be escaped).
  211. Finally an additional level of escaping is needed when writing the
  212. filtergraph description in a shell command, which depends on the
  213. escaping rules of the adopted shell. For example, assuming that
  214. @code{\} is special and needs to be escaped with another @code{\}, the
  215. previous string will finally result in:
  216. @example
  217. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  218. @end example
  219. @chapter Timeline editing
  220. Some filters support a generic @option{enable} option. For the filters
  221. supporting timeline editing, this option can be set to an expression which is
  222. evaluated before sending a frame to the filter. If the evaluation is non-zero,
  223. the filter will be enabled, otherwise the frame will be sent unchanged to the
  224. next filter in the filtergraph.
  225. The expression accepts the following values:
  226. @table @samp
  227. @item t
  228. timestamp expressed in seconds, NAN if the input timestamp is unknown
  229. @item n
  230. sequential number of the input frame, starting from 0
  231. @item pos
  232. the position in the file of the input frame, NAN if unknown
  233. @item w
  234. @item h
  235. width and height of the input frame if video
  236. @end table
  237. Additionally, these filters support an @option{enable} command that can be used
  238. to re-define the expression.
  239. Like any other filtering option, the @option{enable} option follows the same
  240. rules.
  241. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  242. minutes, and a @ref{curves} filter starting at 3 seconds:
  243. @example
  244. smartblur = enable='between(t,10,3*60)',
  245. curves = enable='gte(t,3)' : preset=cross_process
  246. @end example
  247. @c man end FILTERGRAPH DESCRIPTION
  248. @chapter Audio Filters
  249. @c man begin AUDIO FILTERS
  250. When you configure your FFmpeg build, you can disable any of the
  251. existing filters using @code{--disable-filters}.
  252. The configure output will show the audio filters included in your
  253. build.
  254. Below is a description of the currently available audio filters.
  255. @section acrossfade
  256. Apply cross fade from one input audio stream to another input audio stream.
  257. The cross fade is applied for specified duration near the end of first stream.
  258. The filter accepts the following options:
  259. @table @option
  260. @item nb_samples, ns
  261. Specify the number of samples for which the cross fade effect has to last.
  262. At the end of the cross fade effect the first input audio will be completely
  263. silent. Default is 44100.
  264. @item duration, d
  265. Specify the duration of the cross fade effect. See
  266. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  267. for the accepted syntax.
  268. By default the duration is determined by @var{nb_samples}.
  269. If set this option is used instead of @var{nb_samples}.
  270. @item overlap, o
  271. Should first stream end overlap with second stream start. Default is enabled.
  272. @item curve1
  273. Set curve for cross fade transition for first stream.
  274. @item curve2
  275. Set curve for cross fade transition for second stream.
  276. For description of available curve types see @ref{afade} filter description.
  277. @end table
  278. @subsection Examples
  279. @itemize
  280. @item
  281. Cross fade from one input to another:
  282. @example
  283. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
  284. @end example
  285. @item
  286. Cross fade from one input to another but without overlapping:
  287. @example
  288. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
  289. @end example
  290. @end itemize
  291. @section adelay
  292. Delay one or more audio channels.
  293. Samples in delayed channel are filled with silence.
  294. The filter accepts the following option:
  295. @table @option
  296. @item delays
  297. Set list of delays in milliseconds for each channel separated by '|'.
  298. At least one delay greater than 0 should be provided.
  299. Unused delays will be silently ignored. If number of given delays is
  300. smaller than number of channels all remaining channels will not be delayed.
  301. @end table
  302. @subsection Examples
  303. @itemize
  304. @item
  305. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  306. the second channel (and any other channels that may be present) unchanged.
  307. @example
  308. adelay=1500|0|500
  309. @end example
  310. @end itemize
  311. @section aecho
  312. Apply echoing to the input audio.
  313. Echoes are reflected sound and can occur naturally amongst mountains
  314. (and sometimes large buildings) when talking or shouting; digital echo
  315. effects emulate this behaviour and are often used to help fill out the
  316. sound of a single instrument or vocal. The time difference between the
  317. original signal and the reflection is the @code{delay}, and the
  318. loudness of the reflected signal is the @code{decay}.
  319. Multiple echoes can have different delays and decays.
  320. A description of the accepted parameters follows.
  321. @table @option
  322. @item in_gain
  323. Set input gain of reflected signal. Default is @code{0.6}.
  324. @item out_gain
  325. Set output gain of reflected signal. Default is @code{0.3}.
  326. @item delays
  327. Set list of time intervals in milliseconds between original signal and reflections
  328. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  329. Default is @code{1000}.
  330. @item decays
  331. Set list of loudnesses of reflected signals separated by '|'.
  332. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  333. Default is @code{0.5}.
  334. @end table
  335. @subsection Examples
  336. @itemize
  337. @item
  338. Make it sound as if there are twice as many instruments as are actually playing:
  339. @example
  340. aecho=0.8:0.88:60:0.4
  341. @end example
  342. @item
  343. If delay is very short, then it sound like a (metallic) robot playing music:
  344. @example
  345. aecho=0.8:0.88:6:0.4
  346. @end example
  347. @item
  348. A longer delay will sound like an open air concert in the mountains:
  349. @example
  350. aecho=0.8:0.9:1000:0.3
  351. @end example
  352. @item
  353. Same as above but with one more mountain:
  354. @example
  355. aecho=0.8:0.9:1000|1800:0.3|0.25
  356. @end example
  357. @end itemize
  358. @section aeval
  359. Modify an audio signal according to the specified expressions.
  360. This filter accepts one or more expressions (one for each channel),
  361. which are evaluated and used to modify a corresponding audio signal.
  362. It accepts the following parameters:
  363. @table @option
  364. @item exprs
  365. Set the '|'-separated expressions list for each separate channel. If
  366. the number of input channels is greater than the number of
  367. expressions, the last specified expression is used for the remaining
  368. output channels.
  369. @item channel_layout, c
  370. Set output channel layout. If not specified, the channel layout is
  371. specified by the number of expressions. If set to @samp{same}, it will
  372. use by default the same input channel layout.
  373. @end table
  374. Each expression in @var{exprs} can contain the following constants and functions:
  375. @table @option
  376. @item ch
  377. channel number of the current expression
  378. @item n
  379. number of the evaluated sample, starting from 0
  380. @item s
  381. sample rate
  382. @item t
  383. time of the evaluated sample expressed in seconds
  384. @item nb_in_channels
  385. @item nb_out_channels
  386. input and output number of channels
  387. @item val(CH)
  388. the value of input channel with number @var{CH}
  389. @end table
  390. Note: this filter is slow. For faster processing you should use a
  391. dedicated filter.
  392. @subsection Examples
  393. @itemize
  394. @item
  395. Half volume:
  396. @example
  397. aeval=val(ch)/2:c=same
  398. @end example
  399. @item
  400. Invert phase of the second channel:
  401. @example
  402. aeval=val(0)|-val(1)
  403. @end example
  404. @end itemize
  405. @anchor{afade}
  406. @section afade
  407. Apply fade-in/out effect to input audio.
  408. A description of the accepted parameters follows.
  409. @table @option
  410. @item type, t
  411. Specify the effect type, can be either @code{in} for fade-in, or
  412. @code{out} for a fade-out effect. Default is @code{in}.
  413. @item start_sample, ss
  414. Specify the number of the start sample for starting to apply the fade
  415. effect. Default is 0.
  416. @item nb_samples, ns
  417. Specify the number of samples for which the fade effect has to last. At
  418. the end of the fade-in effect the output audio will have the same
  419. volume as the input audio, at the end of the fade-out transition
  420. the output audio will be silence. Default is 44100.
  421. @item start_time, st
  422. Specify the start time of the fade effect. Default is 0.
  423. The value must be specified as a time duration; see
  424. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  425. for the accepted syntax.
  426. If set this option is used instead of @var{start_sample}.
  427. @item duration, d
  428. Specify the duration of the fade effect. See
  429. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  430. for the accepted syntax.
  431. At the end of the fade-in effect the output audio will have the same
  432. volume as the input audio, at the end of the fade-out transition
  433. the output audio will be silence.
  434. By default the duration is determined by @var{nb_samples}.
  435. If set this option is used instead of @var{nb_samples}.
  436. @item curve
  437. Set curve for fade transition.
  438. It accepts the following values:
  439. @table @option
  440. @item tri
  441. select triangular, linear slope (default)
  442. @item qsin
  443. select quarter of sine wave
  444. @item hsin
  445. select half of sine wave
  446. @item esin
  447. select exponential sine wave
  448. @item log
  449. select logarithmic
  450. @item ipar
  451. select inverted parabola
  452. @item qua
  453. select quadratic
  454. @item cub
  455. select cubic
  456. @item squ
  457. select square root
  458. @item cbr
  459. select cubic root
  460. @item par
  461. select parabola
  462. @item exp
  463. select exponential
  464. @item iqsin
  465. select inverted quarter of sine wave
  466. @item ihsin
  467. select inverted half of sine wave
  468. @item dese
  469. select double-exponential seat
  470. @item desi
  471. select double-exponential sigmoid
  472. @end table
  473. @end table
  474. @subsection Examples
  475. @itemize
  476. @item
  477. Fade in first 15 seconds of audio:
  478. @example
  479. afade=t=in:ss=0:d=15
  480. @end example
  481. @item
  482. Fade out last 25 seconds of a 900 seconds audio:
  483. @example
  484. afade=t=out:st=875:d=25
  485. @end example
  486. @end itemize
  487. @anchor{aformat}
  488. @section aformat
  489. Set output format constraints for the input audio. The framework will
  490. negotiate the most appropriate format to minimize conversions.
  491. It accepts the following parameters:
  492. @table @option
  493. @item sample_fmts
  494. A '|'-separated list of requested sample formats.
  495. @item sample_rates
  496. A '|'-separated list of requested sample rates.
  497. @item channel_layouts
  498. A '|'-separated list of requested channel layouts.
  499. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  500. for the required syntax.
  501. @end table
  502. If a parameter is omitted, all values are allowed.
  503. Force the output to either unsigned 8-bit or signed 16-bit stereo
  504. @example
  505. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  506. @end example
  507. @section agate
  508. A gate is mainly used to reduce lower parts of a signal. This kind of signal
  509. processing reduces disturbing noise between useful signals.
  510. Gating is done by detecting the volume below a chosen level @var{threshold}
  511. and divide it by the factor set with @var{ratio}. The bottom of the noise
  512. floor is set via @var{range}. Because an exact manipulation of the signal
  513. would cause distortion of the waveform the reduction can be levelled over
  514. time. This is done by setting @var{attack} and @var{release}.
  515. @var{attack} determines how long the signal has to fall below the threshold
  516. before any reduction will occur and @var{release} sets the time the signal
  517. has to raise above the threshold to reduce the reduction again.
  518. Shorter signals than the chosen attack time will be left untouched.
  519. @table @option
  520. @item level_in
  521. Set input level before filtering.
  522. @item range
  523. Set the level of gain reduction when the signal is below the threshold.
  524. @item threshold
  525. If a signal rises above this level the gain reduction is released.
  526. @item ratio
  527. Set a ratio about which the signal is reduced.
  528. @item attack
  529. Amount of milliseconds the signal has to rise above the threshold before gain
  530. reduction stops.
  531. @item release
  532. Amount of milliseconds the signal has to fall below the threshold before the
  533. reduction is increased again.
  534. @item makeup
  535. Set amount of amplification of signal after processing.
  536. @item knee
  537. Curve the sharp knee around the threshold to enter gain reduction more softly.
  538. @item detection
  539. Choose if exact signal should be taken for detection or an RMS like one.
  540. @item link
  541. Choose if the average level between all channels or the louder channel affects
  542. the reduction.
  543. @end table
  544. @section alimiter
  545. The limiter prevents input signal from raising over a desired threshold.
  546. This limiter uses lookahead technology to prevent your signal from distorting.
  547. It means that there is a small delay after signal is processed. Keep in mind
  548. that the delay it produces is the attack time you set.
  549. The filter accepts the following options:
  550. @table @option
  551. @item limit
  552. Don't let signals above this level pass the limiter. The removed amplitude is
  553. added automatically. Default is 1.
  554. @item attack
  555. The limiter will reach its attenuation level in this amount of time in
  556. milliseconds. Default is 5 milliseconds.
  557. @item release
  558. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  559. Default is 50 milliseconds.
  560. @item asc
  561. When gain reduction is always needed ASC takes care of releasing to an
  562. average reduction level rather than reaching a reduction of 0 in the release
  563. time.
  564. @item asc_level
  565. Select how much the release time is affected by ASC, 0 means nearly no changes
  566. in release time while 1 produces higher release times.
  567. @end table
  568. Depending on picked setting it is recommended to upsample input 2x or 4x times
  569. with @ref{aresample} before applying this filter.
  570. @section allpass
  571. Apply a two-pole all-pass filter with central frequency (in Hz)
  572. @var{frequency}, and filter-width @var{width}.
  573. An all-pass filter changes the audio's frequency to phase relationship
  574. without changing its frequency to amplitude relationship.
  575. The filter accepts the following options:
  576. @table @option
  577. @item frequency, f
  578. Set frequency in Hz.
  579. @item width_type
  580. Set method to specify band-width of filter.
  581. @table @option
  582. @item h
  583. Hz
  584. @item q
  585. Q-Factor
  586. @item o
  587. octave
  588. @item s
  589. slope
  590. @end table
  591. @item width, w
  592. Specify the band-width of a filter in width_type units.
  593. @end table
  594. @anchor{amerge}
  595. @section amerge
  596. Merge two or more audio streams into a single multi-channel stream.
  597. The filter accepts the following options:
  598. @table @option
  599. @item inputs
  600. Set the number of inputs. Default is 2.
  601. @end table
  602. If the channel layouts of the inputs are disjoint, and therefore compatible,
  603. the channel layout of the output will be set accordingly and the channels
  604. will be reordered as necessary. If the channel layouts of the inputs are not
  605. disjoint, the output will have all the channels of the first input then all
  606. the channels of the second input, in that order, and the channel layout of
  607. the output will be the default value corresponding to the total number of
  608. channels.
  609. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  610. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  611. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  612. first input, b1 is the first channel of the second input).
  613. On the other hand, if both input are in stereo, the output channels will be
  614. in the default order: a1, a2, b1, b2, and the channel layout will be
  615. arbitrarily set to 4.0, which may or may not be the expected value.
  616. All inputs must have the same sample rate, and format.
  617. If inputs do not have the same duration, the output will stop with the
  618. shortest.
  619. @subsection Examples
  620. @itemize
  621. @item
  622. Merge two mono files into a stereo stream:
  623. @example
  624. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  625. @end example
  626. @item
  627. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  628. @example
  629. ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
  630. @end example
  631. @end itemize
  632. @section amix
  633. Mixes multiple audio inputs into a single output.
  634. Note that this filter only supports float samples (the @var{amerge}
  635. and @var{pan} audio filters support many formats). If the @var{amix}
  636. input has integer samples then @ref{aresample} will be automatically
  637. inserted to perform the conversion to float samples.
  638. For example
  639. @example
  640. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  641. @end example
  642. will mix 3 input audio streams to a single output with the same duration as the
  643. first input and a dropout transition time of 3 seconds.
  644. It accepts the following parameters:
  645. @table @option
  646. @item inputs
  647. The number of inputs. If unspecified, it defaults to 2.
  648. @item duration
  649. How to determine the end-of-stream.
  650. @table @option
  651. @item longest
  652. The duration of the longest input. (default)
  653. @item shortest
  654. The duration of the shortest input.
  655. @item first
  656. The duration of the first input.
  657. @end table
  658. @item dropout_transition
  659. The transition time, in seconds, for volume renormalization when an input
  660. stream ends. The default value is 2 seconds.
  661. @end table
  662. @section anull
  663. Pass the audio source unchanged to the output.
  664. @section apad
  665. Pad the end of an audio stream with silence.
  666. This can be used together with @command{ffmpeg} @option{-shortest} to
  667. extend audio streams to the same length as the video stream.
  668. A description of the accepted options follows.
  669. @table @option
  670. @item packet_size
  671. Set silence packet size. Default value is 4096.
  672. @item pad_len
  673. Set the number of samples of silence to add to the end. After the
  674. value is reached, the stream is terminated. This option is mutually
  675. exclusive with @option{whole_len}.
  676. @item whole_len
  677. Set the minimum total number of samples in the output audio stream. If
  678. the value is longer than the input audio length, silence is added to
  679. the end, until the value is reached. This option is mutually exclusive
  680. with @option{pad_len}.
  681. @end table
  682. If neither the @option{pad_len} nor the @option{whole_len} option is
  683. set, the filter will add silence to the end of the input stream
  684. indefinitely.
  685. @subsection Examples
  686. @itemize
  687. @item
  688. Add 1024 samples of silence to the end of the input:
  689. @example
  690. apad=pad_len=1024
  691. @end example
  692. @item
  693. Make sure the audio output will contain at least 10000 samples, pad
  694. the input with silence if required:
  695. @example
  696. apad=whole_len=10000
  697. @end example
  698. @item
  699. Use @command{ffmpeg} to pad the audio input with silence, so that the
  700. video stream will always result the shortest and will be converted
  701. until the end in the output file when using the @option{shortest}
  702. option:
  703. @example
  704. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  705. @end example
  706. @end itemize
  707. @section aphaser
  708. Add a phasing effect to the input audio.
  709. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  710. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  711. A description of the accepted parameters follows.
  712. @table @option
  713. @item in_gain
  714. Set input gain. Default is 0.4.
  715. @item out_gain
  716. Set output gain. Default is 0.74
  717. @item delay
  718. Set delay in milliseconds. Default is 3.0.
  719. @item decay
  720. Set decay. Default is 0.4.
  721. @item speed
  722. Set modulation speed in Hz. Default is 0.5.
  723. @item type
  724. Set modulation type. Default is triangular.
  725. It accepts the following values:
  726. @table @samp
  727. @item triangular, t
  728. @item sinusoidal, s
  729. @end table
  730. @end table
  731. @anchor{aresample}
  732. @section aresample
  733. Resample the input audio to the specified parameters, using the
  734. libswresample library. If none are specified then the filter will
  735. automatically convert between its input and output.
  736. This filter is also able to stretch/squeeze the audio data to make it match
  737. the timestamps or to inject silence / cut out audio to make it match the
  738. timestamps, do a combination of both or do neither.
  739. The filter accepts the syntax
  740. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  741. expresses a sample rate and @var{resampler_options} is a list of
  742. @var{key}=@var{value} pairs, separated by ":". See the
  743. ffmpeg-resampler manual for the complete list of supported options.
  744. @subsection Examples
  745. @itemize
  746. @item
  747. Resample the input audio to 44100Hz:
  748. @example
  749. aresample=44100
  750. @end example
  751. @item
  752. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  753. samples per second compensation:
  754. @example
  755. aresample=async=1000
  756. @end example
  757. @end itemize
  758. @section asetnsamples
  759. Set the number of samples per each output audio frame.
  760. The last output packet may contain a different number of samples, as
  761. the filter will flush all the remaining samples when the input audio
  762. signal its end.
  763. The filter accepts the following options:
  764. @table @option
  765. @item nb_out_samples, n
  766. Set the number of frames per each output audio frame. The number is
  767. intended as the number of samples @emph{per each channel}.
  768. Default value is 1024.
  769. @item pad, p
  770. If set to 1, the filter will pad the last audio frame with zeroes, so
  771. that the last frame will contain the same number of samples as the
  772. previous ones. Default value is 1.
  773. @end table
  774. For example, to set the number of per-frame samples to 1234 and
  775. disable padding for the last frame, use:
  776. @example
  777. asetnsamples=n=1234:p=0
  778. @end example
  779. @section asetrate
  780. Set the sample rate without altering the PCM data.
  781. This will result in a change of speed and pitch.
  782. The filter accepts the following options:
  783. @table @option
  784. @item sample_rate, r
  785. Set the output sample rate. Default is 44100 Hz.
  786. @end table
  787. @section ashowinfo
  788. Show a line containing various information for each input audio frame.
  789. The input audio is not modified.
  790. The shown line contains a sequence of key/value pairs of the form
  791. @var{key}:@var{value}.
  792. The following values are shown in the output:
  793. @table @option
  794. @item n
  795. The (sequential) number of the input frame, starting from 0.
  796. @item pts
  797. The presentation timestamp of the input frame, in time base units; the time base
  798. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  799. @item pts_time
  800. The presentation timestamp of the input frame in seconds.
  801. @item pos
  802. position of the frame in the input stream, -1 if this information in
  803. unavailable and/or meaningless (for example in case of synthetic audio)
  804. @item fmt
  805. The sample format.
  806. @item chlayout
  807. The channel layout.
  808. @item rate
  809. The sample rate for the audio frame.
  810. @item nb_samples
  811. The number of samples (per channel) in the frame.
  812. @item checksum
  813. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  814. audio, the data is treated as if all the planes were concatenated.
  815. @item plane_checksums
  816. A list of Adler-32 checksums for each data plane.
  817. @end table
  818. @anchor{astats}
  819. @section astats
  820. Display time domain statistical information about the audio channels.
  821. Statistics are calculated and displayed for each audio channel and,
  822. where applicable, an overall figure is also given.
  823. It accepts the following option:
  824. @table @option
  825. @item length
  826. Short window length in seconds, used for peak and trough RMS measurement.
  827. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  828. @item metadata
  829. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  830. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  831. disabled.
  832. Available keys for each channel are:
  833. DC_offset
  834. Min_level
  835. Max_level
  836. Min_difference
  837. Max_difference
  838. Mean_difference
  839. Peak_level
  840. RMS_peak
  841. RMS_trough
  842. Crest_factor
  843. Flat_factor
  844. Peak_count
  845. Bit_depth
  846. and for Overall:
  847. DC_offset
  848. Min_level
  849. Max_level
  850. Min_difference
  851. Max_difference
  852. Mean_difference
  853. Peak_level
  854. RMS_level
  855. RMS_peak
  856. RMS_trough
  857. Flat_factor
  858. Peak_count
  859. Bit_depth
  860. Number_of_samples
  861. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  862. this @code{lavfi.astats.Overall.Peak_count}.
  863. For description what each key means read below.
  864. @item reset
  865. Set number of frame after which stats are going to be recalculated.
  866. Default is disabled.
  867. @end table
  868. A description of each shown parameter follows:
  869. @table @option
  870. @item DC offset
  871. Mean amplitude displacement from zero.
  872. @item Min level
  873. Minimal sample level.
  874. @item Max level
  875. Maximal sample level.
  876. @item Min difference
  877. Minimal difference between two consecutive samples.
  878. @item Max difference
  879. Maximal difference between two consecutive samples.
  880. @item Mean difference
  881. Mean difference between two consecutive samples.
  882. The average of each difference between two consecutive samples.
  883. @item Peak level dB
  884. @item RMS level dB
  885. Standard peak and RMS level measured in dBFS.
  886. @item RMS peak dB
  887. @item RMS trough dB
  888. Peak and trough values for RMS level measured over a short window.
  889. @item Crest factor
  890. Standard ratio of peak to RMS level (note: not in dB).
  891. @item Flat factor
  892. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  893. (i.e. either @var{Min level} or @var{Max level}).
  894. @item Peak count
  895. Number of occasions (not the number of samples) that the signal attained either
  896. @var{Min level} or @var{Max level}.
  897. @item Bit depth
  898. Overall bit depth of audio. Number of bits used for each sample.
  899. @end table
  900. @section asyncts
  901. Synchronize audio data with timestamps by squeezing/stretching it and/or
  902. dropping samples/adding silence when needed.
  903. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  904. It accepts the following parameters:
  905. @table @option
  906. @item compensate
  907. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  908. by default. When disabled, time gaps are covered with silence.
  909. @item min_delta
  910. The minimum difference between timestamps and audio data (in seconds) to trigger
  911. adding/dropping samples. The default value is 0.1. If you get an imperfect
  912. sync with this filter, try setting this parameter to 0.
  913. @item max_comp
  914. The maximum compensation in samples per second. Only relevant with compensate=1.
  915. The default value is 500.
  916. @item first_pts
  917. Assume that the first PTS should be this value. The time base is 1 / sample
  918. rate. This allows for padding/trimming at the start of the stream. By default,
  919. no assumption is made about the first frame's expected PTS, so no padding or
  920. trimming is done. For example, this could be set to 0 to pad the beginning with
  921. silence if an audio stream starts after the video stream or to trim any samples
  922. with a negative PTS due to encoder delay.
  923. @end table
  924. @section atempo
  925. Adjust audio tempo.
  926. The filter accepts exactly one parameter, the audio tempo. If not
  927. specified then the filter will assume nominal 1.0 tempo. Tempo must
  928. be in the [0.5, 2.0] range.
  929. @subsection Examples
  930. @itemize
  931. @item
  932. Slow down audio to 80% tempo:
  933. @example
  934. atempo=0.8
  935. @end example
  936. @item
  937. To speed up audio to 125% tempo:
  938. @example
  939. atempo=1.25
  940. @end example
  941. @end itemize
  942. @section atrim
  943. Trim the input so that the output contains one continuous subpart of the input.
  944. It accepts the following parameters:
  945. @table @option
  946. @item start
  947. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  948. sample with the timestamp @var{start} will be the first sample in the output.
  949. @item end
  950. Specify time of the first audio sample that will be dropped, i.e. the
  951. audio sample immediately preceding the one with the timestamp @var{end} will be
  952. the last sample in the output.
  953. @item start_pts
  954. Same as @var{start}, except this option sets the start timestamp in samples
  955. instead of seconds.
  956. @item end_pts
  957. Same as @var{end}, except this option sets the end timestamp in samples instead
  958. of seconds.
  959. @item duration
  960. The maximum duration of the output in seconds.
  961. @item start_sample
  962. The number of the first sample that should be output.
  963. @item end_sample
  964. The number of the first sample that should be dropped.
  965. @end table
  966. @option{start}, @option{end}, and @option{duration} are expressed as time
  967. duration specifications; see
  968. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  969. Note that the first two sets of the start/end options and the @option{duration}
  970. option look at the frame timestamp, while the _sample options simply count the
  971. samples that pass through the filter. So start/end_pts and start/end_sample will
  972. give different results when the timestamps are wrong, inexact or do not start at
  973. zero. Also note that this filter does not modify the timestamps. If you wish
  974. to have the output timestamps start at zero, insert the asetpts filter after the
  975. atrim filter.
  976. If multiple start or end options are set, this filter tries to be greedy and
  977. keep all samples that match at least one of the specified constraints. To keep
  978. only the part that matches all the constraints at once, chain multiple atrim
  979. filters.
  980. The defaults are such that all the input is kept. So it is possible to set e.g.
  981. just the end values to keep everything before the specified time.
  982. Examples:
  983. @itemize
  984. @item
  985. Drop everything except the second minute of input:
  986. @example
  987. ffmpeg -i INPUT -af atrim=60:120
  988. @end example
  989. @item
  990. Keep only the first 1000 samples:
  991. @example
  992. ffmpeg -i INPUT -af atrim=end_sample=1000
  993. @end example
  994. @end itemize
  995. @section bandpass
  996. Apply a two-pole Butterworth band-pass filter with central
  997. frequency @var{frequency}, and (3dB-point) band-width width.
  998. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  999. instead of the default: constant 0dB peak gain.
  1000. The filter roll off at 6dB per octave (20dB per decade).
  1001. The filter accepts the following options:
  1002. @table @option
  1003. @item frequency, f
  1004. Set the filter's central frequency. Default is @code{3000}.
  1005. @item csg
  1006. Constant skirt gain if set to 1. Defaults to 0.
  1007. @item width_type
  1008. Set method to specify band-width of filter.
  1009. @table @option
  1010. @item h
  1011. Hz
  1012. @item q
  1013. Q-Factor
  1014. @item o
  1015. octave
  1016. @item s
  1017. slope
  1018. @end table
  1019. @item width, w
  1020. Specify the band-width of a filter in width_type units.
  1021. @end table
  1022. @section bandreject
  1023. Apply a two-pole Butterworth band-reject filter with central
  1024. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1025. The filter roll off at 6dB per octave (20dB per decade).
  1026. The filter accepts the following options:
  1027. @table @option
  1028. @item frequency, f
  1029. Set the filter's central frequency. Default is @code{3000}.
  1030. @item width_type
  1031. Set method to specify band-width of filter.
  1032. @table @option
  1033. @item h
  1034. Hz
  1035. @item q
  1036. Q-Factor
  1037. @item o
  1038. octave
  1039. @item s
  1040. slope
  1041. @end table
  1042. @item width, w
  1043. Specify the band-width of a filter in width_type units.
  1044. @end table
  1045. @section bass
  1046. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1047. shelving filter with a response similar to that of a standard
  1048. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1049. The filter accepts the following options:
  1050. @table @option
  1051. @item gain, g
  1052. Give the gain at 0 Hz. Its useful range is about -20
  1053. (for a large cut) to +20 (for a large boost).
  1054. Beware of clipping when using a positive gain.
  1055. @item frequency, f
  1056. Set the filter's central frequency and so can be used
  1057. to extend or reduce the frequency range to be boosted or cut.
  1058. The default value is @code{100} Hz.
  1059. @item width_type
  1060. Set method to specify band-width of filter.
  1061. @table @option
  1062. @item h
  1063. Hz
  1064. @item q
  1065. Q-Factor
  1066. @item o
  1067. octave
  1068. @item s
  1069. slope
  1070. @end table
  1071. @item width, w
  1072. Determine how steep is the filter's shelf transition.
  1073. @end table
  1074. @section biquad
  1075. Apply a biquad IIR filter with the given coefficients.
  1076. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1077. are the numerator and denominator coefficients respectively.
  1078. @section bs2b
  1079. Bauer stereo to binaural transformation, which improves headphone listening of
  1080. stereo audio records.
  1081. It accepts the following parameters:
  1082. @table @option
  1083. @item profile
  1084. Pre-defined crossfeed level.
  1085. @table @option
  1086. @item default
  1087. Default level (fcut=700, feed=50).
  1088. @item cmoy
  1089. Chu Moy circuit (fcut=700, feed=60).
  1090. @item jmeier
  1091. Jan Meier circuit (fcut=650, feed=95).
  1092. @end table
  1093. @item fcut
  1094. Cut frequency (in Hz).
  1095. @item feed
  1096. Feed level (in Hz).
  1097. @end table
  1098. @section channelmap
  1099. Remap input channels to new locations.
  1100. It accepts the following parameters:
  1101. @table @option
  1102. @item channel_layout
  1103. The channel layout of the output stream.
  1104. @item map
  1105. Map channels from input to output. The argument is a '|'-separated list of
  1106. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1107. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1108. channel (e.g. FL for front left) or its index in the input channel layout.
  1109. @var{out_channel} is the name of the output channel or its index in the output
  1110. channel layout. If @var{out_channel} is not given then it is implicitly an
  1111. index, starting with zero and increasing by one for each mapping.
  1112. @end table
  1113. If no mapping is present, the filter will implicitly map input channels to
  1114. output channels, preserving indices.
  1115. For example, assuming a 5.1+downmix input MOV file,
  1116. @example
  1117. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1118. @end example
  1119. will create an output WAV file tagged as stereo from the downmix channels of
  1120. the input.
  1121. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1122. @example
  1123. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1124. @end example
  1125. @section channelsplit
  1126. Split each channel from an input audio stream into a separate output stream.
  1127. It accepts the following parameters:
  1128. @table @option
  1129. @item channel_layout
  1130. The channel layout of the input stream. The default is "stereo".
  1131. @end table
  1132. For example, assuming a stereo input MP3 file,
  1133. @example
  1134. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1135. @end example
  1136. will create an output Matroska file with two audio streams, one containing only
  1137. the left channel and the other the right channel.
  1138. Split a 5.1 WAV file into per-channel files:
  1139. @example
  1140. ffmpeg -i in.wav -filter_complex
  1141. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1142. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1143. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1144. side_right.wav
  1145. @end example
  1146. @section chorus
  1147. Add a chorus effect to the audio.
  1148. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1149. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1150. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1151. The modulation depth defines the range the modulated delay is played before or after
  1152. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1153. sound tuned around the original one, like in a chorus where some vocals are slightly
  1154. off key.
  1155. It accepts the following parameters:
  1156. @table @option
  1157. @item in_gain
  1158. Set input gain. Default is 0.4.
  1159. @item out_gain
  1160. Set output gain. Default is 0.4.
  1161. @item delays
  1162. Set delays. A typical delay is around 40ms to 60ms.
  1163. @item decays
  1164. Set decays.
  1165. @item speeds
  1166. Set speeds.
  1167. @item depths
  1168. Set depths.
  1169. @end table
  1170. @subsection Examples
  1171. @itemize
  1172. @item
  1173. A single delay:
  1174. @example
  1175. chorus=0.7:0.9:55:0.4:0.25:2
  1176. @end example
  1177. @item
  1178. Two delays:
  1179. @example
  1180. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1181. @end example
  1182. @item
  1183. Fuller sounding chorus with three delays:
  1184. @example
  1185. 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
  1186. @end example
  1187. @end itemize
  1188. @section compand
  1189. Compress or expand the audio's dynamic range.
  1190. It accepts the following parameters:
  1191. @table @option
  1192. @item attacks
  1193. @item decays
  1194. A list of times in seconds for each channel over which the instantaneous level
  1195. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1196. increase of volume and @var{decays} refers to decrease of volume. For most
  1197. situations, the attack time (response to the audio getting louder) should be
  1198. shorter than the decay time, because the human ear is more sensitive to sudden
  1199. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1200. a typical value for decay is 0.8 seconds.
  1201. If specified number of attacks & decays is lower than number of channels, the last
  1202. set attack/decay will be used for all remaining channels.
  1203. @item points
  1204. A list of points for the transfer function, specified in dB relative to the
  1205. maximum possible signal amplitude. Each key points list must be defined using
  1206. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1207. @code{x0/y0 x1/y1 x2/y2 ....}
  1208. The input values must be in strictly increasing order but the transfer function
  1209. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1210. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1211. function are @code{-70/-70|-60/-20}.
  1212. @item soft-knee
  1213. Set the curve radius in dB for all joints. It defaults to 0.01.
  1214. @item gain
  1215. Set the additional gain in dB to be applied at all points on the transfer
  1216. function. This allows for easy adjustment of the overall gain.
  1217. It defaults to 0.
  1218. @item volume
  1219. Set an initial volume, in dB, to be assumed for each channel when filtering
  1220. starts. This permits the user to supply a nominal level initially, so that, for
  1221. example, a very large gain is not applied to initial signal levels before the
  1222. companding has begun to operate. A typical value for audio which is initially
  1223. quiet is -90 dB. It defaults to 0.
  1224. @item delay
  1225. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1226. delayed before being fed to the volume adjuster. Specifying a delay
  1227. approximately equal to the attack/decay times allows the filter to effectively
  1228. operate in predictive rather than reactive mode. It defaults to 0.
  1229. @end table
  1230. @subsection Examples
  1231. @itemize
  1232. @item
  1233. Make music with both quiet and loud passages suitable for listening to in a
  1234. noisy environment:
  1235. @example
  1236. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1237. @end example
  1238. Another example for audio with whisper and explosion parts:
  1239. @example
  1240. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1241. @end example
  1242. @item
  1243. A noise gate for when the noise is at a lower level than the signal:
  1244. @example
  1245. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1246. @end example
  1247. @item
  1248. Here is another noise gate, this time for when the noise is at a higher level
  1249. than the signal (making it, in some ways, similar to squelch):
  1250. @example
  1251. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1252. @end example
  1253. @end itemize
  1254. @section dcshift
  1255. Apply a DC shift to the audio.
  1256. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1257. in the recording chain) from the audio. The effect of a DC offset is reduced
  1258. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1259. a signal has a DC offset.
  1260. @table @option
  1261. @item shift
  1262. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1263. the audio.
  1264. @item limitergain
  1265. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1266. used to prevent clipping.
  1267. @end table
  1268. @section dynaudnorm
  1269. Dynamic Audio Normalizer.
  1270. This filter applies a certain amount of gain to the input audio in order
  1271. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1272. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1273. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1274. This allows for applying extra gain to the "quiet" sections of the audio
  1275. while avoiding distortions or clipping the "loud" sections. In other words:
  1276. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1277. sections, in the sense that the volume of each section is brought to the
  1278. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1279. this goal *without* applying "dynamic range compressing". It will retain 100%
  1280. of the dynamic range *within* each section of the audio file.
  1281. @table @option
  1282. @item f
  1283. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1284. Default is 500 milliseconds.
  1285. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1286. referred to as frames. This is required, because a peak magnitude has no
  1287. meaning for just a single sample value. Instead, we need to determine the
  1288. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1289. normalizer would simply use the peak magnitude of the complete file, the
  1290. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1291. frame. The length of a frame is specified in milliseconds. By default, the
  1292. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1293. been found to give good results with most files.
  1294. Note that the exact frame length, in number of samples, will be determined
  1295. automatically, based on the sampling rate of the individual input audio file.
  1296. @item g
  1297. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1298. number. Default is 31.
  1299. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1300. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1301. is specified in frames, centered around the current frame. For the sake of
  1302. simplicity, this must be an odd number. Consequently, the default value of 31
  1303. takes into account the current frame, as well as the 15 preceding frames and
  1304. the 15 subsequent frames. Using a larger window results in a stronger
  1305. smoothing effect and thus in less gain variation, i.e. slower gain
  1306. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1307. effect and thus in more gain variation, i.e. faster gain adaptation.
  1308. In other words, the more you increase this value, the more the Dynamic Audio
  1309. Normalizer will behave like a "traditional" normalization filter. On the
  1310. contrary, the more you decrease this value, the more the Dynamic Audio
  1311. Normalizer will behave like a dynamic range compressor.
  1312. @item p
  1313. Set the target peak value. This specifies the highest permissible magnitude
  1314. level for the normalized audio input. This filter will try to approach the
  1315. target peak magnitude as closely as possible, but at the same time it also
  1316. makes sure that the normalized signal will never exceed the peak magnitude.
  1317. A frame's maximum local gain factor is imposed directly by the target peak
  1318. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1319. It is not recommended to go above this value.
  1320. @item m
  1321. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1322. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1323. factor for each input frame, i.e. the maximum gain factor that does not
  1324. result in clipping or distortion. The maximum gain factor is determined by
  1325. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1326. additionally bounds the frame's maximum gain factor by a predetermined
  1327. (global) maximum gain factor. This is done in order to avoid excessive gain
  1328. factors in "silent" or almost silent frames. By default, the maximum gain
  1329. factor is 10.0, For most inputs the default value should be sufficient and
  1330. it usually is not recommended to increase this value. Though, for input
  1331. with an extremely low overall volume level, it may be necessary to allow even
  1332. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1333. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1334. Instead, a "sigmoid" threshold function will be applied. This way, the
  1335. gain factors will smoothly approach the threshold value, but never exceed that
  1336. value.
  1337. @item r
  1338. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1339. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1340. This means that the maximum local gain factor for each frame is defined
  1341. (only) by the frame's highest magnitude sample. This way, the samples can
  1342. be amplified as much as possible without exceeding the maximum signal
  1343. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1344. Normalizer can also take into account the frame's root mean square,
  1345. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1346. determine the power of a time-varying signal. It is therefore considered
  1347. that the RMS is a better approximation of the "perceived loudness" than
  1348. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1349. frames to a constant RMS value, a uniform "perceived loudness" can be
  1350. established. If a target RMS value has been specified, a frame's local gain
  1351. factor is defined as the factor that would result in exactly that RMS value.
  1352. Note, however, that the maximum local gain factor is still restricted by the
  1353. frame's highest magnitude sample, in order to prevent clipping.
  1354. @item n
  1355. Enable channels coupling. By default is enabled.
  1356. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1357. amount. This means the same gain factor will be applied to all channels, i.e.
  1358. the maximum possible gain factor is determined by the "loudest" channel.
  1359. However, in some recordings, it may happen that the volume of the different
  1360. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1361. In this case, this option can be used to disable the channel coupling. This way,
  1362. the gain factor will be determined independently for each channel, depending
  1363. only on the individual channel's highest magnitude sample. This allows for
  1364. harmonizing the volume of the different channels.
  1365. @item c
  1366. Enable DC bias correction. By default is disabled.
  1367. An audio signal (in the time domain) is a sequence of sample values.
  1368. In the Dynamic Audio Normalizer these sample values are represented in the
  1369. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1370. audio signal, or "waveform", should be centered around the zero point.
  1371. That means if we calculate the mean value of all samples in a file, or in a
  1372. single frame, then the result should be 0.0 or at least very close to that
  1373. value. If, however, there is a significant deviation of the mean value from
  1374. 0.0, in either positive or negative direction, this is referred to as a
  1375. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1376. Audio Normalizer provides optional DC bias correction.
  1377. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1378. the mean value, or "DC correction" offset, of each input frame and subtract
  1379. that value from all of the frame's sample values which ensures those samples
  1380. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1381. boundaries, the DC correction offset values will be interpolated smoothly
  1382. between neighbouring frames.
  1383. @item b
  1384. Enable alternative boundary mode. By default is disabled.
  1385. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1386. around each frame. This includes the preceding frames as well as the
  1387. subsequent frames. However, for the "boundary" frames, located at the very
  1388. beginning and at the very end of the audio file, not all neighbouring
  1389. frames are available. In particular, for the first few frames in the audio
  1390. file, the preceding frames are not known. And, similarly, for the last few
  1391. frames in the audio file, the subsequent frames are not known. Thus, the
  1392. question arises which gain factors should be assumed for the missing frames
  1393. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1394. to deal with this situation. The default boundary mode assumes a gain factor
  1395. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1396. "fade out" at the beginning and at the end of the input, respectively.
  1397. @item s
  1398. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1399. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1400. compression. This means that signal peaks will not be pruned and thus the
  1401. full dynamic range will be retained within each local neighbourhood. However,
  1402. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1403. normalization algorithm with a more "traditional" compression.
  1404. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1405. (thresholding) function. If (and only if) the compression feature is enabled,
  1406. all input frames will be processed by a soft knee thresholding function prior
  1407. to the actual normalization process. Put simply, the thresholding function is
  1408. going to prune all samples whose magnitude exceeds a certain threshold value.
  1409. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1410. value. Instead, the threshold value will be adjusted for each individual
  1411. frame.
  1412. In general, smaller parameters result in stronger compression, and vice versa.
  1413. Values below 3.0 are not recommended, because audible distortion may appear.
  1414. @end table
  1415. @section earwax
  1416. Make audio easier to listen to on headphones.
  1417. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1418. so that when listened to on headphones the stereo image is moved from
  1419. inside your head (standard for headphones) to outside and in front of
  1420. the listener (standard for speakers).
  1421. Ported from SoX.
  1422. @section equalizer
  1423. Apply a two-pole peaking equalisation (EQ) filter. With this
  1424. filter, the signal-level at and around a selected frequency can
  1425. be increased or decreased, whilst (unlike bandpass and bandreject
  1426. filters) that at all other frequencies is unchanged.
  1427. In order to produce complex equalisation curves, this filter can
  1428. be given several times, each with a different central frequency.
  1429. The filter accepts the following options:
  1430. @table @option
  1431. @item frequency, f
  1432. Set the filter's central frequency in Hz.
  1433. @item width_type
  1434. Set method to specify band-width of filter.
  1435. @table @option
  1436. @item h
  1437. Hz
  1438. @item q
  1439. Q-Factor
  1440. @item o
  1441. octave
  1442. @item s
  1443. slope
  1444. @end table
  1445. @item width, w
  1446. Specify the band-width of a filter in width_type units.
  1447. @item gain, g
  1448. Set the required gain or attenuation in dB.
  1449. Beware of clipping when using a positive gain.
  1450. @end table
  1451. @subsection Examples
  1452. @itemize
  1453. @item
  1454. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1455. @example
  1456. equalizer=f=1000:width_type=h:width=200:g=-10
  1457. @end example
  1458. @item
  1459. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1460. @example
  1461. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1462. @end example
  1463. @end itemize
  1464. @section extrastereo
  1465. Linearly increases the difference between left and right channels which
  1466. adds some sort of "live" effect to playback.
  1467. The filter accepts the following option:
  1468. @table @option
  1469. @item m
  1470. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1471. (average of both channels), with 1.0 sound will be unchanged, with
  1472. -1.0 left and right channels will be swapped.
  1473. @item c
  1474. Enable clipping. By default is enabled.
  1475. @end table
  1476. @section flanger
  1477. Apply a flanging effect to the audio.
  1478. The filter accepts the following options:
  1479. @table @option
  1480. @item delay
  1481. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1482. @item depth
  1483. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1484. @item regen
  1485. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1486. Default value is 0.
  1487. @item width
  1488. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1489. Default value is 71.
  1490. @item speed
  1491. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1492. @item shape
  1493. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1494. Default value is @var{sinusoidal}.
  1495. @item phase
  1496. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1497. Default value is 25.
  1498. @item interp
  1499. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1500. Default is @var{linear}.
  1501. @end table
  1502. @section highpass
  1503. Apply a high-pass filter with 3dB point frequency.
  1504. The filter can be either single-pole, or double-pole (the default).
  1505. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1506. The filter accepts the following options:
  1507. @table @option
  1508. @item frequency, f
  1509. Set frequency in Hz. Default is 3000.
  1510. @item poles, p
  1511. Set number of poles. Default is 2.
  1512. @item width_type
  1513. Set method to specify band-width of filter.
  1514. @table @option
  1515. @item h
  1516. Hz
  1517. @item q
  1518. Q-Factor
  1519. @item o
  1520. octave
  1521. @item s
  1522. slope
  1523. @end table
  1524. @item width, w
  1525. Specify the band-width of a filter in width_type units.
  1526. Applies only to double-pole filter.
  1527. The default is 0.707q and gives a Butterworth response.
  1528. @end table
  1529. @section join
  1530. Join multiple input streams into one multi-channel stream.
  1531. It accepts the following parameters:
  1532. @table @option
  1533. @item inputs
  1534. The number of input streams. It defaults to 2.
  1535. @item channel_layout
  1536. The desired output channel layout. It defaults to stereo.
  1537. @item map
  1538. Map channels from inputs to output. The argument is a '|'-separated list of
  1539. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1540. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1541. can be either the name of the input channel (e.g. FL for front left) or its
  1542. index in the specified input stream. @var{out_channel} is the name of the output
  1543. channel.
  1544. @end table
  1545. The filter will attempt to guess the mappings when they are not specified
  1546. explicitly. It does so by first trying to find an unused matching input channel
  1547. and if that fails it picks the first unused input channel.
  1548. Join 3 inputs (with properly set channel layouts):
  1549. @example
  1550. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1551. @end example
  1552. Build a 5.1 output from 6 single-channel streams:
  1553. @example
  1554. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1555. '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'
  1556. out
  1557. @end example
  1558. @section ladspa
  1559. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1560. To enable compilation of this filter you need to configure FFmpeg with
  1561. @code{--enable-ladspa}.
  1562. @table @option
  1563. @item file, f
  1564. Specifies the name of LADSPA plugin library to load. If the environment
  1565. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1566. each one of the directories specified by the colon separated list in
  1567. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1568. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1569. @file{/usr/lib/ladspa/}.
  1570. @item plugin, p
  1571. Specifies the plugin within the library. Some libraries contain only
  1572. one plugin, but others contain many of them. If this is not set filter
  1573. will list all available plugins within the specified library.
  1574. @item controls, c
  1575. Set the '|' separated list of controls which are zero or more floating point
  1576. values that determine the behavior of the loaded plugin (for example delay,
  1577. threshold or gain).
  1578. Controls need to be defined using the following syntax:
  1579. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1580. @var{valuei} is the value set on the @var{i}-th control.
  1581. Alternatively they can be also defined using the following syntax:
  1582. @var{value0}|@var{value1}|@var{value2}|..., where
  1583. @var{valuei} is the value set on the @var{i}-th control.
  1584. If @option{controls} is set to @code{help}, all available controls and
  1585. their valid ranges are printed.
  1586. @item sample_rate, s
  1587. Specify the sample rate, default to 44100. Only used if plugin have
  1588. zero inputs.
  1589. @item nb_samples, n
  1590. Set the number of samples per channel per each output frame, default
  1591. is 1024. Only used if plugin have zero inputs.
  1592. @item duration, d
  1593. Set the minimum duration of the sourced audio. See
  1594. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1595. for the accepted syntax.
  1596. Note that the resulting duration may be greater than the specified duration,
  1597. as the generated audio is always cut at the end of a complete frame.
  1598. If not specified, or the expressed duration is negative, the audio is
  1599. supposed to be generated forever.
  1600. Only used if plugin have zero inputs.
  1601. @end table
  1602. @subsection Examples
  1603. @itemize
  1604. @item
  1605. List all available plugins within amp (LADSPA example plugin) library:
  1606. @example
  1607. ladspa=file=amp
  1608. @end example
  1609. @item
  1610. List all available controls and their valid ranges for @code{vcf_notch}
  1611. plugin from @code{VCF} library:
  1612. @example
  1613. ladspa=f=vcf:p=vcf_notch:c=help
  1614. @end example
  1615. @item
  1616. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1617. plugin library:
  1618. @example
  1619. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1620. @end example
  1621. @item
  1622. Add reverberation to the audio using TAP-plugins
  1623. (Tom's Audio Processing plugins):
  1624. @example
  1625. ladspa=file=tap_reverb:tap_reverb
  1626. @end example
  1627. @item
  1628. Generate white noise, with 0.2 amplitude:
  1629. @example
  1630. ladspa=file=cmt:noise_source_white:c=c0=.2
  1631. @end example
  1632. @item
  1633. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1634. @code{C* Audio Plugin Suite} (CAPS) library:
  1635. @example
  1636. ladspa=file=caps:Click:c=c1=20'
  1637. @end example
  1638. @item
  1639. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1640. @example
  1641. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1642. @end example
  1643. @item
  1644. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  1645. @code{SWH Plugins} collection:
  1646. @example
  1647. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  1648. @end example
  1649. @item
  1650. Attenuate low frequencies using Multiband EQ from Steve Harris
  1651. @code{SWH Plugins} collection:
  1652. @example
  1653. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  1654. @end example
  1655. @end itemize
  1656. @subsection Commands
  1657. This filter supports the following commands:
  1658. @table @option
  1659. @item cN
  1660. Modify the @var{N}-th control value.
  1661. If the specified value is not valid, it is ignored and prior one is kept.
  1662. @end table
  1663. @section lowpass
  1664. Apply a low-pass filter with 3dB point frequency.
  1665. The filter can be either single-pole or double-pole (the default).
  1666. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1667. The filter accepts the following options:
  1668. @table @option
  1669. @item frequency, f
  1670. Set frequency in Hz. Default is 500.
  1671. @item poles, p
  1672. Set number of poles. Default is 2.
  1673. @item width_type
  1674. Set method to specify band-width of filter.
  1675. @table @option
  1676. @item h
  1677. Hz
  1678. @item q
  1679. Q-Factor
  1680. @item o
  1681. octave
  1682. @item s
  1683. slope
  1684. @end table
  1685. @item width, w
  1686. Specify the band-width of a filter in width_type units.
  1687. Applies only to double-pole filter.
  1688. The default is 0.707q and gives a Butterworth response.
  1689. @end table
  1690. @anchor{pan}
  1691. @section pan
  1692. Mix channels with specific gain levels. The filter accepts the output
  1693. channel layout followed by a set of channels definitions.
  1694. This filter is also designed to efficiently remap the channels of an audio
  1695. stream.
  1696. The filter accepts parameters of the form:
  1697. "@var{l}|@var{outdef}|@var{outdef}|..."
  1698. @table @option
  1699. @item l
  1700. output channel layout or number of channels
  1701. @item outdef
  1702. output channel specification, of the form:
  1703. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1704. @item out_name
  1705. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1706. number (c0, c1, etc.)
  1707. @item gain
  1708. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1709. @item in_name
  1710. input channel to use, see out_name for details; it is not possible to mix
  1711. named and numbered input channels
  1712. @end table
  1713. If the `=' in a channel specification is replaced by `<', then the gains for
  1714. that specification will be renormalized so that the total is 1, thus
  1715. avoiding clipping noise.
  1716. @subsection Mixing examples
  1717. For example, if you want to down-mix from stereo to mono, but with a bigger
  1718. factor for the left channel:
  1719. @example
  1720. pan=1c|c0=0.9*c0+0.1*c1
  1721. @end example
  1722. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1723. 7-channels surround:
  1724. @example
  1725. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1726. @end example
  1727. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1728. that should be preferred (see "-ac" option) unless you have very specific
  1729. needs.
  1730. @subsection Remapping examples
  1731. The channel remapping will be effective if, and only if:
  1732. @itemize
  1733. @item gain coefficients are zeroes or ones,
  1734. @item only one input per channel output,
  1735. @end itemize
  1736. If all these conditions are satisfied, the filter will notify the user ("Pure
  1737. channel mapping detected"), and use an optimized and lossless method to do the
  1738. remapping.
  1739. For example, if you have a 5.1 source and want a stereo audio stream by
  1740. dropping the extra channels:
  1741. @example
  1742. pan="stereo| c0=FL | c1=FR"
  1743. @end example
  1744. Given the same source, you can also switch front left and front right channels
  1745. and keep the input channel layout:
  1746. @example
  1747. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1748. @end example
  1749. If the input is a stereo audio stream, you can mute the front left channel (and
  1750. still keep the stereo channel layout) with:
  1751. @example
  1752. pan="stereo|c1=c1"
  1753. @end example
  1754. Still with a stereo audio stream input, you can copy the right channel in both
  1755. front left and right:
  1756. @example
  1757. pan="stereo| c0=FR | c1=FR"
  1758. @end example
  1759. @section replaygain
  1760. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1761. outputs it unchanged.
  1762. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1763. @section resample
  1764. Convert the audio sample format, sample rate and channel layout. It is
  1765. not meant to be used directly.
  1766. @section rubberband
  1767. Apply time-stretching and pitch-shifting with librubberband.
  1768. The filter accepts the following options:
  1769. @table @option
  1770. @item tempo
  1771. Set tempo scale factor.
  1772. @item pitch
  1773. Set pitch scale factor.
  1774. @item transients
  1775. Set transients detector.
  1776. Possible values are:
  1777. @table @var
  1778. @item crisp
  1779. @item mixed
  1780. @item smooth
  1781. @end table
  1782. @item detector
  1783. Set detector.
  1784. Possible values are:
  1785. @table @var
  1786. @item compound
  1787. @item percussive
  1788. @item soft
  1789. @end table
  1790. @item phase
  1791. Set phase.
  1792. Possible values are:
  1793. @table @var
  1794. @item laminar
  1795. @item independent
  1796. @end table
  1797. @item window
  1798. Set processing window size.
  1799. Possible values are:
  1800. @table @var
  1801. @item standard
  1802. @item short
  1803. @item long
  1804. @end table
  1805. @item smoothing
  1806. Set smoothing.
  1807. Possible values are:
  1808. @table @var
  1809. @item off
  1810. @item on
  1811. @end table
  1812. @item formant
  1813. Enable formant preservation when shift pitching.
  1814. Possible values are:
  1815. @table @var
  1816. @item shifted
  1817. @item preserved
  1818. @end table
  1819. @item pitchq
  1820. Set pitch quality.
  1821. Possible values are:
  1822. @table @var
  1823. @item quality
  1824. @item speed
  1825. @item consistency
  1826. @end table
  1827. @item channels
  1828. Set channels.
  1829. Possible values are:
  1830. @table @var
  1831. @item apart
  1832. @item together
  1833. @end table
  1834. @end table
  1835. @section sidechaincompress
  1836. This filter acts like normal compressor but has the ability to compress
  1837. detected signal using second input signal.
  1838. It needs two input streams and returns one output stream.
  1839. First input stream will be processed depending on second stream signal.
  1840. The filtered signal then can be filtered with other filters in later stages of
  1841. processing. See @ref{pan} and @ref{amerge} filter.
  1842. The filter accepts the following options:
  1843. @table @option
  1844. @item threshold
  1845. If a signal of second stream raises above this level it will affect the gain
  1846. reduction of first stream.
  1847. By default is 0.125. Range is between 0.00097563 and 1.
  1848. @item ratio
  1849. Set a ratio about which the signal is reduced. 1:2 means that if the level
  1850. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  1851. Default is 2. Range is between 1 and 20.
  1852. @item attack
  1853. Amount of milliseconds the signal has to rise above the threshold before gain
  1854. reduction starts. Default is 20. Range is between 0.01 and 2000.
  1855. @item release
  1856. Amount of milliseconds the signal has to fall below the threshold before
  1857. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  1858. @item makeup
  1859. Set the amount by how much signal will be amplified after processing.
  1860. Default is 2. Range is from 1 and 64.
  1861. @item knee
  1862. Curve the sharp knee around the threshold to enter gain reduction more softly.
  1863. Default is 2.82843. Range is between 1 and 8.
  1864. @item link
  1865. Choose if the @code{average} level between all channels of side-chain stream
  1866. or the louder(@code{maximum}) channel of side-chain stream affects the
  1867. reduction. Default is @code{average}.
  1868. @item detection
  1869. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  1870. of @code{rms}. Default is @code{rms} which is mainly smoother.
  1871. @end table
  1872. @subsection Examples
  1873. @itemize
  1874. @item
  1875. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  1876. depending on the signal of 2nd input and later compressed signal to be
  1877. merged with 2nd input:
  1878. @example
  1879. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  1880. @end example
  1881. @end itemize
  1882. @section silencedetect
  1883. Detect silence in an audio stream.
  1884. This filter logs a message when it detects that the input audio volume is less
  1885. or equal to a noise tolerance value for a duration greater or equal to the
  1886. minimum detected noise duration.
  1887. The printed times and duration are expressed in seconds.
  1888. The filter accepts the following options:
  1889. @table @option
  1890. @item duration, d
  1891. Set silence duration until notification (default is 2 seconds).
  1892. @item noise, n
  1893. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1894. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1895. @end table
  1896. @subsection Examples
  1897. @itemize
  1898. @item
  1899. Detect 5 seconds of silence with -50dB noise tolerance:
  1900. @example
  1901. silencedetect=n=-50dB:d=5
  1902. @end example
  1903. @item
  1904. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1905. tolerance in @file{silence.mp3}:
  1906. @example
  1907. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1908. @end example
  1909. @end itemize
  1910. @section silenceremove
  1911. Remove silence from the beginning, middle or end of the audio.
  1912. The filter accepts the following options:
  1913. @table @option
  1914. @item start_periods
  1915. This value is used to indicate if audio should be trimmed at beginning of
  1916. the audio. A value of zero indicates no silence should be trimmed from the
  1917. beginning. When specifying a non-zero value, it trims audio up until it
  1918. finds non-silence. Normally, when trimming silence from beginning of audio
  1919. the @var{start_periods} will be @code{1} but it can be increased to higher
  1920. values to trim all audio up to specific count of non-silence periods.
  1921. Default value is @code{0}.
  1922. @item start_duration
  1923. Specify the amount of time that non-silence must be detected before it stops
  1924. trimming audio. By increasing the duration, bursts of noises can be treated
  1925. as silence and trimmed off. Default value is @code{0}.
  1926. @item start_threshold
  1927. This indicates what sample value should be treated as silence. For digital
  1928. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1929. you may wish to increase the value to account for background noise.
  1930. Can be specified in dB (in case "dB" is appended to the specified value)
  1931. or amplitude ratio. Default value is @code{0}.
  1932. @item stop_periods
  1933. Set the count for trimming silence from the end of audio.
  1934. To remove silence from the middle of a file, specify a @var{stop_periods}
  1935. that is negative. This value is then treated as a positive value and is
  1936. used to indicate the effect should restart processing as specified by
  1937. @var{start_periods}, making it suitable for removing periods of silence
  1938. in the middle of the audio.
  1939. Default value is @code{0}.
  1940. @item stop_duration
  1941. Specify a duration of silence that must exist before audio is not copied any
  1942. more. By specifying a higher duration, silence that is wanted can be left in
  1943. the audio.
  1944. Default value is @code{0}.
  1945. @item stop_threshold
  1946. This is the same as @option{start_threshold} but for trimming silence from
  1947. the end of audio.
  1948. Can be specified in dB (in case "dB" is appended to the specified value)
  1949. or amplitude ratio. Default value is @code{0}.
  1950. @item leave_silence
  1951. This indicate that @var{stop_duration} length of audio should be left intact
  1952. at the beginning of each period of silence.
  1953. For example, if you want to remove long pauses between words but do not want
  1954. to remove the pauses completely. Default value is @code{0}.
  1955. @end table
  1956. @subsection Examples
  1957. @itemize
  1958. @item
  1959. The following example shows how this filter can be used to start a recording
  1960. that does not contain the delay at the start which usually occurs between
  1961. pressing the record button and the start of the performance:
  1962. @example
  1963. silenceremove=1:5:0.02
  1964. @end example
  1965. @end itemize
  1966. @section stereotools
  1967. This filter has some handy utilities to manage stereo signals, for converting
  1968. M/S stereo recordings to L/R signal while having control over the parameters
  1969. or spreading the stereo image of master track.
  1970. The filter accepts the following options:
  1971. @table @option
  1972. @item level_in
  1973. Set input level before filtering for both channels. Defaults is 1.
  1974. Allowed range is from 0.015625 to 64.
  1975. @item level_out
  1976. Set output level after filtering for both channels. Defaults is 1.
  1977. Allowed range is from 0.015625 to 64.
  1978. @item balance_in
  1979. Set input balance between both channels. Default is 0.
  1980. Allowed range is from -1 to 1.
  1981. @item balance_out
  1982. Set output balance between both channels. Default is 0.
  1983. Allowed range is from -1 to 1.
  1984. @item softclip
  1985. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  1986. clipping. Disabled by default.
  1987. @item mutel
  1988. Mute the left channel. Disabled by default.
  1989. @item muter
  1990. Mute the right channel. Disabled by default.
  1991. @item phasel
  1992. Change the phase of the left channel. Disabled by default.
  1993. @item phaser
  1994. Change the phase of the right channel. Disabled by default.
  1995. @item mode
  1996. Set stereo mode. Available values are:
  1997. @table @samp
  1998. @item lr>lr
  1999. Left/Right to Left/Right, this is default.
  2000. @item lr>ms
  2001. Left/Right to Mid/Side.
  2002. @item ms>lr
  2003. Mid/Side to Left/Right.
  2004. @item lr>ll
  2005. Left/Right to Left/Left.
  2006. @item lr>rr
  2007. Left/Right to Right/Right.
  2008. @item lr>l+r
  2009. Left/Right to Left + Right.
  2010. @item lr>rl
  2011. Left/Right to Right/Left.
  2012. @end table
  2013. @item slev
  2014. Set level of side signal. Default is 1.
  2015. Allowed range is from 0.015625 to 64.
  2016. @item sbal
  2017. Set balance of side signal. Default is 0.
  2018. Allowed range is from -1 to 1.
  2019. @item mlev
  2020. Set level of the middle signal. Default is 1.
  2021. Allowed range is from 0.015625 to 64.
  2022. @item mpan
  2023. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2024. @item base
  2025. Set stereo base between mono and inversed channels. Default is 0.
  2026. Allowed range is from -1 to 1.
  2027. @item delay
  2028. Set delay in milliseconds how much to delay left from right channel and
  2029. vice versa. Default is 0. Allowed range is from -20 to 20.
  2030. @item sclevel
  2031. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2032. @item phase
  2033. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2034. @end table
  2035. @section stereowiden
  2036. This filter enhance the stereo effect by suppressing signal common to both
  2037. channels and by delaying the signal of left into right and vice versa,
  2038. thereby widening the stereo effect.
  2039. The filter accepts the following options:
  2040. @table @option
  2041. @item delay
  2042. Time in milliseconds of the delay of left signal into right and vice versa.
  2043. Default is 20 milliseconds.
  2044. @item feedback
  2045. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2046. effect of left signal in right output and vice versa which gives widening
  2047. effect. Default is 0.3.
  2048. @item crossfeed
  2049. Cross feed of left into right with inverted phase. This helps in suppressing
  2050. the mono. If the value is 1 it will cancel all the signal common to both
  2051. channels. Default is 0.3.
  2052. @item drymix
  2053. Set level of input signal of original channel. Default is 0.8.
  2054. @end table
  2055. @section treble
  2056. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2057. shelving filter with a response similar to that of a standard
  2058. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2059. The filter accepts the following options:
  2060. @table @option
  2061. @item gain, g
  2062. Give the gain at whichever is the lower of ~22 kHz and the
  2063. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2064. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2065. @item frequency, f
  2066. Set the filter's central frequency and so can be used
  2067. to extend or reduce the frequency range to be boosted or cut.
  2068. The default value is @code{3000} Hz.
  2069. @item width_type
  2070. Set method to specify band-width of filter.
  2071. @table @option
  2072. @item h
  2073. Hz
  2074. @item q
  2075. Q-Factor
  2076. @item o
  2077. octave
  2078. @item s
  2079. slope
  2080. @end table
  2081. @item width, w
  2082. Determine how steep is the filter's shelf transition.
  2083. @end table
  2084. @section tremolo
  2085. Sinusoidal amplitude modulation.
  2086. The filter accepts the following options:
  2087. @table @option
  2088. @item f
  2089. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2090. (20 Hz or lower) will result in a tremolo effect.
  2091. This filter may also be used as a ring modulator by specifying
  2092. a modulation frequency higher than 20 Hz.
  2093. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2094. @item d
  2095. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2096. Default value is 0.5.
  2097. @end table
  2098. @section vibrato
  2099. Sinusoidal phase modulation.
  2100. The filter accepts the following options:
  2101. @table @option
  2102. @item f
  2103. Modulation frequency in Hertz.
  2104. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2105. @item d
  2106. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2107. Default value is 0.5.
  2108. @end table
  2109. @section volume
  2110. Adjust the input audio volume.
  2111. It accepts the following parameters:
  2112. @table @option
  2113. @item volume
  2114. Set audio volume expression.
  2115. Output values are clipped to the maximum value.
  2116. The output audio volume is given by the relation:
  2117. @example
  2118. @var{output_volume} = @var{volume} * @var{input_volume}
  2119. @end example
  2120. The default value for @var{volume} is "1.0".
  2121. @item precision
  2122. This parameter represents the mathematical precision.
  2123. It determines which input sample formats will be allowed, which affects the
  2124. precision of the volume scaling.
  2125. @table @option
  2126. @item fixed
  2127. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2128. @item float
  2129. 32-bit floating-point; this limits input sample format to FLT. (default)
  2130. @item double
  2131. 64-bit floating-point; this limits input sample format to DBL.
  2132. @end table
  2133. @item replaygain
  2134. Choose the behaviour on encountering ReplayGain side data in input frames.
  2135. @table @option
  2136. @item drop
  2137. Remove ReplayGain side data, ignoring its contents (the default).
  2138. @item ignore
  2139. Ignore ReplayGain side data, but leave it in the frame.
  2140. @item track
  2141. Prefer the track gain, if present.
  2142. @item album
  2143. Prefer the album gain, if present.
  2144. @end table
  2145. @item replaygain_preamp
  2146. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2147. Default value for @var{replaygain_preamp} is 0.0.
  2148. @item eval
  2149. Set when the volume expression is evaluated.
  2150. It accepts the following values:
  2151. @table @samp
  2152. @item once
  2153. only evaluate expression once during the filter initialization, or
  2154. when the @samp{volume} command is sent
  2155. @item frame
  2156. evaluate expression for each incoming frame
  2157. @end table
  2158. Default value is @samp{once}.
  2159. @end table
  2160. The volume expression can contain the following parameters.
  2161. @table @option
  2162. @item n
  2163. frame number (starting at zero)
  2164. @item nb_channels
  2165. number of channels
  2166. @item nb_consumed_samples
  2167. number of samples consumed by the filter
  2168. @item nb_samples
  2169. number of samples in the current frame
  2170. @item pos
  2171. original frame position in the file
  2172. @item pts
  2173. frame PTS
  2174. @item sample_rate
  2175. sample rate
  2176. @item startpts
  2177. PTS at start of stream
  2178. @item startt
  2179. time at start of stream
  2180. @item t
  2181. frame time
  2182. @item tb
  2183. timestamp timebase
  2184. @item volume
  2185. last set volume value
  2186. @end table
  2187. Note that when @option{eval} is set to @samp{once} only the
  2188. @var{sample_rate} and @var{tb} variables are available, all other
  2189. variables will evaluate to NAN.
  2190. @subsection Commands
  2191. This filter supports the following commands:
  2192. @table @option
  2193. @item volume
  2194. Modify the volume expression.
  2195. The command accepts the same syntax of the corresponding option.
  2196. If the specified expression is not valid, it is kept at its current
  2197. value.
  2198. @item replaygain_noclip
  2199. Prevent clipping by limiting the gain applied.
  2200. Default value for @var{replaygain_noclip} is 1.
  2201. @end table
  2202. @subsection Examples
  2203. @itemize
  2204. @item
  2205. Halve the input audio volume:
  2206. @example
  2207. volume=volume=0.5
  2208. volume=volume=1/2
  2209. volume=volume=-6.0206dB
  2210. @end example
  2211. In all the above example the named key for @option{volume} can be
  2212. omitted, for example like in:
  2213. @example
  2214. volume=0.5
  2215. @end example
  2216. @item
  2217. Increase input audio power by 6 decibels using fixed-point precision:
  2218. @example
  2219. volume=volume=6dB:precision=fixed
  2220. @end example
  2221. @item
  2222. Fade volume after time 10 with an annihilation period of 5 seconds:
  2223. @example
  2224. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2225. @end example
  2226. @end itemize
  2227. @section volumedetect
  2228. Detect the volume of the input video.
  2229. The filter has no parameters. The input is not modified. Statistics about
  2230. the volume will be printed in the log when the input stream end is reached.
  2231. In particular it will show the mean volume (root mean square), maximum
  2232. volume (on a per-sample basis), and the beginning of a histogram of the
  2233. registered volume values (from the maximum value to a cumulated 1/1000 of
  2234. the samples).
  2235. All volumes are in decibels relative to the maximum PCM value.
  2236. @subsection Examples
  2237. Here is an excerpt of the output:
  2238. @example
  2239. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2240. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2241. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2242. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2243. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2244. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2245. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2246. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2247. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2248. @end example
  2249. It means that:
  2250. @itemize
  2251. @item
  2252. The mean square energy is approximately -27 dB, or 10^-2.7.
  2253. @item
  2254. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2255. @item
  2256. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2257. @end itemize
  2258. In other words, raising the volume by +4 dB does not cause any clipping,
  2259. raising it by +5 dB causes clipping for 6 samples, etc.
  2260. @c man end AUDIO FILTERS
  2261. @chapter Audio Sources
  2262. @c man begin AUDIO SOURCES
  2263. Below is a description of the currently available audio sources.
  2264. @section abuffer
  2265. Buffer audio frames, and make them available to the filter chain.
  2266. This source is mainly intended for a programmatic use, in particular
  2267. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2268. It accepts the following parameters:
  2269. @table @option
  2270. @item time_base
  2271. The timebase which will be used for timestamps of submitted frames. It must be
  2272. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2273. @item sample_rate
  2274. The sample rate of the incoming audio buffers.
  2275. @item sample_fmt
  2276. The sample format of the incoming audio buffers.
  2277. Either a sample format name or its corresponding integer representation from
  2278. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2279. @item channel_layout
  2280. The channel layout of the incoming audio buffers.
  2281. Either a channel layout name from channel_layout_map in
  2282. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2283. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2284. @item channels
  2285. The number of channels of the incoming audio buffers.
  2286. If both @var{channels} and @var{channel_layout} are specified, then they
  2287. must be consistent.
  2288. @end table
  2289. @subsection Examples
  2290. @example
  2291. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2292. @end example
  2293. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2294. Since the sample format with name "s16p" corresponds to the number
  2295. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2296. equivalent to:
  2297. @example
  2298. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2299. @end example
  2300. @section aevalsrc
  2301. Generate an audio signal specified by an expression.
  2302. This source accepts in input one or more expressions (one for each
  2303. channel), which are evaluated and used to generate a corresponding
  2304. audio signal.
  2305. This source accepts the following options:
  2306. @table @option
  2307. @item exprs
  2308. Set the '|'-separated expressions list for each separate channel. In case the
  2309. @option{channel_layout} option is not specified, the selected channel layout
  2310. depends on the number of provided expressions. Otherwise the last
  2311. specified expression is applied to the remaining output channels.
  2312. @item channel_layout, c
  2313. Set the channel layout. The number of channels in the specified layout
  2314. must be equal to the number of specified expressions.
  2315. @item duration, d
  2316. Set the minimum duration of the sourced audio. See
  2317. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2318. for the accepted syntax.
  2319. Note that the resulting duration may be greater than the specified
  2320. duration, as the generated audio is always cut at the end of a
  2321. complete frame.
  2322. If not specified, or the expressed duration is negative, the audio is
  2323. supposed to be generated forever.
  2324. @item nb_samples, n
  2325. Set the number of samples per channel per each output frame,
  2326. default to 1024.
  2327. @item sample_rate, s
  2328. Specify the sample rate, default to 44100.
  2329. @end table
  2330. Each expression in @var{exprs} can contain the following constants:
  2331. @table @option
  2332. @item n
  2333. number of the evaluated sample, starting from 0
  2334. @item t
  2335. time of the evaluated sample expressed in seconds, starting from 0
  2336. @item s
  2337. sample rate
  2338. @end table
  2339. @subsection Examples
  2340. @itemize
  2341. @item
  2342. Generate silence:
  2343. @example
  2344. aevalsrc=0
  2345. @end example
  2346. @item
  2347. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2348. 8000 Hz:
  2349. @example
  2350. aevalsrc="sin(440*2*PI*t):s=8000"
  2351. @end example
  2352. @item
  2353. Generate a two channels signal, specify the channel layout (Front
  2354. Center + Back Center) explicitly:
  2355. @example
  2356. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2357. @end example
  2358. @item
  2359. Generate white noise:
  2360. @example
  2361. aevalsrc="-2+random(0)"
  2362. @end example
  2363. @item
  2364. Generate an amplitude modulated signal:
  2365. @example
  2366. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2367. @end example
  2368. @item
  2369. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2370. @example
  2371. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2372. @end example
  2373. @end itemize
  2374. @section anullsrc
  2375. The null audio source, return unprocessed audio frames. It is mainly useful
  2376. as a template and to be employed in analysis / debugging tools, or as
  2377. the source for filters which ignore the input data (for example the sox
  2378. synth filter).
  2379. This source accepts the following options:
  2380. @table @option
  2381. @item channel_layout, cl
  2382. Specifies the channel layout, and can be either an integer or a string
  2383. representing a channel layout. The default value of @var{channel_layout}
  2384. is "stereo".
  2385. Check the channel_layout_map definition in
  2386. @file{libavutil/channel_layout.c} for the mapping between strings and
  2387. channel layout values.
  2388. @item sample_rate, r
  2389. Specifies the sample rate, and defaults to 44100.
  2390. @item nb_samples, n
  2391. Set the number of samples per requested frames.
  2392. @end table
  2393. @subsection Examples
  2394. @itemize
  2395. @item
  2396. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2397. @example
  2398. anullsrc=r=48000:cl=4
  2399. @end example
  2400. @item
  2401. Do the same operation with a more obvious syntax:
  2402. @example
  2403. anullsrc=r=48000:cl=mono
  2404. @end example
  2405. @end itemize
  2406. All the parameters need to be explicitly defined.
  2407. @section flite
  2408. Synthesize a voice utterance using the libflite library.
  2409. To enable compilation of this filter you need to configure FFmpeg with
  2410. @code{--enable-libflite}.
  2411. Note that the flite library is not thread-safe.
  2412. The filter accepts the following options:
  2413. @table @option
  2414. @item list_voices
  2415. If set to 1, list the names of the available voices and exit
  2416. immediately. Default value is 0.
  2417. @item nb_samples, n
  2418. Set the maximum number of samples per frame. Default value is 512.
  2419. @item textfile
  2420. Set the filename containing the text to speak.
  2421. @item text
  2422. Set the text to speak.
  2423. @item voice, v
  2424. Set the voice to use for the speech synthesis. Default value is
  2425. @code{kal}. See also the @var{list_voices} option.
  2426. @end table
  2427. @subsection Examples
  2428. @itemize
  2429. @item
  2430. Read from file @file{speech.txt}, and synthesize the text using the
  2431. standard flite voice:
  2432. @example
  2433. flite=textfile=speech.txt
  2434. @end example
  2435. @item
  2436. Read the specified text selecting the @code{slt} voice:
  2437. @example
  2438. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2439. @end example
  2440. @item
  2441. Input text to ffmpeg:
  2442. @example
  2443. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2444. @end example
  2445. @item
  2446. Make @file{ffplay} speak the specified text, using @code{flite} and
  2447. the @code{lavfi} device:
  2448. @example
  2449. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2450. @end example
  2451. @end itemize
  2452. For more information about libflite, check:
  2453. @url{http://www.speech.cs.cmu.edu/flite/}
  2454. @section sine
  2455. Generate an audio signal made of a sine wave with amplitude 1/8.
  2456. The audio signal is bit-exact.
  2457. The filter accepts the following options:
  2458. @table @option
  2459. @item frequency, f
  2460. Set the carrier frequency. Default is 440 Hz.
  2461. @item beep_factor, b
  2462. Enable a periodic beep every second with frequency @var{beep_factor} times
  2463. the carrier frequency. Default is 0, meaning the beep is disabled.
  2464. @item sample_rate, r
  2465. Specify the sample rate, default is 44100.
  2466. @item duration, d
  2467. Specify the duration of the generated audio stream.
  2468. @item samples_per_frame
  2469. Set the number of samples per output frame.
  2470. The expression can contain the following constants:
  2471. @table @option
  2472. @item n
  2473. The (sequential) number of the output audio frame, starting from 0.
  2474. @item pts
  2475. The PTS (Presentation TimeStamp) of the output audio frame,
  2476. expressed in @var{TB} units.
  2477. @item t
  2478. The PTS of the output audio frame, expressed in seconds.
  2479. @item TB
  2480. The timebase of the output audio frames.
  2481. @end table
  2482. Default is @code{1024}.
  2483. @end table
  2484. @subsection Examples
  2485. @itemize
  2486. @item
  2487. Generate a simple 440 Hz sine wave:
  2488. @example
  2489. sine
  2490. @end example
  2491. @item
  2492. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2493. @example
  2494. sine=220:4:d=5
  2495. sine=f=220:b=4:d=5
  2496. sine=frequency=220:beep_factor=4:duration=5
  2497. @end example
  2498. @item
  2499. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2500. pattern:
  2501. @example
  2502. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2503. @end example
  2504. @end itemize
  2505. @c man end AUDIO SOURCES
  2506. @chapter Audio Sinks
  2507. @c man begin AUDIO SINKS
  2508. Below is a description of the currently available audio sinks.
  2509. @section abuffersink
  2510. Buffer audio frames, and make them available to the end of filter chain.
  2511. This sink is mainly intended for programmatic use, in particular
  2512. through the interface defined in @file{libavfilter/buffersink.h}
  2513. or the options system.
  2514. It accepts a pointer to an AVABufferSinkContext structure, which
  2515. defines the incoming buffers' formats, to be passed as the opaque
  2516. parameter to @code{avfilter_init_filter} for initialization.
  2517. @section anullsink
  2518. Null audio sink; do absolutely nothing with the input audio. It is
  2519. mainly useful as a template and for use in analysis / debugging
  2520. tools.
  2521. @c man end AUDIO SINKS
  2522. @chapter Video Filters
  2523. @c man begin VIDEO FILTERS
  2524. When you configure your FFmpeg build, you can disable any of the
  2525. existing filters using @code{--disable-filters}.
  2526. The configure output will show the video filters included in your
  2527. build.
  2528. Below is a description of the currently available video filters.
  2529. @section alphaextract
  2530. Extract the alpha component from the input as a grayscale video. This
  2531. is especially useful with the @var{alphamerge} filter.
  2532. @section alphamerge
  2533. Add or replace the alpha component of the primary input with the
  2534. grayscale value of a second input. This is intended for use with
  2535. @var{alphaextract} to allow the transmission or storage of frame
  2536. sequences that have alpha in a format that doesn't support an alpha
  2537. channel.
  2538. For example, to reconstruct full frames from a normal YUV-encoded video
  2539. and a separate video created with @var{alphaextract}, you might use:
  2540. @example
  2541. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2542. @end example
  2543. Since this filter is designed for reconstruction, it operates on frame
  2544. sequences without considering timestamps, and terminates when either
  2545. input reaches end of stream. This will cause problems if your encoding
  2546. pipeline drops frames. If you're trying to apply an image as an
  2547. overlay to a video stream, consider the @var{overlay} filter instead.
  2548. @section ass
  2549. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2550. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2551. Substation Alpha) subtitles files.
  2552. This filter accepts the following option in addition to the common options from
  2553. the @ref{subtitles} filter:
  2554. @table @option
  2555. @item shaping
  2556. Set the shaping engine
  2557. Available values are:
  2558. @table @samp
  2559. @item auto
  2560. The default libass shaping engine, which is the best available.
  2561. @item simple
  2562. Fast, font-agnostic shaper that can do only substitutions
  2563. @item complex
  2564. Slower shaper using OpenType for substitutions and positioning
  2565. @end table
  2566. The default is @code{auto}.
  2567. @end table
  2568. @section atadenoise
  2569. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2570. The filter accepts the following options:
  2571. @table @option
  2572. @item 0a
  2573. Set threshold A for 1st plane. Default is 0.02.
  2574. Valid range is 0 to 0.3.
  2575. @item 0b
  2576. Set threshold B for 1st plane. Default is 0.04.
  2577. Valid range is 0 to 5.
  2578. @item 1a
  2579. Set threshold A for 2nd plane. Default is 0.02.
  2580. Valid range is 0 to 0.3.
  2581. @item 1b
  2582. Set threshold B for 2nd plane. Default is 0.04.
  2583. Valid range is 0 to 5.
  2584. @item 2a
  2585. Set threshold A for 3rd plane. Default is 0.02.
  2586. Valid range is 0 to 0.3.
  2587. @item 2b
  2588. Set threshold B for 3rd plane. Default is 0.04.
  2589. Valid range is 0 to 5.
  2590. Threshold A is designed to react on abrupt changes in the input signal and
  2591. threshold B is designed to react on continuous changes in the input signal.
  2592. @item s
  2593. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2594. number in range [5, 129].
  2595. @end table
  2596. @section bbox
  2597. Compute the bounding box for the non-black pixels in the input frame
  2598. luminance plane.
  2599. This filter computes the bounding box containing all the pixels with a
  2600. luminance value greater than the minimum allowed value.
  2601. The parameters describing the bounding box are printed on the filter
  2602. log.
  2603. The filter accepts the following option:
  2604. @table @option
  2605. @item min_val
  2606. Set the minimal luminance value. Default is @code{16}.
  2607. @end table
  2608. @section blackdetect
  2609. Detect video intervals that are (almost) completely black. Can be
  2610. useful to detect chapter transitions, commercials, or invalid
  2611. recordings. Output lines contains the time for the start, end and
  2612. duration of the detected black interval expressed in seconds.
  2613. In order to display the output lines, you need to set the loglevel at
  2614. least to the AV_LOG_INFO value.
  2615. The filter accepts the following options:
  2616. @table @option
  2617. @item black_min_duration, d
  2618. Set the minimum detected black duration expressed in seconds. It must
  2619. be a non-negative floating point number.
  2620. Default value is 2.0.
  2621. @item picture_black_ratio_th, pic_th
  2622. Set the threshold for considering a picture "black".
  2623. Express the minimum value for the ratio:
  2624. @example
  2625. @var{nb_black_pixels} / @var{nb_pixels}
  2626. @end example
  2627. for which a picture is considered black.
  2628. Default value is 0.98.
  2629. @item pixel_black_th, pix_th
  2630. Set the threshold for considering a pixel "black".
  2631. The threshold expresses the maximum pixel luminance value for which a
  2632. pixel is considered "black". The provided value is scaled according to
  2633. the following equation:
  2634. @example
  2635. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2636. @end example
  2637. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2638. the input video format, the range is [0-255] for YUV full-range
  2639. formats and [16-235] for YUV non full-range formats.
  2640. Default value is 0.10.
  2641. @end table
  2642. The following example sets the maximum pixel threshold to the minimum
  2643. value, and detects only black intervals of 2 or more seconds:
  2644. @example
  2645. blackdetect=d=2:pix_th=0.00
  2646. @end example
  2647. @section blackframe
  2648. Detect frames that are (almost) completely black. Can be useful to
  2649. detect chapter transitions or commercials. Output lines consist of
  2650. the frame number of the detected frame, the percentage of blackness,
  2651. the position in the file if known or -1 and the timestamp in seconds.
  2652. In order to display the output lines, you need to set the loglevel at
  2653. least to the AV_LOG_INFO value.
  2654. It accepts the following parameters:
  2655. @table @option
  2656. @item amount
  2657. The percentage of the pixels that have to be below the threshold; it defaults to
  2658. @code{98}.
  2659. @item threshold, thresh
  2660. The threshold below which a pixel value is considered black; it defaults to
  2661. @code{32}.
  2662. @end table
  2663. @section blend, tblend
  2664. Blend two video frames into each other.
  2665. The @code{blend} filter takes two input streams and outputs one
  2666. stream, the first input is the "top" layer and second input is
  2667. "bottom" layer. Output terminates when shortest input terminates.
  2668. The @code{tblend} (time blend) filter takes two consecutive frames
  2669. from one single stream, and outputs the result obtained by blending
  2670. the new frame on top of the old frame.
  2671. A description of the accepted options follows.
  2672. @table @option
  2673. @item c0_mode
  2674. @item c1_mode
  2675. @item c2_mode
  2676. @item c3_mode
  2677. @item all_mode
  2678. Set blend mode for specific pixel component or all pixel components in case
  2679. of @var{all_mode}. Default value is @code{normal}.
  2680. Available values for component modes are:
  2681. @table @samp
  2682. @item addition
  2683. @item addition128
  2684. @item and
  2685. @item average
  2686. @item burn
  2687. @item darken
  2688. @item difference
  2689. @item difference128
  2690. @item divide
  2691. @item dodge
  2692. @item exclusion
  2693. @item glow
  2694. @item hardlight
  2695. @item hardmix
  2696. @item lighten
  2697. @item linearlight
  2698. @item multiply
  2699. @item negation
  2700. @item normal
  2701. @item or
  2702. @item overlay
  2703. @item phoenix
  2704. @item pinlight
  2705. @item reflect
  2706. @item screen
  2707. @item softlight
  2708. @item subtract
  2709. @item vividlight
  2710. @item xor
  2711. @end table
  2712. @item c0_opacity
  2713. @item c1_opacity
  2714. @item c2_opacity
  2715. @item c3_opacity
  2716. @item all_opacity
  2717. Set blend opacity for specific pixel component or all pixel components in case
  2718. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2719. @item c0_expr
  2720. @item c1_expr
  2721. @item c2_expr
  2722. @item c3_expr
  2723. @item all_expr
  2724. Set blend expression for specific pixel component or all pixel components in case
  2725. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2726. The expressions can use the following variables:
  2727. @table @option
  2728. @item N
  2729. The sequential number of the filtered frame, starting from @code{0}.
  2730. @item X
  2731. @item Y
  2732. the coordinates of the current sample
  2733. @item W
  2734. @item H
  2735. the width and height of currently filtered plane
  2736. @item SW
  2737. @item SH
  2738. Width and height scale depending on the currently filtered plane. It is the
  2739. ratio between the corresponding luma plane number of pixels and the current
  2740. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2741. @code{0.5,0.5} for chroma planes.
  2742. @item T
  2743. Time of the current frame, expressed in seconds.
  2744. @item TOP, A
  2745. Value of pixel component at current location for first video frame (top layer).
  2746. @item BOTTOM, B
  2747. Value of pixel component at current location for second video frame (bottom layer).
  2748. @end table
  2749. @item shortest
  2750. Force termination when the shortest input terminates. Default is
  2751. @code{0}. This option is only defined for the @code{blend} filter.
  2752. @item repeatlast
  2753. Continue applying the last bottom frame after the end of the stream. A value of
  2754. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2755. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2756. @end table
  2757. @subsection Examples
  2758. @itemize
  2759. @item
  2760. Apply transition from bottom layer to top layer in first 10 seconds:
  2761. @example
  2762. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2763. @end example
  2764. @item
  2765. Apply 1x1 checkerboard effect:
  2766. @example
  2767. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2768. @end example
  2769. @item
  2770. Apply uncover left effect:
  2771. @example
  2772. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2773. @end example
  2774. @item
  2775. Apply uncover down effect:
  2776. @example
  2777. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2778. @end example
  2779. @item
  2780. Apply uncover up-left effect:
  2781. @example
  2782. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2783. @end example
  2784. @item
  2785. Display differences between the current and the previous frame:
  2786. @example
  2787. tblend=all_mode=difference128
  2788. @end example
  2789. @end itemize
  2790. @section boxblur
  2791. Apply a boxblur algorithm to the input video.
  2792. It accepts the following parameters:
  2793. @table @option
  2794. @item luma_radius, lr
  2795. @item luma_power, lp
  2796. @item chroma_radius, cr
  2797. @item chroma_power, cp
  2798. @item alpha_radius, ar
  2799. @item alpha_power, ap
  2800. @end table
  2801. A description of the accepted options follows.
  2802. @table @option
  2803. @item luma_radius, lr
  2804. @item chroma_radius, cr
  2805. @item alpha_radius, ar
  2806. Set an expression for the box radius in pixels used for blurring the
  2807. corresponding input plane.
  2808. The radius value must be a non-negative number, and must not be
  2809. greater than the value of the expression @code{min(w,h)/2} for the
  2810. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2811. planes.
  2812. Default value for @option{luma_radius} is "2". If not specified,
  2813. @option{chroma_radius} and @option{alpha_radius} default to the
  2814. corresponding value set for @option{luma_radius}.
  2815. The expressions can contain the following constants:
  2816. @table @option
  2817. @item w
  2818. @item h
  2819. The input width and height in pixels.
  2820. @item cw
  2821. @item ch
  2822. The input chroma image width and height in pixels.
  2823. @item hsub
  2824. @item vsub
  2825. The horizontal and vertical chroma subsample values. For example, for the
  2826. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2827. @end table
  2828. @item luma_power, lp
  2829. @item chroma_power, cp
  2830. @item alpha_power, ap
  2831. Specify how many times the boxblur filter is applied to the
  2832. corresponding plane.
  2833. Default value for @option{luma_power} is 2. If not specified,
  2834. @option{chroma_power} and @option{alpha_power} default to the
  2835. corresponding value set for @option{luma_power}.
  2836. A value of 0 will disable the effect.
  2837. @end table
  2838. @subsection Examples
  2839. @itemize
  2840. @item
  2841. Apply a boxblur filter with the luma, chroma, and alpha radii
  2842. set to 2:
  2843. @example
  2844. boxblur=luma_radius=2:luma_power=1
  2845. boxblur=2:1
  2846. @end example
  2847. @item
  2848. Set the luma radius to 2, and alpha and chroma radius to 0:
  2849. @example
  2850. boxblur=2:1:cr=0:ar=0
  2851. @end example
  2852. @item
  2853. Set the luma and chroma radii to a fraction of the video dimension:
  2854. @example
  2855. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2856. @end example
  2857. @end itemize
  2858. @section chromakey
  2859. YUV colorspace color/chroma keying.
  2860. The filter accepts the following options:
  2861. @table @option
  2862. @item color
  2863. The color which will be replaced with transparency.
  2864. @item similarity
  2865. Similarity percentage with the key color.
  2866. 0.01 matches only the exact key color, while 1.0 matches everything.
  2867. @item blend
  2868. Blend percentage.
  2869. 0.0 makes pixels either fully transparent, or not transparent at all.
  2870. Higher values result in semi-transparent pixels, with a higher transparency
  2871. the more similar the pixels color is to the key color.
  2872. @item yuv
  2873. Signals that the color passed is already in YUV instead of RGB.
  2874. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  2875. This can be used to pass exact YUV values as hexadecimal numbers.
  2876. @end table
  2877. @subsection Examples
  2878. @itemize
  2879. @item
  2880. Make every green pixel in the input image transparent:
  2881. @example
  2882. ffmpeg -i input.png -vf chromakey=green out.png
  2883. @end example
  2884. @item
  2885. Overlay a greenscreen-video on top of a static black background.
  2886. @example
  2887. ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_complex "[1:v]chromakey=0x70de77:0.1:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mkv
  2888. @end example
  2889. @end itemize
  2890. @section codecview
  2891. Visualize information exported by some codecs.
  2892. Some codecs can export information through frames using side-data or other
  2893. means. For example, some MPEG based codecs export motion vectors through the
  2894. @var{export_mvs} flag in the codec @option{flags2} option.
  2895. The filter accepts the following option:
  2896. @table @option
  2897. @item mv
  2898. Set motion vectors to visualize.
  2899. Available flags for @var{mv} are:
  2900. @table @samp
  2901. @item pf
  2902. forward predicted MVs of P-frames
  2903. @item bf
  2904. forward predicted MVs of B-frames
  2905. @item bb
  2906. backward predicted MVs of B-frames
  2907. @end table
  2908. @end table
  2909. @subsection Examples
  2910. @itemize
  2911. @item
  2912. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2913. @example
  2914. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2915. @end example
  2916. @end itemize
  2917. @section colorbalance
  2918. Modify intensity of primary colors (red, green and blue) of input frames.
  2919. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2920. regions for the red-cyan, green-magenta or blue-yellow balance.
  2921. A positive adjustment value shifts the balance towards the primary color, a negative
  2922. value towards the complementary color.
  2923. The filter accepts the following options:
  2924. @table @option
  2925. @item rs
  2926. @item gs
  2927. @item bs
  2928. Adjust red, green and blue shadows (darkest pixels).
  2929. @item rm
  2930. @item gm
  2931. @item bm
  2932. Adjust red, green and blue midtones (medium pixels).
  2933. @item rh
  2934. @item gh
  2935. @item bh
  2936. Adjust red, green and blue highlights (brightest pixels).
  2937. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2938. @end table
  2939. @subsection Examples
  2940. @itemize
  2941. @item
  2942. Add red color cast to shadows:
  2943. @example
  2944. colorbalance=rs=.3
  2945. @end example
  2946. @end itemize
  2947. @section colorkey
  2948. RGB colorspace color keying.
  2949. The filter accepts the following options:
  2950. @table @option
  2951. @item color
  2952. The color which will be replaced with transparency.
  2953. @item similarity
  2954. Similarity percentage with the key color.
  2955. 0.01 matches only the exact key color, while 1.0 matches everything.
  2956. @item blend
  2957. Blend percentage.
  2958. 0.0 makes pixels either fully transparent, or not transparent at all.
  2959. Higher values result in semi-transparent pixels, with a higher transparency
  2960. the more similar the pixels color is to the key color.
  2961. @end table
  2962. @subsection Examples
  2963. @itemize
  2964. @item
  2965. Make every green pixel in the input image transparent:
  2966. @example
  2967. ffmpeg -i input.png -vf colorkey=green out.png
  2968. @end example
  2969. @item
  2970. Overlay a greenscreen-video on top of a static background image.
  2971. @example
  2972. 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
  2973. @end example
  2974. @end itemize
  2975. @section colorlevels
  2976. Adjust video input frames using levels.
  2977. The filter accepts the following options:
  2978. @table @option
  2979. @item rimin
  2980. @item gimin
  2981. @item bimin
  2982. @item aimin
  2983. Adjust red, green, blue and alpha input black point.
  2984. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2985. @item rimax
  2986. @item gimax
  2987. @item bimax
  2988. @item aimax
  2989. Adjust red, green, blue and alpha input white point.
  2990. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2991. Input levels are used to lighten highlights (bright tones), darken shadows
  2992. (dark tones), change the balance of bright and dark tones.
  2993. @item romin
  2994. @item gomin
  2995. @item bomin
  2996. @item aomin
  2997. Adjust red, green, blue and alpha output black point.
  2998. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2999. @item romax
  3000. @item gomax
  3001. @item bomax
  3002. @item aomax
  3003. Adjust red, green, blue and alpha output white point.
  3004. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3005. Output levels allows manual selection of a constrained output level range.
  3006. @end table
  3007. @subsection Examples
  3008. @itemize
  3009. @item
  3010. Make video output darker:
  3011. @example
  3012. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3013. @end example
  3014. @item
  3015. Increase contrast:
  3016. @example
  3017. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3018. @end example
  3019. @item
  3020. Make video output lighter:
  3021. @example
  3022. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3023. @end example
  3024. @item
  3025. Increase brightness:
  3026. @example
  3027. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3028. @end example
  3029. @end itemize
  3030. @section colorchannelmixer
  3031. Adjust video input frames by re-mixing color channels.
  3032. This filter modifies a color channel by adding the values associated to
  3033. the other channels of the same pixels. For example if the value to
  3034. modify is red, the output value will be:
  3035. @example
  3036. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3037. @end example
  3038. The filter accepts the following options:
  3039. @table @option
  3040. @item rr
  3041. @item rg
  3042. @item rb
  3043. @item ra
  3044. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3045. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3046. @item gr
  3047. @item gg
  3048. @item gb
  3049. @item ga
  3050. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3051. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3052. @item br
  3053. @item bg
  3054. @item bb
  3055. @item ba
  3056. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3057. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3058. @item ar
  3059. @item ag
  3060. @item ab
  3061. @item aa
  3062. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3063. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3064. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3065. @end table
  3066. @subsection Examples
  3067. @itemize
  3068. @item
  3069. Convert source to grayscale:
  3070. @example
  3071. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3072. @end example
  3073. @item
  3074. Simulate sepia tones:
  3075. @example
  3076. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3077. @end example
  3078. @end itemize
  3079. @section colormatrix
  3080. Convert color matrix.
  3081. The filter accepts the following options:
  3082. @table @option
  3083. @item src
  3084. @item dst
  3085. Specify the source and destination color matrix. Both values must be
  3086. specified.
  3087. The accepted values are:
  3088. @table @samp
  3089. @item bt709
  3090. BT.709
  3091. @item bt601
  3092. BT.601
  3093. @item smpte240m
  3094. SMPTE-240M
  3095. @item fcc
  3096. FCC
  3097. @end table
  3098. @end table
  3099. For example to convert from BT.601 to SMPTE-240M, use the command:
  3100. @example
  3101. colormatrix=bt601:smpte240m
  3102. @end example
  3103. @section copy
  3104. Copy the input source unchanged to the output. This is mainly useful for
  3105. testing purposes.
  3106. @section crop
  3107. Crop the input video to given dimensions.
  3108. It accepts the following parameters:
  3109. @table @option
  3110. @item w, out_w
  3111. The width of the output video. It defaults to @code{iw}.
  3112. This expression is evaluated only once during the filter
  3113. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3114. @item h, out_h
  3115. The height of the output video. It defaults to @code{ih}.
  3116. This expression is evaluated only once during the filter
  3117. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3118. @item x
  3119. The horizontal position, in the input video, of the left edge of the output
  3120. video. It defaults to @code{(in_w-out_w)/2}.
  3121. This expression is evaluated per-frame.
  3122. @item y
  3123. The vertical position, in the input video, of the top edge of the output video.
  3124. It defaults to @code{(in_h-out_h)/2}.
  3125. This expression is evaluated per-frame.
  3126. @item keep_aspect
  3127. If set to 1 will force the output display aspect ratio
  3128. to be the same of the input, by changing the output sample aspect
  3129. ratio. It defaults to 0.
  3130. @end table
  3131. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3132. expressions containing the following constants:
  3133. @table @option
  3134. @item x
  3135. @item y
  3136. The computed values for @var{x} and @var{y}. They are evaluated for
  3137. each new frame.
  3138. @item in_w
  3139. @item in_h
  3140. The input width and height.
  3141. @item iw
  3142. @item ih
  3143. These are the same as @var{in_w} and @var{in_h}.
  3144. @item out_w
  3145. @item out_h
  3146. The output (cropped) width and height.
  3147. @item ow
  3148. @item oh
  3149. These are the same as @var{out_w} and @var{out_h}.
  3150. @item a
  3151. same as @var{iw} / @var{ih}
  3152. @item sar
  3153. input sample aspect ratio
  3154. @item dar
  3155. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3156. @item hsub
  3157. @item vsub
  3158. horizontal and vertical chroma subsample values. For example for the
  3159. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3160. @item n
  3161. The number of the input frame, starting from 0.
  3162. @item pos
  3163. the position in the file of the input frame, NAN if unknown
  3164. @item t
  3165. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3166. @end table
  3167. The expression for @var{out_w} may depend on the value of @var{out_h},
  3168. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3169. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3170. evaluated after @var{out_w} and @var{out_h}.
  3171. The @var{x} and @var{y} parameters specify the expressions for the
  3172. position of the top-left corner of the output (non-cropped) area. They
  3173. are evaluated for each frame. If the evaluated value is not valid, it
  3174. is approximated to the nearest valid value.
  3175. The expression for @var{x} may depend on @var{y}, and the expression
  3176. for @var{y} may depend on @var{x}.
  3177. @subsection Examples
  3178. @itemize
  3179. @item
  3180. Crop area with size 100x100 at position (12,34).
  3181. @example
  3182. crop=100:100:12:34
  3183. @end example
  3184. Using named options, the example above becomes:
  3185. @example
  3186. crop=w=100:h=100:x=12:y=34
  3187. @end example
  3188. @item
  3189. Crop the central input area with size 100x100:
  3190. @example
  3191. crop=100:100
  3192. @end example
  3193. @item
  3194. Crop the central input area with size 2/3 of the input video:
  3195. @example
  3196. crop=2/3*in_w:2/3*in_h
  3197. @end example
  3198. @item
  3199. Crop the input video central square:
  3200. @example
  3201. crop=out_w=in_h
  3202. crop=in_h
  3203. @end example
  3204. @item
  3205. Delimit the rectangle with the top-left corner placed at position
  3206. 100:100 and the right-bottom corner corresponding to the right-bottom
  3207. corner of the input image.
  3208. @example
  3209. crop=in_w-100:in_h-100:100:100
  3210. @end example
  3211. @item
  3212. Crop 10 pixels from the left and right borders, and 20 pixels from
  3213. the top and bottom borders
  3214. @example
  3215. crop=in_w-2*10:in_h-2*20
  3216. @end example
  3217. @item
  3218. Keep only the bottom right quarter of the input image:
  3219. @example
  3220. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3221. @end example
  3222. @item
  3223. Crop height for getting Greek harmony:
  3224. @example
  3225. crop=in_w:1/PHI*in_w
  3226. @end example
  3227. @item
  3228. Apply trembling effect:
  3229. @example
  3230. 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)
  3231. @end example
  3232. @item
  3233. Apply erratic camera effect depending on timestamp:
  3234. @example
  3235. 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)"
  3236. @end example
  3237. @item
  3238. Set x depending on the value of y:
  3239. @example
  3240. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3241. @end example
  3242. @end itemize
  3243. @subsection Commands
  3244. This filter supports the following commands:
  3245. @table @option
  3246. @item w, out_w
  3247. @item h, out_h
  3248. @item x
  3249. @item y
  3250. Set width/height of the output video and the horizontal/vertical position
  3251. in the input video.
  3252. The command accepts the same syntax of the corresponding option.
  3253. If the specified expression is not valid, it is kept at its current
  3254. value.
  3255. @end table
  3256. @section cropdetect
  3257. Auto-detect the crop size.
  3258. It calculates the necessary cropping parameters and prints the
  3259. recommended parameters via the logging system. The detected dimensions
  3260. correspond to the non-black area of the input video.
  3261. It accepts the following parameters:
  3262. @table @option
  3263. @item limit
  3264. Set higher black value threshold, which can be optionally specified
  3265. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3266. value greater to the set value is considered non-black. It defaults to 24.
  3267. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3268. on the bitdepth of the pixel format.
  3269. @item round
  3270. The value which the width/height should be divisible by. It defaults to
  3271. 16. The offset is automatically adjusted to center the video. Use 2 to
  3272. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3273. encoding to most video codecs.
  3274. @item reset_count, reset
  3275. Set the counter that determines after how many frames cropdetect will
  3276. reset the previously detected largest video area and start over to
  3277. detect the current optimal crop area. Default value is 0.
  3278. This can be useful when channel logos distort the video area. 0
  3279. indicates 'never reset', and returns the largest area encountered during
  3280. playback.
  3281. @end table
  3282. @anchor{curves}
  3283. @section curves
  3284. Apply color adjustments using curves.
  3285. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3286. component (red, green and blue) has its values defined by @var{N} key points
  3287. tied from each other using a smooth curve. The x-axis represents the pixel
  3288. values from the input frame, and the y-axis the new pixel values to be set for
  3289. the output frame.
  3290. By default, a component curve is defined by the two points @var{(0;0)} and
  3291. @var{(1;1)}. This creates a straight line where each original pixel value is
  3292. "adjusted" to its own value, which means no change to the image.
  3293. The filter allows you to redefine these two points and add some more. A new
  3294. curve (using a natural cubic spline interpolation) will be define to pass
  3295. smoothly through all these new coordinates. The new defined points needs to be
  3296. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3297. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3298. the vector spaces, the values will be clipped accordingly.
  3299. If there is no key point defined in @code{x=0}, the filter will automatically
  3300. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3301. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3302. The filter accepts the following options:
  3303. @table @option
  3304. @item preset
  3305. Select one of the available color presets. This option can be used in addition
  3306. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3307. options takes priority on the preset values.
  3308. Available presets are:
  3309. @table @samp
  3310. @item none
  3311. @item color_negative
  3312. @item cross_process
  3313. @item darker
  3314. @item increase_contrast
  3315. @item lighter
  3316. @item linear_contrast
  3317. @item medium_contrast
  3318. @item negative
  3319. @item strong_contrast
  3320. @item vintage
  3321. @end table
  3322. Default is @code{none}.
  3323. @item master, m
  3324. Set the master key points. These points will define a second pass mapping. It
  3325. is sometimes called a "luminance" or "value" mapping. It can be used with
  3326. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3327. post-processing LUT.
  3328. @item red, r
  3329. Set the key points for the red component.
  3330. @item green, g
  3331. Set the key points for the green component.
  3332. @item blue, b
  3333. Set the key points for the blue component.
  3334. @item all
  3335. Set the key points for all components (not including master).
  3336. Can be used in addition to the other key points component
  3337. options. In this case, the unset component(s) will fallback on this
  3338. @option{all} setting.
  3339. @item psfile
  3340. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3341. @end table
  3342. To avoid some filtergraph syntax conflicts, each key points list need to be
  3343. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3344. @subsection Examples
  3345. @itemize
  3346. @item
  3347. Increase slightly the middle level of blue:
  3348. @example
  3349. curves=blue='0.5/0.58'
  3350. @end example
  3351. @item
  3352. Vintage effect:
  3353. @example
  3354. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3355. @end example
  3356. Here we obtain the following coordinates for each components:
  3357. @table @var
  3358. @item red
  3359. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3360. @item green
  3361. @code{(0;0) (0.50;0.48) (1;1)}
  3362. @item blue
  3363. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3364. @end table
  3365. @item
  3366. The previous example can also be achieved with the associated built-in preset:
  3367. @example
  3368. curves=preset=vintage
  3369. @end example
  3370. @item
  3371. Or simply:
  3372. @example
  3373. curves=vintage
  3374. @end example
  3375. @item
  3376. Use a Photoshop preset and redefine the points of the green component:
  3377. @example
  3378. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3379. @end example
  3380. @end itemize
  3381. @section dctdnoiz
  3382. Denoise frames using 2D DCT (frequency domain filtering).
  3383. This filter is not designed for real time.
  3384. The filter accepts the following options:
  3385. @table @option
  3386. @item sigma, s
  3387. Set the noise sigma constant.
  3388. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3389. coefficient (absolute value) below this threshold with be dropped.
  3390. If you need a more advanced filtering, see @option{expr}.
  3391. Default is @code{0}.
  3392. @item overlap
  3393. Set number overlapping pixels for each block. Since the filter can be slow, you
  3394. may want to reduce this value, at the cost of a less effective filter and the
  3395. risk of various artefacts.
  3396. If the overlapping value doesn't permit processing the whole input width or
  3397. height, a warning will be displayed and according borders won't be denoised.
  3398. Default value is @var{blocksize}-1, which is the best possible setting.
  3399. @item expr, e
  3400. Set the coefficient factor expression.
  3401. For each coefficient of a DCT block, this expression will be evaluated as a
  3402. multiplier value for the coefficient.
  3403. If this is option is set, the @option{sigma} option will be ignored.
  3404. The absolute value of the coefficient can be accessed through the @var{c}
  3405. variable.
  3406. @item n
  3407. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3408. @var{blocksize}, which is the width and height of the processed blocks.
  3409. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3410. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3411. on the speed processing. Also, a larger block size does not necessarily means a
  3412. better de-noising.
  3413. @end table
  3414. @subsection Examples
  3415. Apply a denoise with a @option{sigma} of @code{4.5}:
  3416. @example
  3417. dctdnoiz=4.5
  3418. @end example
  3419. The same operation can be achieved using the expression system:
  3420. @example
  3421. dctdnoiz=e='gte(c, 4.5*3)'
  3422. @end example
  3423. Violent denoise using a block size of @code{16x16}:
  3424. @example
  3425. dctdnoiz=15:n=4
  3426. @end example
  3427. @section deband
  3428. Remove banding artifacts from input video.
  3429. It works by replacing banded pixels with average value of referenced pixels.
  3430. The filter accepts the following options:
  3431. @table @option
  3432. @item 1thr
  3433. @item 2thr
  3434. @item 3thr
  3435. @item 4thr
  3436. Set banding detection threshold for each plane. Default is 0.02.
  3437. Valid range is 0.00003 to 0.5.
  3438. If difference between current pixel and reference pixel is less than threshold,
  3439. it will be considered as banded.
  3440. @item range, r
  3441. Banding detection range in pixels. Default is 16. If positive, random number
  3442. in range 0 to set value will be used. If negative, exact absolute value
  3443. will be used.
  3444. The range defines square of four pixels around current pixel.
  3445. @item direction, d
  3446. Set direction in radians from which four pixel will be compared. If positive,
  3447. random direction from 0 to set direction will be picked. If negative, exact of
  3448. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3449. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3450. column.
  3451. @item blur
  3452. If enabled, current pixel is compared with average value of all four
  3453. surrounding pixels. The default is enabled. If disabled current pixel is
  3454. compared with all four surrounding pixels. The pixel is considered banded
  3455. if only all four differences with surrounding pixels are less than threshold.
  3456. @end table
  3457. @anchor{decimate}
  3458. @section decimate
  3459. Drop duplicated frames at regular intervals.
  3460. The filter accepts the following options:
  3461. @table @option
  3462. @item cycle
  3463. Set the number of frames from which one will be dropped. Setting this to
  3464. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3465. Default is @code{5}.
  3466. @item dupthresh
  3467. Set the threshold for duplicate detection. If the difference metric for a frame
  3468. is less than or equal to this value, then it is declared as duplicate. Default
  3469. is @code{1.1}
  3470. @item scthresh
  3471. Set scene change threshold. Default is @code{15}.
  3472. @item blockx
  3473. @item blocky
  3474. Set the size of the x and y-axis blocks used during metric calculations.
  3475. Larger blocks give better noise suppression, but also give worse detection of
  3476. small movements. Must be a power of two. Default is @code{32}.
  3477. @item ppsrc
  3478. Mark main input as a pre-processed input and activate clean source input
  3479. stream. This allows the input to be pre-processed with various filters to help
  3480. the metrics calculation while keeping the frame selection lossless. When set to
  3481. @code{1}, the first stream is for the pre-processed input, and the second
  3482. stream is the clean source from where the kept frames are chosen. Default is
  3483. @code{0}.
  3484. @item chroma
  3485. Set whether or not chroma is considered in the metric calculations. Default is
  3486. @code{1}.
  3487. @end table
  3488. @section deflate
  3489. Apply deflate effect to the video.
  3490. This filter replaces the pixel by the local(3x3) average by taking into account
  3491. only values lower than the pixel.
  3492. It accepts the following options:
  3493. @table @option
  3494. @item threshold0
  3495. @item threshold1
  3496. @item threshold2
  3497. @item threshold3
  3498. Limit the maximum change for each plane, default is 65535.
  3499. If 0, plane will remain unchanged.
  3500. @end table
  3501. @section dejudder
  3502. Remove judder produced by partially interlaced telecined content.
  3503. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3504. source was partially telecined content then the output of @code{pullup,dejudder}
  3505. will have a variable frame rate. May change the recorded frame rate of the
  3506. container. Aside from that change, this filter will not affect constant frame
  3507. rate video.
  3508. The option available in this filter is:
  3509. @table @option
  3510. @item cycle
  3511. Specify the length of the window over which the judder repeats.
  3512. Accepts any integer greater than 1. Useful values are:
  3513. @table @samp
  3514. @item 4
  3515. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3516. @item 5
  3517. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3518. @item 20
  3519. If a mixture of the two.
  3520. @end table
  3521. The default is @samp{4}.
  3522. @end table
  3523. @section delogo
  3524. Suppress a TV station logo by a simple interpolation of the surrounding
  3525. pixels. Just set a rectangle covering the logo and watch it disappear
  3526. (and sometimes something even uglier appear - your mileage may vary).
  3527. It accepts the following parameters:
  3528. @table @option
  3529. @item x
  3530. @item y
  3531. Specify the top left corner coordinates of the logo. They must be
  3532. specified.
  3533. @item w
  3534. @item h
  3535. Specify the width and height of the logo to clear. They must be
  3536. specified.
  3537. @item band, t
  3538. Specify the thickness of the fuzzy edge of the rectangle (added to
  3539. @var{w} and @var{h}). The default value is 1. This option is
  3540. deprecated, setting higher values should no longer be necessary and
  3541. is not recommended.
  3542. @item show
  3543. When set to 1, a green rectangle is drawn on the screen to simplify
  3544. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3545. The default value is 0.
  3546. The rectangle is drawn on the outermost pixels which will be (partly)
  3547. replaced with interpolated values. The values of the next pixels
  3548. immediately outside this rectangle in each direction will be used to
  3549. compute the interpolated pixel values inside the rectangle.
  3550. @end table
  3551. @subsection Examples
  3552. @itemize
  3553. @item
  3554. Set a rectangle covering the area with top left corner coordinates 0,0
  3555. and size 100x77, and a band of size 10:
  3556. @example
  3557. delogo=x=0:y=0:w=100:h=77:band=10
  3558. @end example
  3559. @end itemize
  3560. @section deshake
  3561. Attempt to fix small changes in horizontal and/or vertical shift. This
  3562. filter helps remove camera shake from hand-holding a camera, bumping a
  3563. tripod, moving on a vehicle, etc.
  3564. The filter accepts the following options:
  3565. @table @option
  3566. @item x
  3567. @item y
  3568. @item w
  3569. @item h
  3570. Specify a rectangular area where to limit the search for motion
  3571. vectors.
  3572. If desired the search for motion vectors can be limited to a
  3573. rectangular area of the frame defined by its top left corner, width
  3574. and height. These parameters have the same meaning as the drawbox
  3575. filter which can be used to visualise the position of the bounding
  3576. box.
  3577. This is useful when simultaneous movement of subjects within the frame
  3578. might be confused for camera motion by the motion vector search.
  3579. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3580. then the full frame is used. This allows later options to be set
  3581. without specifying the bounding box for the motion vector search.
  3582. Default - search the whole frame.
  3583. @item rx
  3584. @item ry
  3585. Specify the maximum extent of movement in x and y directions in the
  3586. range 0-64 pixels. Default 16.
  3587. @item edge
  3588. Specify how to generate pixels to fill blanks at the edge of the
  3589. frame. Available values are:
  3590. @table @samp
  3591. @item blank, 0
  3592. Fill zeroes at blank locations
  3593. @item original, 1
  3594. Original image at blank locations
  3595. @item clamp, 2
  3596. Extruded edge value at blank locations
  3597. @item mirror, 3
  3598. Mirrored edge at blank locations
  3599. @end table
  3600. Default value is @samp{mirror}.
  3601. @item blocksize
  3602. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3603. default 8.
  3604. @item contrast
  3605. Specify the contrast threshold for blocks. Only blocks with more than
  3606. the specified contrast (difference between darkest and lightest
  3607. pixels) will be considered. Range 1-255, default 125.
  3608. @item search
  3609. Specify the search strategy. Available values are:
  3610. @table @samp
  3611. @item exhaustive, 0
  3612. Set exhaustive search
  3613. @item less, 1
  3614. Set less exhaustive search.
  3615. @end table
  3616. Default value is @samp{exhaustive}.
  3617. @item filename
  3618. If set then a detailed log of the motion search is written to the
  3619. specified file.
  3620. @item opencl
  3621. If set to 1, specify using OpenCL capabilities, only available if
  3622. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3623. @end table
  3624. @section detelecine
  3625. Apply an exact inverse of the telecine operation. It requires a predefined
  3626. pattern specified using the pattern option which must be the same as that passed
  3627. to the telecine filter.
  3628. This filter accepts the following options:
  3629. @table @option
  3630. @item first_field
  3631. @table @samp
  3632. @item top, t
  3633. top field first
  3634. @item bottom, b
  3635. bottom field first
  3636. The default value is @code{top}.
  3637. @end table
  3638. @item pattern
  3639. A string of numbers representing the pulldown pattern you wish to apply.
  3640. The default value is @code{23}.
  3641. @item start_frame
  3642. A number representing position of the first frame with respect to the telecine
  3643. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3644. @end table
  3645. @section dilation
  3646. Apply dilation effect to the video.
  3647. This filter replaces the pixel by the local(3x3) maximum.
  3648. It accepts the following options:
  3649. @table @option
  3650. @item threshold0
  3651. @item threshold1
  3652. @item threshold2
  3653. @item threshold3
  3654. Limit the maximum change for each plane, default is 65535.
  3655. If 0, plane will remain unchanged.
  3656. @item coordinates
  3657. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  3658. pixels are used.
  3659. Flags to local 3x3 coordinates maps like this:
  3660. 1 2 3
  3661. 4 5
  3662. 6 7 8
  3663. @end table
  3664. @section displace
  3665. Displace pixels as indicated by second and third input stream.
  3666. It takes three input streams and outputs one stream, the first input is the
  3667. source, and second and third input are displacement maps.
  3668. The second input specifies how much to displace pixels along the
  3669. x-axis, while the third input specifies how much to displace pixels
  3670. along the y-axis.
  3671. If one of displacement map streams terminates, last frame from that
  3672. displacement map will be used.
  3673. Note that once generated, displacements maps can be reused over and over again.
  3674. A description of the accepted options follows.
  3675. @table @option
  3676. @item edge
  3677. Set displace behavior for pixels that are out of range.
  3678. Available values are:
  3679. @table @samp
  3680. @item blank
  3681. Missing pixels are replaced by black pixels.
  3682. @item smear
  3683. Adjacent pixels will spread out to replace missing pixels.
  3684. @item wrap
  3685. Out of range pixels are wrapped so they point to pixels of other side.
  3686. @end table
  3687. Default is @samp{smear}.
  3688. @end table
  3689. @subsection Examples
  3690. @itemize
  3691. @item
  3692. Add ripple effect to rgb input of video size hd720:
  3693. @example
  3694. ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -f lavfi -i nullsrc=s=hd720,geq='r=128+30*sin(2*PI*X/400+T):g=128+30*sin(2*PI*X/400+T):b=128+30*sin(2*PI*X/400+T)' -lavfi '[0][1][2]displace' OUTPUT
  3695. @end example
  3696. @item
  3697. Add wave effect to rgb input of video size hd720:
  3698. @example
  3699. ffmpeg -i INPUT -f lavfi -i nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):g=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):b=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T))' -lavfi '[1]split[x][y],[0][x][y]displace' OUTPUT
  3700. @end example
  3701. @end itemize
  3702. @section drawbox
  3703. Draw a colored box on the input image.
  3704. It accepts the following parameters:
  3705. @table @option
  3706. @item x
  3707. @item y
  3708. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3709. @item width, w
  3710. @item height, h
  3711. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3712. the input width and height. It defaults to 0.
  3713. @item color, c
  3714. Specify the color of the box to write. For the general syntax of this option,
  3715. check the "Color" section in the ffmpeg-utils manual. If the special
  3716. value @code{invert} is used, the box edge color is the same as the
  3717. video with inverted luma.
  3718. @item thickness, t
  3719. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3720. See below for the list of accepted constants.
  3721. @end table
  3722. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3723. following constants:
  3724. @table @option
  3725. @item dar
  3726. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3727. @item hsub
  3728. @item vsub
  3729. horizontal and vertical chroma subsample values. For example for the
  3730. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3731. @item in_h, ih
  3732. @item in_w, iw
  3733. The input width and height.
  3734. @item sar
  3735. The input sample aspect ratio.
  3736. @item x
  3737. @item y
  3738. The x and y offset coordinates where the box is drawn.
  3739. @item w
  3740. @item h
  3741. The width and height of the drawn box.
  3742. @item t
  3743. The thickness of the drawn box.
  3744. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3745. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3746. @end table
  3747. @subsection Examples
  3748. @itemize
  3749. @item
  3750. Draw a black box around the edge of the input image:
  3751. @example
  3752. drawbox
  3753. @end example
  3754. @item
  3755. Draw a box with color red and an opacity of 50%:
  3756. @example
  3757. drawbox=10:20:200:60:red@@0.5
  3758. @end example
  3759. The previous example can be specified as:
  3760. @example
  3761. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3762. @end example
  3763. @item
  3764. Fill the box with pink color:
  3765. @example
  3766. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3767. @end example
  3768. @item
  3769. Draw a 2-pixel red 2.40:1 mask:
  3770. @example
  3771. 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
  3772. @end example
  3773. @end itemize
  3774. @section drawgraph, adrawgraph
  3775. Draw a graph using input video or audio metadata.
  3776. It accepts the following parameters:
  3777. @table @option
  3778. @item m1
  3779. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3780. @item fg1
  3781. Set 1st foreground color expression.
  3782. @item m2
  3783. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3784. @item fg2
  3785. Set 2nd foreground color expression.
  3786. @item m3
  3787. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3788. @item fg3
  3789. Set 3rd foreground color expression.
  3790. @item m4
  3791. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3792. @item fg4
  3793. Set 4th foreground color expression.
  3794. @item min
  3795. Set minimal value of metadata value.
  3796. @item max
  3797. Set maximal value of metadata value.
  3798. @item bg
  3799. Set graph background color. Default is white.
  3800. @item mode
  3801. Set graph mode.
  3802. Available values for mode is:
  3803. @table @samp
  3804. @item bar
  3805. @item dot
  3806. @item line
  3807. @end table
  3808. Default is @code{line}.
  3809. @item slide
  3810. Set slide mode.
  3811. Available values for slide is:
  3812. @table @samp
  3813. @item frame
  3814. Draw new frame when right border is reached.
  3815. @item replace
  3816. Replace old columns with new ones.
  3817. @item scroll
  3818. Scroll from right to left.
  3819. @item rscroll
  3820. Scroll from left to right.
  3821. @end table
  3822. Default is @code{frame}.
  3823. @item size
  3824. Set size of graph video. For the syntax of this option, check the
  3825. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3826. The default value is @code{900x256}.
  3827. The foreground color expressions can use the following variables:
  3828. @table @option
  3829. @item MIN
  3830. Minimal value of metadata value.
  3831. @item MAX
  3832. Maximal value of metadata value.
  3833. @item VAL
  3834. Current metadata key value.
  3835. @end table
  3836. The color is defined as 0xAABBGGRR.
  3837. @end table
  3838. Example using metadata from @ref{signalstats} filter:
  3839. @example
  3840. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3841. @end example
  3842. Example using metadata from @ref{ebur128} filter:
  3843. @example
  3844. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3845. @end example
  3846. @section drawgrid
  3847. Draw a grid on the input image.
  3848. It accepts the following parameters:
  3849. @table @option
  3850. @item x
  3851. @item y
  3852. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3853. @item width, w
  3854. @item height, h
  3855. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3856. input width and height, respectively, minus @code{thickness}, so image gets
  3857. framed. Default to 0.
  3858. @item color, c
  3859. Specify the color of the grid. For the general syntax of this option,
  3860. check the "Color" section in the ffmpeg-utils manual. If the special
  3861. value @code{invert} is used, the grid color is the same as the
  3862. video with inverted luma.
  3863. @item thickness, t
  3864. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3865. See below for the list of accepted constants.
  3866. @end table
  3867. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3868. following constants:
  3869. @table @option
  3870. @item dar
  3871. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3872. @item hsub
  3873. @item vsub
  3874. horizontal and vertical chroma subsample values. For example for the
  3875. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3876. @item in_h, ih
  3877. @item in_w, iw
  3878. The input grid cell width and height.
  3879. @item sar
  3880. The input sample aspect ratio.
  3881. @item x
  3882. @item y
  3883. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3884. @item w
  3885. @item h
  3886. The width and height of the drawn cell.
  3887. @item t
  3888. The thickness of the drawn cell.
  3889. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3890. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3891. @end table
  3892. @subsection Examples
  3893. @itemize
  3894. @item
  3895. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3896. @example
  3897. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3898. @end example
  3899. @item
  3900. Draw a white 3x3 grid with an opacity of 50%:
  3901. @example
  3902. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3903. @end example
  3904. @end itemize
  3905. @anchor{drawtext}
  3906. @section drawtext
  3907. Draw a text string or text from a specified file on top of a video, using the
  3908. libfreetype library.
  3909. To enable compilation of this filter, you need to configure FFmpeg with
  3910. @code{--enable-libfreetype}.
  3911. To enable default font fallback and the @var{font} option you need to
  3912. configure FFmpeg with @code{--enable-libfontconfig}.
  3913. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3914. @code{--enable-libfribidi}.
  3915. @subsection Syntax
  3916. It accepts the following parameters:
  3917. @table @option
  3918. @item box
  3919. Used to draw a box around text using the background color.
  3920. The value must be either 1 (enable) or 0 (disable).
  3921. The default value of @var{box} is 0.
  3922. @item boxborderw
  3923. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3924. The default value of @var{boxborderw} is 0.
  3925. @item boxcolor
  3926. The color to be used for drawing box around text. For the syntax of this
  3927. option, check the "Color" section in the ffmpeg-utils manual.
  3928. The default value of @var{boxcolor} is "white".
  3929. @item borderw
  3930. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3931. The default value of @var{borderw} is 0.
  3932. @item bordercolor
  3933. Set the color to be used for drawing border around text. For the syntax of this
  3934. option, check the "Color" section in the ffmpeg-utils manual.
  3935. The default value of @var{bordercolor} is "black".
  3936. @item expansion
  3937. Select how the @var{text} is expanded. Can be either @code{none},
  3938. @code{strftime} (deprecated) or
  3939. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3940. below for details.
  3941. @item fix_bounds
  3942. If true, check and fix text coords to avoid clipping.
  3943. @item fontcolor
  3944. The color to be used for drawing fonts. For the syntax of this option, check
  3945. the "Color" section in the ffmpeg-utils manual.
  3946. The default value of @var{fontcolor} is "black".
  3947. @item fontcolor_expr
  3948. String which is expanded the same way as @var{text} to obtain dynamic
  3949. @var{fontcolor} value. By default this option has empty value and is not
  3950. processed. When this option is set, it overrides @var{fontcolor} option.
  3951. @item font
  3952. The font family to be used for drawing text. By default Sans.
  3953. @item fontfile
  3954. The font file to be used for drawing text. The path must be included.
  3955. This parameter is mandatory if the fontconfig support is disabled.
  3956. @item draw
  3957. This option does not exist, please see the timeline system
  3958. @item alpha
  3959. Draw the text applying alpha blending. The value can
  3960. be either a number between 0.0 and 1.0
  3961. The expression accepts the same variables @var{x, y} do.
  3962. The default value is 1.
  3963. Please see fontcolor_expr
  3964. @item fontsize
  3965. The font size to be used for drawing text.
  3966. The default value of @var{fontsize} is 16.
  3967. @item text_shaping
  3968. If set to 1, attempt to shape the text (for example, reverse the order of
  3969. right-to-left text and join Arabic characters) before drawing it.
  3970. Otherwise, just draw the text exactly as given.
  3971. By default 1 (if supported).
  3972. @item ft_load_flags
  3973. The flags to be used for loading the fonts.
  3974. The flags map the corresponding flags supported by libfreetype, and are
  3975. a combination of the following values:
  3976. @table @var
  3977. @item default
  3978. @item no_scale
  3979. @item no_hinting
  3980. @item render
  3981. @item no_bitmap
  3982. @item vertical_layout
  3983. @item force_autohint
  3984. @item crop_bitmap
  3985. @item pedantic
  3986. @item ignore_global_advance_width
  3987. @item no_recurse
  3988. @item ignore_transform
  3989. @item monochrome
  3990. @item linear_design
  3991. @item no_autohint
  3992. @end table
  3993. Default value is "default".
  3994. For more information consult the documentation for the FT_LOAD_*
  3995. libfreetype flags.
  3996. @item shadowcolor
  3997. The color to be used for drawing a shadow behind the drawn text. For the
  3998. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3999. The default value of @var{shadowcolor} is "black".
  4000. @item shadowx
  4001. @item shadowy
  4002. The x and y offsets for the text shadow position with respect to the
  4003. position of the text. They can be either positive or negative
  4004. values. The default value for both is "0".
  4005. @item start_number
  4006. The starting frame number for the n/frame_num variable. The default value
  4007. is "0".
  4008. @item tabsize
  4009. The size in number of spaces to use for rendering the tab.
  4010. Default value is 4.
  4011. @item timecode
  4012. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4013. format. It can be used with or without text parameter. @var{timecode_rate}
  4014. option must be specified.
  4015. @item timecode_rate, rate, r
  4016. Set the timecode frame rate (timecode only).
  4017. @item text
  4018. The text string to be drawn. The text must be a sequence of UTF-8
  4019. encoded characters.
  4020. This parameter is mandatory if no file is specified with the parameter
  4021. @var{textfile}.
  4022. @item textfile
  4023. A text file containing text to be drawn. The text must be a sequence
  4024. of UTF-8 encoded characters.
  4025. This parameter is mandatory if no text string is specified with the
  4026. parameter @var{text}.
  4027. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4028. @item reload
  4029. If set to 1, the @var{textfile} will be reloaded before each frame.
  4030. Be sure to update it atomically, or it may be read partially, or even fail.
  4031. @item x
  4032. @item y
  4033. The expressions which specify the offsets where text will be drawn
  4034. within the video frame. They are relative to the top/left border of the
  4035. output image.
  4036. The default value of @var{x} and @var{y} is "0".
  4037. See below for the list of accepted constants and functions.
  4038. @end table
  4039. The parameters for @var{x} and @var{y} are expressions containing the
  4040. following constants and functions:
  4041. @table @option
  4042. @item dar
  4043. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4044. @item hsub
  4045. @item vsub
  4046. horizontal and vertical chroma subsample values. For example for the
  4047. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4048. @item line_h, lh
  4049. the height of each text line
  4050. @item main_h, h, H
  4051. the input height
  4052. @item main_w, w, W
  4053. the input width
  4054. @item max_glyph_a, ascent
  4055. the maximum distance from the baseline to the highest/upper grid
  4056. coordinate used to place a glyph outline point, for all the rendered
  4057. glyphs.
  4058. It is a positive value, due to the grid's orientation with the Y axis
  4059. upwards.
  4060. @item max_glyph_d, descent
  4061. the maximum distance from the baseline to the lowest grid coordinate
  4062. used to place a glyph outline point, for all the rendered glyphs.
  4063. This is a negative value, due to the grid's orientation, with the Y axis
  4064. upwards.
  4065. @item max_glyph_h
  4066. maximum glyph height, that is the maximum height for all the glyphs
  4067. contained in the rendered text, it is equivalent to @var{ascent} -
  4068. @var{descent}.
  4069. @item max_glyph_w
  4070. maximum glyph width, that is the maximum width for all the glyphs
  4071. contained in the rendered text
  4072. @item n
  4073. the number of input frame, starting from 0
  4074. @item rand(min, max)
  4075. return a random number included between @var{min} and @var{max}
  4076. @item sar
  4077. The input sample aspect ratio.
  4078. @item t
  4079. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4080. @item text_h, th
  4081. the height of the rendered text
  4082. @item text_w, tw
  4083. the width of the rendered text
  4084. @item x
  4085. @item y
  4086. the x and y offset coordinates where the text is drawn.
  4087. These parameters allow the @var{x} and @var{y} expressions to refer
  4088. each other, so you can for example specify @code{y=x/dar}.
  4089. @end table
  4090. @anchor{drawtext_expansion}
  4091. @subsection Text expansion
  4092. If @option{expansion} is set to @code{strftime},
  4093. the filter recognizes strftime() sequences in the provided text and
  4094. expands them accordingly. Check the documentation of strftime(). This
  4095. feature is deprecated.
  4096. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4097. If @option{expansion} is set to @code{normal} (which is the default),
  4098. the following expansion mechanism is used.
  4099. The backslash character @samp{\}, followed by any character, always expands to
  4100. the second character.
  4101. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4102. braces is a function name, possibly followed by arguments separated by ':'.
  4103. If the arguments contain special characters or delimiters (':' or '@}'),
  4104. they should be escaped.
  4105. Note that they probably must also be escaped as the value for the
  4106. @option{text} option in the filter argument string and as the filter
  4107. argument in the filtergraph description, and possibly also for the shell,
  4108. that makes up to four levels of escaping; using a text file avoids these
  4109. problems.
  4110. The following functions are available:
  4111. @table @command
  4112. @item expr, e
  4113. The expression evaluation result.
  4114. It must take one argument specifying the expression to be evaluated,
  4115. which accepts the same constants and functions as the @var{x} and
  4116. @var{y} values. Note that not all constants should be used, for
  4117. example the text size is not known when evaluating the expression, so
  4118. the constants @var{text_w} and @var{text_h} will have an undefined
  4119. value.
  4120. @item expr_int_format, eif
  4121. Evaluate the expression's value and output as formatted integer.
  4122. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4123. The second argument specifies the output format. Allowed values are @samp{x},
  4124. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4125. @code{printf} function.
  4126. The third parameter is optional and sets the number of positions taken by the output.
  4127. It can be used to add padding with zeros from the left.
  4128. @item gmtime
  4129. The time at which the filter is running, expressed in UTC.
  4130. It can accept an argument: a strftime() format string.
  4131. @item localtime
  4132. The time at which the filter is running, expressed in the local time zone.
  4133. It can accept an argument: a strftime() format string.
  4134. @item metadata
  4135. Frame metadata. It must take one argument specifying metadata key.
  4136. @item n, frame_num
  4137. The frame number, starting from 0.
  4138. @item pict_type
  4139. A 1 character description of the current picture type.
  4140. @item pts
  4141. The timestamp of the current frame.
  4142. It can take up to three arguments.
  4143. The first argument is the format of the timestamp; it defaults to @code{flt}
  4144. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4145. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4146. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4147. @code{localtime} stands for the timestamp of the frame formatted as
  4148. local time zone time.
  4149. The second argument is an offset added to the timestamp.
  4150. If the format is set to @code{localtime} or @code{gmtime},
  4151. a third argument may be supplied: a strftime() format string.
  4152. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4153. @end table
  4154. @subsection Examples
  4155. @itemize
  4156. @item
  4157. Draw "Test Text" with font FreeSerif, using the default values for the
  4158. optional parameters.
  4159. @example
  4160. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4161. @end example
  4162. @item
  4163. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4164. and y=50 (counting from the top-left corner of the screen), text is
  4165. yellow with a red box around it. Both the text and the box have an
  4166. opacity of 20%.
  4167. @example
  4168. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4169. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4170. @end example
  4171. Note that the double quotes are not necessary if spaces are not used
  4172. within the parameter list.
  4173. @item
  4174. Show the text at the center of the video frame:
  4175. @example
  4176. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  4177. @end example
  4178. @item
  4179. Show a text line sliding from right to left in the last row of the video
  4180. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4181. with no newlines.
  4182. @example
  4183. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4184. @end example
  4185. @item
  4186. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4187. @example
  4188. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4189. @end example
  4190. @item
  4191. Draw a single green letter "g", at the center of the input video.
  4192. The glyph baseline is placed at half screen height.
  4193. @example
  4194. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4195. @end example
  4196. @item
  4197. Show text for 1 second every 3 seconds:
  4198. @example
  4199. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4200. @end example
  4201. @item
  4202. Use fontconfig to set the font. Note that the colons need to be escaped.
  4203. @example
  4204. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4205. @end example
  4206. @item
  4207. Print the date of a real-time encoding (see strftime(3)):
  4208. @example
  4209. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4210. @end example
  4211. @item
  4212. Show text fading in and out (appearing/disappearing):
  4213. @example
  4214. #!/bin/sh
  4215. DS=1.0 # display start
  4216. DE=10.0 # display end
  4217. FID=1.5 # fade in duration
  4218. FOD=5 # fade out duration
  4219. 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 @}"
  4220. @end example
  4221. @end itemize
  4222. For more information about libfreetype, check:
  4223. @url{http://www.freetype.org/}.
  4224. For more information about fontconfig, check:
  4225. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4226. For more information about libfribidi, check:
  4227. @url{http://fribidi.org/}.
  4228. @section edgedetect
  4229. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4230. The filter accepts the following options:
  4231. @table @option
  4232. @item low
  4233. @item high
  4234. Set low and high threshold values used by the Canny thresholding
  4235. algorithm.
  4236. The high threshold selects the "strong" edge pixels, which are then
  4237. connected through 8-connectivity with the "weak" edge pixels selected
  4238. by the low threshold.
  4239. @var{low} and @var{high} threshold values must be chosen in the range
  4240. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4241. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4242. is @code{50/255}.
  4243. @item mode
  4244. Define the drawing mode.
  4245. @table @samp
  4246. @item wires
  4247. Draw white/gray wires on black background.
  4248. @item colormix
  4249. Mix the colors to create a paint/cartoon effect.
  4250. @end table
  4251. Default value is @var{wires}.
  4252. @end table
  4253. @subsection Examples
  4254. @itemize
  4255. @item
  4256. Standard edge detection with custom values for the hysteresis thresholding:
  4257. @example
  4258. edgedetect=low=0.1:high=0.4
  4259. @end example
  4260. @item
  4261. Painting effect without thresholding:
  4262. @example
  4263. edgedetect=mode=colormix:high=0
  4264. @end example
  4265. @end itemize
  4266. @section eq
  4267. Set brightness, contrast, saturation and approximate gamma adjustment.
  4268. The filter accepts the following options:
  4269. @table @option
  4270. @item contrast
  4271. Set the contrast expression. The value must be a float value in range
  4272. @code{-2.0} to @code{2.0}. The default value is "1".
  4273. @item brightness
  4274. Set the brightness expression. The value must be a float value in
  4275. range @code{-1.0} to @code{1.0}. The default value is "0".
  4276. @item saturation
  4277. Set the saturation expression. The value must be a float in
  4278. range @code{0.0} to @code{3.0}. The default value is "1".
  4279. @item gamma
  4280. Set the gamma expression. The value must be a float in range
  4281. @code{0.1} to @code{10.0}. The default value is "1".
  4282. @item gamma_r
  4283. Set the gamma expression for red. The value must be a float in
  4284. range @code{0.1} to @code{10.0}. The default value is "1".
  4285. @item gamma_g
  4286. Set the gamma expression for green. The value must be a float in range
  4287. @code{0.1} to @code{10.0}. The default value is "1".
  4288. @item gamma_b
  4289. Set the gamma expression for blue. The value must be a float in range
  4290. @code{0.1} to @code{10.0}. The default value is "1".
  4291. @item gamma_weight
  4292. Set the gamma weight expression. It can be used to reduce the effect
  4293. of a high gamma value on bright image areas, e.g. keep them from
  4294. getting overamplified and just plain white. The value must be a float
  4295. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4296. gamma correction all the way down while @code{1.0} leaves it at its
  4297. full strength. Default is "1".
  4298. @item eval
  4299. Set when the expressions for brightness, contrast, saturation and
  4300. gamma expressions are evaluated.
  4301. It accepts the following values:
  4302. @table @samp
  4303. @item init
  4304. only evaluate expressions once during the filter initialization or
  4305. when a command is processed
  4306. @item frame
  4307. evaluate expressions for each incoming frame
  4308. @end table
  4309. Default value is @samp{init}.
  4310. @end table
  4311. The expressions accept the following parameters:
  4312. @table @option
  4313. @item n
  4314. frame count of the input frame starting from 0
  4315. @item pos
  4316. byte position of the corresponding packet in the input file, NAN if
  4317. unspecified
  4318. @item r
  4319. frame rate of the input video, NAN if the input frame rate is unknown
  4320. @item t
  4321. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4322. @end table
  4323. @subsection Commands
  4324. The filter supports the following commands:
  4325. @table @option
  4326. @item contrast
  4327. Set the contrast expression.
  4328. @item brightness
  4329. Set the brightness expression.
  4330. @item saturation
  4331. Set the saturation expression.
  4332. @item gamma
  4333. Set the gamma expression.
  4334. @item gamma_r
  4335. Set the gamma_r expression.
  4336. @item gamma_g
  4337. Set gamma_g expression.
  4338. @item gamma_b
  4339. Set gamma_b expression.
  4340. @item gamma_weight
  4341. Set gamma_weight expression.
  4342. The command accepts the same syntax of the corresponding option.
  4343. If the specified expression is not valid, it is kept at its current
  4344. value.
  4345. @end table
  4346. @section erosion
  4347. Apply erosion effect to the video.
  4348. This filter replaces the pixel by the local(3x3) minimum.
  4349. It accepts the following options:
  4350. @table @option
  4351. @item threshold0
  4352. @item threshold1
  4353. @item threshold2
  4354. @item threshold3
  4355. Limit the maximum change for each plane, default is 65535.
  4356. If 0, plane will remain unchanged.
  4357. @item coordinates
  4358. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4359. pixels are used.
  4360. Flags to local 3x3 coordinates maps like this:
  4361. 1 2 3
  4362. 4 5
  4363. 6 7 8
  4364. @end table
  4365. @section extractplanes
  4366. Extract color channel components from input video stream into
  4367. separate grayscale video streams.
  4368. The filter accepts the following option:
  4369. @table @option
  4370. @item planes
  4371. Set plane(s) to extract.
  4372. Available values for planes are:
  4373. @table @samp
  4374. @item y
  4375. @item u
  4376. @item v
  4377. @item a
  4378. @item r
  4379. @item g
  4380. @item b
  4381. @end table
  4382. Choosing planes not available in the input will result in an error.
  4383. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4384. with @code{y}, @code{u}, @code{v} planes at same time.
  4385. @end table
  4386. @subsection Examples
  4387. @itemize
  4388. @item
  4389. Extract luma, u and v color channel component from input video frame
  4390. into 3 grayscale outputs:
  4391. @example
  4392. 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
  4393. @end example
  4394. @end itemize
  4395. @section elbg
  4396. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4397. For each input image, the filter will compute the optimal mapping from
  4398. the input to the output given the codebook length, that is the number
  4399. of distinct output colors.
  4400. This filter accepts the following options.
  4401. @table @option
  4402. @item codebook_length, l
  4403. Set codebook length. The value must be a positive integer, and
  4404. represents the number of distinct output colors. Default value is 256.
  4405. @item nb_steps, n
  4406. Set the maximum number of iterations to apply for computing the optimal
  4407. mapping. The higher the value the better the result and the higher the
  4408. computation time. Default value is 1.
  4409. @item seed, s
  4410. Set a random seed, must be an integer included between 0 and
  4411. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4412. will try to use a good random seed on a best effort basis.
  4413. @item pal8
  4414. Set pal8 output pixel format. This option does not work with codebook
  4415. length greater than 256.
  4416. @end table
  4417. @section fade
  4418. Apply a fade-in/out effect to the input video.
  4419. It accepts the following parameters:
  4420. @table @option
  4421. @item type, t
  4422. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4423. effect.
  4424. Default is @code{in}.
  4425. @item start_frame, s
  4426. Specify the number of the frame to start applying the fade
  4427. effect at. Default is 0.
  4428. @item nb_frames, n
  4429. The number of frames that the fade effect lasts. At the end of the
  4430. fade-in effect, the output video will have the same intensity as the input video.
  4431. At the end of the fade-out transition, the output video will be filled with the
  4432. selected @option{color}.
  4433. Default is 25.
  4434. @item alpha
  4435. If set to 1, fade only alpha channel, if one exists on the input.
  4436. Default value is 0.
  4437. @item start_time, st
  4438. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4439. effect. If both start_frame and start_time are specified, the fade will start at
  4440. whichever comes last. Default is 0.
  4441. @item duration, d
  4442. The number of seconds for which the fade effect has to last. At the end of the
  4443. fade-in effect the output video will have the same intensity as the input video,
  4444. at the end of the fade-out transition the output video will be filled with the
  4445. selected @option{color}.
  4446. If both duration and nb_frames are specified, duration is used. Default is 0
  4447. (nb_frames is used by default).
  4448. @item color, c
  4449. Specify the color of the fade. Default is "black".
  4450. @end table
  4451. @subsection Examples
  4452. @itemize
  4453. @item
  4454. Fade in the first 30 frames of video:
  4455. @example
  4456. fade=in:0:30
  4457. @end example
  4458. The command above is equivalent to:
  4459. @example
  4460. fade=t=in:s=0:n=30
  4461. @end example
  4462. @item
  4463. Fade out the last 45 frames of a 200-frame video:
  4464. @example
  4465. fade=out:155:45
  4466. fade=type=out:start_frame=155:nb_frames=45
  4467. @end example
  4468. @item
  4469. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4470. @example
  4471. fade=in:0:25, fade=out:975:25
  4472. @end example
  4473. @item
  4474. Make the first 5 frames yellow, then fade in from frame 5-24:
  4475. @example
  4476. fade=in:5:20:color=yellow
  4477. @end example
  4478. @item
  4479. Fade in alpha over first 25 frames of video:
  4480. @example
  4481. fade=in:0:25:alpha=1
  4482. @end example
  4483. @item
  4484. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4485. @example
  4486. fade=t=in:st=5.5:d=0.5
  4487. @end example
  4488. @end itemize
  4489. @section fftfilt
  4490. Apply arbitrary expressions to samples in frequency domain
  4491. @table @option
  4492. @item dc_Y
  4493. Adjust the dc value (gain) of the luma plane of the image. The filter
  4494. accepts an integer value in range @code{0} to @code{1000}. The default
  4495. value is set to @code{0}.
  4496. @item dc_U
  4497. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4498. filter accepts an integer value in range @code{0} to @code{1000}. The
  4499. default value is set to @code{0}.
  4500. @item dc_V
  4501. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4502. filter accepts an integer value in range @code{0} to @code{1000}. The
  4503. default value is set to @code{0}.
  4504. @item weight_Y
  4505. Set the frequency domain weight expression for the luma plane.
  4506. @item weight_U
  4507. Set the frequency domain weight expression for the 1st chroma plane.
  4508. @item weight_V
  4509. Set the frequency domain weight expression for the 2nd chroma plane.
  4510. The filter accepts the following variables:
  4511. @item X
  4512. @item Y
  4513. The coordinates of the current sample.
  4514. @item W
  4515. @item H
  4516. The width and height of the image.
  4517. @end table
  4518. @subsection Examples
  4519. @itemize
  4520. @item
  4521. High-pass:
  4522. @example
  4523. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4524. @end example
  4525. @item
  4526. Low-pass:
  4527. @example
  4528. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4529. @end example
  4530. @item
  4531. Sharpen:
  4532. @example
  4533. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4534. @end example
  4535. @end itemize
  4536. @section field
  4537. Extract a single field from an interlaced image using stride
  4538. arithmetic to avoid wasting CPU time. The output frames are marked as
  4539. non-interlaced.
  4540. The filter accepts the following options:
  4541. @table @option
  4542. @item type
  4543. Specify whether to extract the top (if the value is @code{0} or
  4544. @code{top}) or the bottom field (if the value is @code{1} or
  4545. @code{bottom}).
  4546. @end table
  4547. @section fieldmatch
  4548. Field matching filter for inverse telecine. It is meant to reconstruct the
  4549. progressive frames from a telecined stream. The filter does not drop duplicated
  4550. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4551. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4552. The separation of the field matching and the decimation is notably motivated by
  4553. the possibility of inserting a de-interlacing filter fallback between the two.
  4554. If the source has mixed telecined and real interlaced content,
  4555. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4556. But these remaining combed frames will be marked as interlaced, and thus can be
  4557. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4558. In addition to the various configuration options, @code{fieldmatch} can take an
  4559. optional second stream, activated through the @option{ppsrc} option. If
  4560. enabled, the frames reconstruction will be based on the fields and frames from
  4561. this second stream. This allows the first input to be pre-processed in order to
  4562. help the various algorithms of the filter, while keeping the output lossless
  4563. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4564. or brightness/contrast adjustments can help.
  4565. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4566. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4567. which @code{fieldmatch} is based on. While the semantic and usage are very
  4568. close, some behaviour and options names can differ.
  4569. The @ref{decimate} filter currently only works for constant frame rate input.
  4570. If your input has mixed telecined (30fps) and progressive content with a lower
  4571. framerate like 24fps use the following filterchain to produce the necessary cfr
  4572. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4573. The filter accepts the following options:
  4574. @table @option
  4575. @item order
  4576. Specify the assumed field order of the input stream. Available values are:
  4577. @table @samp
  4578. @item auto
  4579. Auto detect parity (use FFmpeg's internal parity value).
  4580. @item bff
  4581. Assume bottom field first.
  4582. @item tff
  4583. Assume top field first.
  4584. @end table
  4585. Note that it is sometimes recommended not to trust the parity announced by the
  4586. stream.
  4587. Default value is @var{auto}.
  4588. @item mode
  4589. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4590. sense that it won't risk creating jerkiness due to duplicate frames when
  4591. possible, but if there are bad edits or blended fields it will end up
  4592. outputting combed frames when a good match might actually exist. On the other
  4593. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4594. but will almost always find a good frame if there is one. The other values are
  4595. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4596. jerkiness and creating duplicate frames versus finding good matches in sections
  4597. with bad edits, orphaned fields, blended fields, etc.
  4598. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4599. Available values are:
  4600. @table @samp
  4601. @item pc
  4602. 2-way matching (p/c)
  4603. @item pc_n
  4604. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4605. @item pc_u
  4606. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4607. @item pc_n_ub
  4608. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4609. still combed (p/c + n + u/b)
  4610. @item pcn
  4611. 3-way matching (p/c/n)
  4612. @item pcn_ub
  4613. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4614. detected as combed (p/c/n + u/b)
  4615. @end table
  4616. The parenthesis at the end indicate the matches that would be used for that
  4617. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4618. @var{top}).
  4619. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4620. the slowest.
  4621. Default value is @var{pc_n}.
  4622. @item ppsrc
  4623. Mark the main input stream as a pre-processed input, and enable the secondary
  4624. input stream as the clean source to pick the fields from. See the filter
  4625. introduction for more details. It is similar to the @option{clip2} feature from
  4626. VFM/TFM.
  4627. Default value is @code{0} (disabled).
  4628. @item field
  4629. Set the field to match from. It is recommended to set this to the same value as
  4630. @option{order} unless you experience matching failures with that setting. In
  4631. certain circumstances changing the field that is used to match from can have a
  4632. large impact on matching performance. Available values are:
  4633. @table @samp
  4634. @item auto
  4635. Automatic (same value as @option{order}).
  4636. @item bottom
  4637. Match from the bottom field.
  4638. @item top
  4639. Match from the top field.
  4640. @end table
  4641. Default value is @var{auto}.
  4642. @item mchroma
  4643. Set whether or not chroma is included during the match comparisons. In most
  4644. cases it is recommended to leave this enabled. You should set this to @code{0}
  4645. only if your clip has bad chroma problems such as heavy rainbowing or other
  4646. artifacts. Setting this to @code{0} could also be used to speed things up at
  4647. the cost of some accuracy.
  4648. Default value is @code{1}.
  4649. @item y0
  4650. @item y1
  4651. These define an exclusion band which excludes the lines between @option{y0} and
  4652. @option{y1} from being included in the field matching decision. An exclusion
  4653. band can be used to ignore subtitles, a logo, or other things that may
  4654. interfere with the matching. @option{y0} sets the starting scan line and
  4655. @option{y1} sets the ending line; all lines in between @option{y0} and
  4656. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  4657. @option{y0} and @option{y1} to the same value will disable the feature.
  4658. @option{y0} and @option{y1} defaults to @code{0}.
  4659. @item scthresh
  4660. Set the scene change detection threshold as a percentage of maximum change on
  4661. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  4662. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  4663. @option{scthresh} is @code{[0.0, 100.0]}.
  4664. Default value is @code{12.0}.
  4665. @item combmatch
  4666. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  4667. account the combed scores of matches when deciding what match to use as the
  4668. final match. Available values are:
  4669. @table @samp
  4670. @item none
  4671. No final matching based on combed scores.
  4672. @item sc
  4673. Combed scores are only used when a scene change is detected.
  4674. @item full
  4675. Use combed scores all the time.
  4676. @end table
  4677. Default is @var{sc}.
  4678. @item combdbg
  4679. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  4680. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  4681. Available values are:
  4682. @table @samp
  4683. @item none
  4684. No forced calculation.
  4685. @item pcn
  4686. Force p/c/n calculations.
  4687. @item pcnub
  4688. Force p/c/n/u/b calculations.
  4689. @end table
  4690. Default value is @var{none}.
  4691. @item cthresh
  4692. This is the area combing threshold used for combed frame detection. This
  4693. essentially controls how "strong" or "visible" combing must be to be detected.
  4694. Larger values mean combing must be more visible and smaller values mean combing
  4695. can be less visible or strong and still be detected. Valid settings are from
  4696. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  4697. be detected as combed). This is basically a pixel difference value. A good
  4698. range is @code{[8, 12]}.
  4699. Default value is @code{9}.
  4700. @item chroma
  4701. Sets whether or not chroma is considered in the combed frame decision. Only
  4702. disable this if your source has chroma problems (rainbowing, etc.) that are
  4703. causing problems for the combed frame detection with chroma enabled. Actually,
  4704. using @option{chroma}=@var{0} is usually more reliable, except for the case
  4705. where there is chroma only combing in the source.
  4706. Default value is @code{0}.
  4707. @item blockx
  4708. @item blocky
  4709. Respectively set the x-axis and y-axis size of the window used during combed
  4710. frame detection. This has to do with the size of the area in which
  4711. @option{combpel} pixels are required to be detected as combed for a frame to be
  4712. declared combed. See the @option{combpel} parameter description for more info.
  4713. Possible values are any number that is a power of 2 starting at 4 and going up
  4714. to 512.
  4715. Default value is @code{16}.
  4716. @item combpel
  4717. The number of combed pixels inside any of the @option{blocky} by
  4718. @option{blockx} size blocks on the frame for the frame to be detected as
  4719. combed. While @option{cthresh} controls how "visible" the combing must be, this
  4720. setting controls "how much" combing there must be in any localized area (a
  4721. window defined by the @option{blockx} and @option{blocky} settings) on the
  4722. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  4723. which point no frames will ever be detected as combed). This setting is known
  4724. as @option{MI} in TFM/VFM vocabulary.
  4725. Default value is @code{80}.
  4726. @end table
  4727. @anchor{p/c/n/u/b meaning}
  4728. @subsection p/c/n/u/b meaning
  4729. @subsubsection p/c/n
  4730. We assume the following telecined stream:
  4731. @example
  4732. Top fields: 1 2 2 3 4
  4733. Bottom fields: 1 2 3 4 4
  4734. @end example
  4735. The numbers correspond to the progressive frame the fields relate to. Here, the
  4736. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4737. When @code{fieldmatch} is configured to run a matching from bottom
  4738. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4739. @example
  4740. Input stream:
  4741. T 1 2 2 3 4
  4742. B 1 2 3 4 4 <-- matching reference
  4743. Matches: c c n n c
  4744. Output stream:
  4745. T 1 2 3 4 4
  4746. B 1 2 3 4 4
  4747. @end example
  4748. As a result of the field matching, we can see that some frames get duplicated.
  4749. To perform a complete inverse telecine, you need to rely on a decimation filter
  4750. after this operation. See for instance the @ref{decimate} filter.
  4751. The same operation now matching from top fields (@option{field}=@var{top})
  4752. looks like this:
  4753. @example
  4754. Input stream:
  4755. T 1 2 2 3 4 <-- matching reference
  4756. B 1 2 3 4 4
  4757. Matches: c c p p c
  4758. Output stream:
  4759. T 1 2 2 3 4
  4760. B 1 2 2 3 4
  4761. @end example
  4762. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4763. basically, they refer to the frame and field of the opposite parity:
  4764. @itemize
  4765. @item @var{p} matches the field of the opposite parity in the previous frame
  4766. @item @var{c} matches the field of the opposite parity in the current frame
  4767. @item @var{n} matches the field of the opposite parity in the next frame
  4768. @end itemize
  4769. @subsubsection u/b
  4770. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4771. from the opposite parity flag. In the following examples, we assume that we are
  4772. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4773. 'x' is placed above and below each matched fields.
  4774. With bottom matching (@option{field}=@var{bottom}):
  4775. @example
  4776. Match: c p n b u
  4777. x x x x x
  4778. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4779. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4780. x x x x x
  4781. Output frames:
  4782. 2 1 2 2 2
  4783. 2 2 2 1 3
  4784. @end example
  4785. With top matching (@option{field}=@var{top}):
  4786. @example
  4787. Match: c p n b u
  4788. x x x x x
  4789. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4790. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4791. x x x x x
  4792. Output frames:
  4793. 2 2 2 1 2
  4794. 2 1 3 2 2
  4795. @end example
  4796. @subsection Examples
  4797. Simple IVTC of a top field first telecined stream:
  4798. @example
  4799. fieldmatch=order=tff:combmatch=none, decimate
  4800. @end example
  4801. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4802. @example
  4803. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4804. @end example
  4805. @section fieldorder
  4806. Transform the field order of the input video.
  4807. It accepts the following parameters:
  4808. @table @option
  4809. @item order
  4810. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4811. for bottom field first.
  4812. @end table
  4813. The default value is @samp{tff}.
  4814. The transformation is done by shifting the picture content up or down
  4815. by one line, and filling the remaining line with appropriate picture content.
  4816. This method is consistent with most broadcast field order converters.
  4817. If the input video is not flagged as being interlaced, or it is already
  4818. flagged as being of the required output field order, then this filter does
  4819. not alter the incoming video.
  4820. It is very useful when converting to or from PAL DV material,
  4821. which is bottom field first.
  4822. For example:
  4823. @example
  4824. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4825. @end example
  4826. @section fifo
  4827. Buffer input images and send them when they are requested.
  4828. It is mainly useful when auto-inserted by the libavfilter
  4829. framework.
  4830. It does not take parameters.
  4831. @section find_rect
  4832. Find a rectangular object
  4833. It accepts the following options:
  4834. @table @option
  4835. @item object
  4836. Filepath of the object image, needs to be in gray8.
  4837. @item threshold
  4838. Detection threshold, default is 0.5.
  4839. @item mipmaps
  4840. Number of mipmaps, default is 3.
  4841. @item xmin, ymin, xmax, ymax
  4842. Specifies the rectangle in which to search.
  4843. @end table
  4844. @subsection Examples
  4845. @itemize
  4846. @item
  4847. Generate a representative palette of a given video using @command{ffmpeg}:
  4848. @example
  4849. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4850. @end example
  4851. @end itemize
  4852. @section cover_rect
  4853. Cover a rectangular object
  4854. It accepts the following options:
  4855. @table @option
  4856. @item cover
  4857. Filepath of the optional cover image, needs to be in yuv420.
  4858. @item mode
  4859. Set covering mode.
  4860. It accepts the following values:
  4861. @table @samp
  4862. @item cover
  4863. cover it by the supplied image
  4864. @item blur
  4865. cover it by interpolating the surrounding pixels
  4866. @end table
  4867. Default value is @var{blur}.
  4868. @end table
  4869. @subsection Examples
  4870. @itemize
  4871. @item
  4872. Generate a representative palette of a given video using @command{ffmpeg}:
  4873. @example
  4874. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4875. @end example
  4876. @end itemize
  4877. @anchor{format}
  4878. @section format
  4879. Convert the input video to one of the specified pixel formats.
  4880. Libavfilter will try to pick one that is suitable as input to
  4881. the next filter.
  4882. It accepts the following parameters:
  4883. @table @option
  4884. @item pix_fmts
  4885. A '|'-separated list of pixel format names, such as
  4886. "pix_fmts=yuv420p|monow|rgb24".
  4887. @end table
  4888. @subsection Examples
  4889. @itemize
  4890. @item
  4891. Convert the input video to the @var{yuv420p} format
  4892. @example
  4893. format=pix_fmts=yuv420p
  4894. @end example
  4895. Convert the input video to any of the formats in the list
  4896. @example
  4897. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4898. @end example
  4899. @end itemize
  4900. @anchor{fps}
  4901. @section fps
  4902. Convert the video to specified constant frame rate by duplicating or dropping
  4903. frames as necessary.
  4904. It accepts the following parameters:
  4905. @table @option
  4906. @item fps
  4907. The desired output frame rate. The default is @code{25}.
  4908. @item round
  4909. Rounding method.
  4910. Possible values are:
  4911. @table @option
  4912. @item zero
  4913. zero round towards 0
  4914. @item inf
  4915. round away from 0
  4916. @item down
  4917. round towards -infinity
  4918. @item up
  4919. round towards +infinity
  4920. @item near
  4921. round to nearest
  4922. @end table
  4923. The default is @code{near}.
  4924. @item start_time
  4925. Assume the first PTS should be the given value, in seconds. This allows for
  4926. padding/trimming at the start of stream. By default, no assumption is made
  4927. about the first frame's expected PTS, so no padding or trimming is done.
  4928. For example, this could be set to 0 to pad the beginning with duplicates of
  4929. the first frame if a video stream starts after the audio stream or to trim any
  4930. frames with a negative PTS.
  4931. @end table
  4932. Alternatively, the options can be specified as a flat string:
  4933. @var{fps}[:@var{round}].
  4934. See also the @ref{setpts} filter.
  4935. @subsection Examples
  4936. @itemize
  4937. @item
  4938. A typical usage in order to set the fps to 25:
  4939. @example
  4940. fps=fps=25
  4941. @end example
  4942. @item
  4943. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4944. @example
  4945. fps=fps=film:round=near
  4946. @end example
  4947. @end itemize
  4948. @section framepack
  4949. Pack two different video streams into a stereoscopic video, setting proper
  4950. metadata on supported codecs. The two views should have the same size and
  4951. framerate and processing will stop when the shorter video ends. Please note
  4952. that you may conveniently adjust view properties with the @ref{scale} and
  4953. @ref{fps} filters.
  4954. It accepts the following parameters:
  4955. @table @option
  4956. @item format
  4957. The desired packing format. Supported values are:
  4958. @table @option
  4959. @item sbs
  4960. The views are next to each other (default).
  4961. @item tab
  4962. The views are on top of each other.
  4963. @item lines
  4964. The views are packed by line.
  4965. @item columns
  4966. The views are packed by column.
  4967. @item frameseq
  4968. The views are temporally interleaved.
  4969. @end table
  4970. @end table
  4971. Some examples:
  4972. @example
  4973. # Convert left and right views into a frame-sequential video
  4974. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4975. # Convert views into a side-by-side video with the same output resolution as the input
  4976. 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
  4977. @end example
  4978. @section framerate
  4979. Change the frame rate by interpolating new video output frames from the source
  4980. frames.
  4981. This filter is not designed to function correctly with interlaced media. If
  4982. you wish to change the frame rate of interlaced media then you are required
  4983. to deinterlace before this filter and re-interlace after this filter.
  4984. A description of the accepted options follows.
  4985. @table @option
  4986. @item fps
  4987. Specify the output frames per second. This option can also be specified
  4988. as a value alone. The default is @code{50}.
  4989. @item interp_start
  4990. Specify the start of a range where the output frame will be created as a
  4991. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4992. the default is @code{15}.
  4993. @item interp_end
  4994. Specify the end of a range where the output frame will be created as a
  4995. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4996. the default is @code{240}.
  4997. @item scene
  4998. Specify the level at which a scene change is detected as a value between
  4999. 0 and 100 to indicate a new scene; a low value reflects a low
  5000. probability for the current frame to introduce a new scene, while a higher
  5001. value means the current frame is more likely to be one.
  5002. The default is @code{7}.
  5003. @item flags
  5004. Specify flags influencing the filter process.
  5005. Available value for @var{flags} is:
  5006. @table @option
  5007. @item scene_change_detect, scd
  5008. Enable scene change detection using the value of the option @var{scene}.
  5009. This flag is enabled by default.
  5010. @end table
  5011. @end table
  5012. @section framestep
  5013. Select one frame every N-th frame.
  5014. This filter accepts the following option:
  5015. @table @option
  5016. @item step
  5017. Select frame after every @code{step} frames.
  5018. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5019. @end table
  5020. @anchor{frei0r}
  5021. @section frei0r
  5022. Apply a frei0r effect to the input video.
  5023. To enable the compilation of this filter, you need to install the frei0r
  5024. header and configure FFmpeg with @code{--enable-frei0r}.
  5025. It accepts the following parameters:
  5026. @table @option
  5027. @item filter_name
  5028. The name of the frei0r effect to load. If the environment variable
  5029. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5030. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5031. Otherwise, the standard frei0r paths are searched, in this order:
  5032. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5033. @file{/usr/lib/frei0r-1/}.
  5034. @item filter_params
  5035. A '|'-separated list of parameters to pass to the frei0r effect.
  5036. @end table
  5037. A frei0r effect parameter can be a boolean (its value is either
  5038. "y" or "n"), a double, a color (specified as
  5039. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5040. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5041. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5042. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5043. The number and types of parameters depend on the loaded effect. If an
  5044. effect parameter is not specified, the default value is set.
  5045. @subsection Examples
  5046. @itemize
  5047. @item
  5048. Apply the distort0r effect, setting the first two double parameters:
  5049. @example
  5050. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5051. @end example
  5052. @item
  5053. Apply the colordistance effect, taking a color as the first parameter:
  5054. @example
  5055. frei0r=colordistance:0.2/0.3/0.4
  5056. frei0r=colordistance:violet
  5057. frei0r=colordistance:0x112233
  5058. @end example
  5059. @item
  5060. Apply the perspective effect, specifying the top left and top right image
  5061. positions:
  5062. @example
  5063. frei0r=perspective:0.2/0.2|0.8/0.2
  5064. @end example
  5065. @end itemize
  5066. For more information, see
  5067. @url{http://frei0r.dyne.org}
  5068. @section fspp
  5069. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5070. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5071. processing filter, one of them is performed once per block, not per pixel.
  5072. This allows for much higher speed.
  5073. The filter accepts the following options:
  5074. @table @option
  5075. @item quality
  5076. Set quality. This option defines the number of levels for averaging. It accepts
  5077. an integer in the range 4-5. Default value is @code{4}.
  5078. @item qp
  5079. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5080. If not set, the filter will use the QP from the video stream (if available).
  5081. @item strength
  5082. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5083. more details but also more artifacts, while higher values make the image smoother
  5084. but also blurrier. Default value is @code{0} − PSNR optimal.
  5085. @item use_bframe_qp
  5086. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5087. option may cause flicker since the B-Frames have often larger QP. Default is
  5088. @code{0} (not enabled).
  5089. @end table
  5090. @section geq
  5091. The filter accepts the following options:
  5092. @table @option
  5093. @item lum_expr, lum
  5094. Set the luminance expression.
  5095. @item cb_expr, cb
  5096. Set the chrominance blue expression.
  5097. @item cr_expr, cr
  5098. Set the chrominance red expression.
  5099. @item alpha_expr, a
  5100. Set the alpha expression.
  5101. @item red_expr, r
  5102. Set the red expression.
  5103. @item green_expr, g
  5104. Set the green expression.
  5105. @item blue_expr, b
  5106. Set the blue expression.
  5107. @end table
  5108. The colorspace is selected according to the specified options. If one
  5109. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5110. options is specified, the filter will automatically select a YCbCr
  5111. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5112. @option{blue_expr} options is specified, it will select an RGB
  5113. colorspace.
  5114. If one of the chrominance expression is not defined, it falls back on the other
  5115. one. If no alpha expression is specified it will evaluate to opaque value.
  5116. If none of chrominance expressions are specified, they will evaluate
  5117. to the luminance expression.
  5118. The expressions can use the following variables and functions:
  5119. @table @option
  5120. @item N
  5121. The sequential number of the filtered frame, starting from @code{0}.
  5122. @item X
  5123. @item Y
  5124. The coordinates of the current sample.
  5125. @item W
  5126. @item H
  5127. The width and height of the image.
  5128. @item SW
  5129. @item SH
  5130. Width and height scale depending on the currently filtered plane. It is the
  5131. ratio between the corresponding luma plane number of pixels and the current
  5132. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5133. @code{0.5,0.5} for chroma planes.
  5134. @item T
  5135. Time of the current frame, expressed in seconds.
  5136. @item p(x, y)
  5137. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5138. plane.
  5139. @item lum(x, y)
  5140. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5141. plane.
  5142. @item cb(x, y)
  5143. Return the value of the pixel at location (@var{x},@var{y}) of the
  5144. blue-difference chroma plane. Return 0 if there is no such plane.
  5145. @item cr(x, y)
  5146. Return the value of the pixel at location (@var{x},@var{y}) of the
  5147. red-difference chroma plane. Return 0 if there is no such plane.
  5148. @item r(x, y)
  5149. @item g(x, y)
  5150. @item b(x, y)
  5151. Return the value of the pixel at location (@var{x},@var{y}) of the
  5152. red/green/blue component. Return 0 if there is no such component.
  5153. @item alpha(x, y)
  5154. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5155. plane. Return 0 if there is no such plane.
  5156. @end table
  5157. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5158. automatically clipped to the closer edge.
  5159. @subsection Examples
  5160. @itemize
  5161. @item
  5162. Flip the image horizontally:
  5163. @example
  5164. geq=p(W-X\,Y)
  5165. @end example
  5166. @item
  5167. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5168. wavelength of 100 pixels:
  5169. @example
  5170. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5171. @end example
  5172. @item
  5173. Generate a fancy enigmatic moving light:
  5174. @example
  5175. 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
  5176. @end example
  5177. @item
  5178. Generate a quick emboss effect:
  5179. @example
  5180. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5181. @end example
  5182. @item
  5183. Modify RGB components depending on pixel position:
  5184. @example
  5185. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5186. @end example
  5187. @item
  5188. Create a radial gradient that is the same size as the input (also see
  5189. the @ref{vignette} filter):
  5190. @example
  5191. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5192. @end example
  5193. @item
  5194. Create a linear gradient to use as a mask for another filter, then
  5195. compose with @ref{overlay}. In this example the video will gradually
  5196. become more blurry from the top to the bottom of the y-axis as defined
  5197. by the linear gradient:
  5198. @example
  5199. 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
  5200. @end example
  5201. @end itemize
  5202. @section gradfun
  5203. Fix the banding artifacts that are sometimes introduced into nearly flat
  5204. regions by truncation to 8bit color depth.
  5205. Interpolate the gradients that should go where the bands are, and
  5206. dither them.
  5207. It is designed for playback only. Do not use it prior to
  5208. lossy compression, because compression tends to lose the dither and
  5209. bring back the bands.
  5210. It accepts the following parameters:
  5211. @table @option
  5212. @item strength
  5213. The maximum amount by which the filter will change any one pixel. This is also
  5214. the threshold for detecting nearly flat regions. Acceptable values range from
  5215. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5216. valid range.
  5217. @item radius
  5218. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5219. gradients, but also prevents the filter from modifying the pixels near detailed
  5220. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5221. values will be clipped to the valid range.
  5222. @end table
  5223. Alternatively, the options can be specified as a flat string:
  5224. @var{strength}[:@var{radius}]
  5225. @subsection Examples
  5226. @itemize
  5227. @item
  5228. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5229. @example
  5230. gradfun=3.5:8
  5231. @end example
  5232. @item
  5233. Specify radius, omitting the strength (which will fall-back to the default
  5234. value):
  5235. @example
  5236. gradfun=radius=8
  5237. @end example
  5238. @end itemize
  5239. @anchor{haldclut}
  5240. @section haldclut
  5241. Apply a Hald CLUT to a video stream.
  5242. First input is the video stream to process, and second one is the Hald CLUT.
  5243. The Hald CLUT input can be a simple picture or a complete video stream.
  5244. The filter accepts the following options:
  5245. @table @option
  5246. @item shortest
  5247. Force termination when the shortest input terminates. Default is @code{0}.
  5248. @item repeatlast
  5249. Continue applying the last CLUT after the end of the stream. A value of
  5250. @code{0} disable the filter after the last frame of the CLUT is reached.
  5251. Default is @code{1}.
  5252. @end table
  5253. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5254. filters share the same internals).
  5255. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5256. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5257. @subsection Workflow examples
  5258. @subsubsection Hald CLUT video stream
  5259. Generate an identity Hald CLUT stream altered with various effects:
  5260. @example
  5261. 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
  5262. @end example
  5263. Note: make sure you use a lossless codec.
  5264. Then use it with @code{haldclut} to apply it on some random stream:
  5265. @example
  5266. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5267. @end example
  5268. The Hald CLUT will be applied to the 10 first seconds (duration of
  5269. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5270. to the remaining frames of the @code{mandelbrot} stream.
  5271. @subsubsection Hald CLUT with preview
  5272. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5273. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5274. biggest possible square starting at the top left of the picture. The remaining
  5275. padding pixels (bottom or right) will be ignored. This area can be used to add
  5276. a preview of the Hald CLUT.
  5277. Typically, the following generated Hald CLUT will be supported by the
  5278. @code{haldclut} filter:
  5279. @example
  5280. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5281. pad=iw+320 [padded_clut];
  5282. smptebars=s=320x256, split [a][b];
  5283. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5284. [main][b] overlay=W-320" -frames:v 1 clut.png
  5285. @end example
  5286. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5287. bars are displayed on the right-top, and below the same color bars processed by
  5288. the color changes.
  5289. Then, the effect of this Hald CLUT can be visualized with:
  5290. @example
  5291. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5292. @end example
  5293. @section hflip
  5294. Flip the input video horizontally.
  5295. For example, to horizontally flip the input video with @command{ffmpeg}:
  5296. @example
  5297. ffmpeg -i in.avi -vf "hflip" out.avi
  5298. @end example
  5299. @section histeq
  5300. This filter applies a global color histogram equalization on a
  5301. per-frame basis.
  5302. It can be used to correct video that has a compressed range of pixel
  5303. intensities. The filter redistributes the pixel intensities to
  5304. equalize their distribution across the intensity range. It may be
  5305. viewed as an "automatically adjusting contrast filter". This filter is
  5306. useful only for correcting degraded or poorly captured source
  5307. video.
  5308. The filter accepts the following options:
  5309. @table @option
  5310. @item strength
  5311. Determine the amount of equalization to be applied. As the strength
  5312. is reduced, the distribution of pixel intensities more-and-more
  5313. approaches that of the input frame. The value must be a float number
  5314. in the range [0,1] and defaults to 0.200.
  5315. @item intensity
  5316. Set the maximum intensity that can generated and scale the output
  5317. values appropriately. The strength should be set as desired and then
  5318. the intensity can be limited if needed to avoid washing-out. The value
  5319. must be a float number in the range [0,1] and defaults to 0.210.
  5320. @item antibanding
  5321. Set the antibanding level. If enabled the filter will randomly vary
  5322. the luminance of output pixels by a small amount to avoid banding of
  5323. the histogram. Possible values are @code{none}, @code{weak} or
  5324. @code{strong}. It defaults to @code{none}.
  5325. @end table
  5326. @section histogram
  5327. Compute and draw a color distribution histogram for the input video.
  5328. The computed histogram is a representation of the color component
  5329. distribution in an image.
  5330. The filter accepts the following options:
  5331. @table @option
  5332. @item mode
  5333. Set histogram mode.
  5334. It accepts the following values:
  5335. @table @samp
  5336. @item levels
  5337. Standard histogram that displays the color components distribution in an
  5338. image. Displays color graph for each color component. Shows distribution of
  5339. the Y, U, V, A or R, G, B components, depending on input format, in the
  5340. current frame. Below each graph a color component scale meter is shown.
  5341. @item color
  5342. Displays chroma values (U/V color placement) in a two dimensional
  5343. graph (which is called a vectorscope). The brighter a pixel in the
  5344. vectorscope, the more pixels of the input frame correspond to that pixel
  5345. (i.e., more pixels have this chroma value). The V component is displayed on
  5346. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  5347. side being V = 255. The U component is displayed on the vertical (Y) axis,
  5348. with the top representing U = 0 and the bottom representing U = 255.
  5349. The position of a white pixel in the graph corresponds to the chroma value of
  5350. a pixel of the input clip. The graph can therefore be used to read the hue
  5351. (color flavor) and the saturation (the dominance of the hue in the color). As
  5352. the hue of a color changes, it moves around the square. At the center of the
  5353. square the saturation is zero, which means that the corresponding pixel has no
  5354. color. If the amount of a specific color is increased (while leaving the other
  5355. colors unchanged) the saturation increases, and the indicator moves towards
  5356. the edge of the square.
  5357. @item color2
  5358. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  5359. are displayed.
  5360. @item waveform
  5361. Per row/column color component graph. In row mode, the graph on the left side
  5362. represents color component value 0 and the right side represents value = 255.
  5363. In column mode, the top side represents color component value = 0 and bottom
  5364. side represents value = 255.
  5365. @end table
  5366. Default value is @code{levels}.
  5367. @item level_height
  5368. Set height of level in @code{levels}. Default value is @code{200}.
  5369. Allowed range is [50, 2048].
  5370. @item scale_height
  5371. Set height of color scale in @code{levels}. Default value is @code{12}.
  5372. Allowed range is [0, 40].
  5373. @item step
  5374. Set step for @code{waveform} mode. Smaller values are useful to find out how
  5375. many values of the same luminance are distributed across input rows/columns.
  5376. Default value is @code{10}. Allowed range is [1, 255].
  5377. @item waveform_mode
  5378. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  5379. Default is @code{row}.
  5380. @item waveform_mirror
  5381. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  5382. means mirrored. In mirrored mode, higher values will be represented on the left
  5383. side for @code{row} mode and at the top for @code{column} mode. Default is
  5384. @code{0} (unmirrored).
  5385. @item display_mode
  5386. Set display mode for @code{waveform} and @code{levels}.
  5387. It accepts the following values:
  5388. @table @samp
  5389. @item parade
  5390. Display separate graph for the color components side by side in
  5391. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5392. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5393. per color component graphs are placed below each other.
  5394. Using this display mode in @code{waveform} histogram mode makes it easy to
  5395. spot color casts in the highlights and shadows of an image, by comparing the
  5396. contours of the top and the bottom graphs of each waveform. Since whites,
  5397. grays, and blacks are characterized by exactly equal amounts of red, green,
  5398. and blue, neutral areas of the picture should display three waveforms of
  5399. roughly equal width/height. If not, the correction is easy to perform by
  5400. making level adjustments the three waveforms.
  5401. @item overlay
  5402. Presents information identical to that in the @code{parade}, except
  5403. that the graphs representing color components are superimposed directly
  5404. over one another.
  5405. This display mode in @code{waveform} histogram mode makes it easier to spot
  5406. relative differences or similarities in overlapping areas of the color
  5407. components that are supposed to be identical, such as neutral whites, grays,
  5408. or blacks.
  5409. @end table
  5410. Default is @code{parade}.
  5411. @item levels_mode
  5412. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5413. Default is @code{linear}.
  5414. @item components
  5415. Set what color components to display for mode @code{levels}.
  5416. Default is @code{7}.
  5417. @end table
  5418. @subsection Examples
  5419. @itemize
  5420. @item
  5421. Calculate and draw histogram:
  5422. @example
  5423. ffplay -i input -vf histogram
  5424. @end example
  5425. @end itemize
  5426. @anchor{hqdn3d}
  5427. @section hqdn3d
  5428. This is a high precision/quality 3d denoise filter. It aims to reduce
  5429. image noise, producing smooth images and making still images really
  5430. still. It should enhance compressibility.
  5431. It accepts the following optional parameters:
  5432. @table @option
  5433. @item luma_spatial
  5434. A non-negative floating point number which specifies spatial luma strength.
  5435. It defaults to 4.0.
  5436. @item chroma_spatial
  5437. A non-negative floating point number which specifies spatial chroma strength.
  5438. It defaults to 3.0*@var{luma_spatial}/4.0.
  5439. @item luma_tmp
  5440. A floating point number which specifies luma temporal strength. It defaults to
  5441. 6.0*@var{luma_spatial}/4.0.
  5442. @item chroma_tmp
  5443. A floating point number which specifies chroma temporal strength. It defaults to
  5444. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5445. @end table
  5446. @section hqx
  5447. Apply a high-quality magnification filter designed for pixel art. This filter
  5448. was originally created by Maxim Stepin.
  5449. It accepts the following option:
  5450. @table @option
  5451. @item n
  5452. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5453. @code{hq3x} and @code{4} for @code{hq4x}.
  5454. Default is @code{3}.
  5455. @end table
  5456. @section hstack
  5457. Stack input videos horizontally.
  5458. All streams must be of same pixel format and of same height.
  5459. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5460. to create same output.
  5461. The filter accept the following option:
  5462. @table @option
  5463. @item inputs
  5464. Set number of input streams. Default is 2.
  5465. @end table
  5466. @section hue
  5467. Modify the hue and/or the saturation of the input.
  5468. It accepts the following parameters:
  5469. @table @option
  5470. @item h
  5471. Specify the hue angle as a number of degrees. It accepts an expression,
  5472. and defaults to "0".
  5473. @item s
  5474. Specify the saturation in the [-10,10] range. It accepts an expression and
  5475. defaults to "1".
  5476. @item H
  5477. Specify the hue angle as a number of radians. It accepts an
  5478. expression, and defaults to "0".
  5479. @item b
  5480. Specify the brightness in the [-10,10] range. It accepts an expression and
  5481. defaults to "0".
  5482. @end table
  5483. @option{h} and @option{H} are mutually exclusive, and can't be
  5484. specified at the same time.
  5485. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5486. expressions containing the following constants:
  5487. @table @option
  5488. @item n
  5489. frame count of the input frame starting from 0
  5490. @item pts
  5491. presentation timestamp of the input frame expressed in time base units
  5492. @item r
  5493. frame rate of the input video, NAN if the input frame rate is unknown
  5494. @item t
  5495. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5496. @item tb
  5497. time base of the input video
  5498. @end table
  5499. @subsection Examples
  5500. @itemize
  5501. @item
  5502. Set the hue to 90 degrees and the saturation to 1.0:
  5503. @example
  5504. hue=h=90:s=1
  5505. @end example
  5506. @item
  5507. Same command but expressing the hue in radians:
  5508. @example
  5509. hue=H=PI/2:s=1
  5510. @end example
  5511. @item
  5512. Rotate hue and make the saturation swing between 0
  5513. and 2 over a period of 1 second:
  5514. @example
  5515. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5516. @end example
  5517. @item
  5518. Apply a 3 seconds saturation fade-in effect starting at 0:
  5519. @example
  5520. hue="s=min(t/3\,1)"
  5521. @end example
  5522. The general fade-in expression can be written as:
  5523. @example
  5524. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5525. @end example
  5526. @item
  5527. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5528. @example
  5529. hue="s=max(0\, min(1\, (8-t)/3))"
  5530. @end example
  5531. The general fade-out expression can be written as:
  5532. @example
  5533. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5534. @end example
  5535. @end itemize
  5536. @subsection Commands
  5537. This filter supports the following commands:
  5538. @table @option
  5539. @item b
  5540. @item s
  5541. @item h
  5542. @item H
  5543. Modify the hue and/or the saturation and/or brightness of the input video.
  5544. The command accepts the same syntax of the corresponding option.
  5545. If the specified expression is not valid, it is kept at its current
  5546. value.
  5547. @end table
  5548. @section idet
  5549. Detect video interlacing type.
  5550. This filter tries to detect if the input frames as interlaced, progressive,
  5551. top or bottom field first. It will also try and detect fields that are
  5552. repeated between adjacent frames (a sign of telecine).
  5553. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5554. Multiple frame detection incorporates the classification history of previous frames.
  5555. The filter will log these metadata values:
  5556. @table @option
  5557. @item single.current_frame
  5558. Detected type of current frame using single-frame detection. One of:
  5559. ``tff'' (top field first), ``bff'' (bottom field first),
  5560. ``progressive'', or ``undetermined''
  5561. @item single.tff
  5562. Cumulative number of frames detected as top field first using single-frame detection.
  5563. @item multiple.tff
  5564. Cumulative number of frames detected as top field first using multiple-frame detection.
  5565. @item single.bff
  5566. Cumulative number of frames detected as bottom field first using single-frame detection.
  5567. @item multiple.current_frame
  5568. Detected type of current frame using multiple-frame detection. One of:
  5569. ``tff'' (top field first), ``bff'' (bottom field first),
  5570. ``progressive'', or ``undetermined''
  5571. @item multiple.bff
  5572. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5573. @item single.progressive
  5574. Cumulative number of frames detected as progressive using single-frame detection.
  5575. @item multiple.progressive
  5576. Cumulative number of frames detected as progressive using multiple-frame detection.
  5577. @item single.undetermined
  5578. Cumulative number of frames that could not be classified using single-frame detection.
  5579. @item multiple.undetermined
  5580. Cumulative number of frames that could not be classified using multiple-frame detection.
  5581. @item repeated.current_frame
  5582. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5583. @item repeated.neither
  5584. Cumulative number of frames with no repeated field.
  5585. @item repeated.top
  5586. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5587. @item repeated.bottom
  5588. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5589. @end table
  5590. The filter accepts the following options:
  5591. @table @option
  5592. @item intl_thres
  5593. Set interlacing threshold.
  5594. @item prog_thres
  5595. Set progressive threshold.
  5596. @item repeat_thres
  5597. Threshold for repeated field detection.
  5598. @item half_life
  5599. Number of frames after which a given frame's contribution to the
  5600. statistics is halved (i.e., it contributes only 0.5 to it's
  5601. classification). The default of 0 means that all frames seen are given
  5602. full weight of 1.0 forever.
  5603. @item analyze_interlaced_flag
  5604. When this is not 0 then idet will use the specified number of frames to determine
  5605. if the interlaced flag is accurate, it will not count undetermined frames.
  5606. If the flag is found to be accurate it will be used without any further
  5607. computations, if it is found to be inaccurate it will be cleared without any
  5608. further computations. This allows inserting the idet filter as a low computational
  5609. method to clean up the interlaced flag
  5610. @end table
  5611. @section il
  5612. Deinterleave or interleave fields.
  5613. This filter allows one to process interlaced images fields without
  5614. deinterlacing them. Deinterleaving splits the input frame into 2
  5615. fields (so called half pictures). Odd lines are moved to the top
  5616. half of the output image, even lines to the bottom half.
  5617. You can process (filter) them independently and then re-interleave them.
  5618. The filter accepts the following options:
  5619. @table @option
  5620. @item luma_mode, l
  5621. @item chroma_mode, c
  5622. @item alpha_mode, a
  5623. Available values for @var{luma_mode}, @var{chroma_mode} and
  5624. @var{alpha_mode} are:
  5625. @table @samp
  5626. @item none
  5627. Do nothing.
  5628. @item deinterleave, d
  5629. Deinterleave fields, placing one above the other.
  5630. @item interleave, i
  5631. Interleave fields. Reverse the effect of deinterleaving.
  5632. @end table
  5633. Default value is @code{none}.
  5634. @item luma_swap, ls
  5635. @item chroma_swap, cs
  5636. @item alpha_swap, as
  5637. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5638. @end table
  5639. @section inflate
  5640. Apply inflate effect to the video.
  5641. This filter replaces the pixel by the local(3x3) average by taking into account
  5642. only values higher than the pixel.
  5643. It accepts the following options:
  5644. @table @option
  5645. @item threshold0
  5646. @item threshold1
  5647. @item threshold2
  5648. @item threshold3
  5649. Limit the maximum change for each plane, default is 65535.
  5650. If 0, plane will remain unchanged.
  5651. @end table
  5652. @section interlace
  5653. Simple interlacing filter from progressive contents. This interleaves upper (or
  5654. lower) lines from odd frames with lower (or upper) lines from even frames,
  5655. halving the frame rate and preserving image height.
  5656. @example
  5657. Original Original New Frame
  5658. Frame 'j' Frame 'j+1' (tff)
  5659. ========== =========== ==================
  5660. Line 0 --------------------> Frame 'j' Line 0
  5661. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5662. Line 2 ---------------------> Frame 'j' Line 2
  5663. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5664. ... ... ...
  5665. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5666. @end example
  5667. It accepts the following optional parameters:
  5668. @table @option
  5669. @item scan
  5670. This determines whether the interlaced frame is taken from the even
  5671. (tff - default) or odd (bff) lines of the progressive frame.
  5672. @item lowpass
  5673. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5674. interlacing and reduce moire patterns.
  5675. @end table
  5676. @section kerndeint
  5677. Deinterlace input video by applying Donald Graft's adaptive kernel
  5678. deinterling. Work on interlaced parts of a video to produce
  5679. progressive frames.
  5680. The description of the accepted parameters follows.
  5681. @table @option
  5682. @item thresh
  5683. Set the threshold which affects the filter's tolerance when
  5684. determining if a pixel line must be processed. It must be an integer
  5685. in the range [0,255] and defaults to 10. A value of 0 will result in
  5686. applying the process on every pixels.
  5687. @item map
  5688. Paint pixels exceeding the threshold value to white if set to 1.
  5689. Default is 0.
  5690. @item order
  5691. Set the fields order. Swap fields if set to 1, leave fields alone if
  5692. 0. Default is 0.
  5693. @item sharp
  5694. Enable additional sharpening if set to 1. Default is 0.
  5695. @item twoway
  5696. Enable twoway sharpening if set to 1. Default is 0.
  5697. @end table
  5698. @subsection Examples
  5699. @itemize
  5700. @item
  5701. Apply default values:
  5702. @example
  5703. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5704. @end example
  5705. @item
  5706. Enable additional sharpening:
  5707. @example
  5708. kerndeint=sharp=1
  5709. @end example
  5710. @item
  5711. Paint processed pixels in white:
  5712. @example
  5713. kerndeint=map=1
  5714. @end example
  5715. @end itemize
  5716. @section lenscorrection
  5717. Correct radial lens distortion
  5718. This filter can be used to correct for radial distortion as can result from the use
  5719. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5720. one can use tools available for example as part of opencv or simply trial-and-error.
  5721. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5722. and extract the k1 and k2 coefficients from the resulting matrix.
  5723. Note that effectively the same filter is available in the open-source tools Krita and
  5724. Digikam from the KDE project.
  5725. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5726. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5727. brightness distribution, so you may want to use both filters together in certain
  5728. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5729. be applied before or after lens correction.
  5730. @subsection Options
  5731. The filter accepts the following options:
  5732. @table @option
  5733. @item cx
  5734. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5735. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5736. width.
  5737. @item cy
  5738. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5739. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5740. height.
  5741. @item k1
  5742. Coefficient of the quadratic correction term. 0.5 means no correction.
  5743. @item k2
  5744. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5745. @end table
  5746. The formula that generates the correction is:
  5747. @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)
  5748. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5749. distances from the focal point in the source and target images, respectively.
  5750. @anchor{lut3d}
  5751. @section lut3d
  5752. Apply a 3D LUT to an input video.
  5753. The filter accepts the following options:
  5754. @table @option
  5755. @item file
  5756. Set the 3D LUT file name.
  5757. Currently supported formats:
  5758. @table @samp
  5759. @item 3dl
  5760. AfterEffects
  5761. @item cube
  5762. Iridas
  5763. @item dat
  5764. DaVinci
  5765. @item m3d
  5766. Pandora
  5767. @end table
  5768. @item interp
  5769. Select interpolation mode.
  5770. Available values are:
  5771. @table @samp
  5772. @item nearest
  5773. Use values from the nearest defined point.
  5774. @item trilinear
  5775. Interpolate values using the 8 points defining a cube.
  5776. @item tetrahedral
  5777. Interpolate values using a tetrahedron.
  5778. @end table
  5779. @end table
  5780. @section lut, lutrgb, lutyuv
  5781. Compute a look-up table for binding each pixel component input value
  5782. to an output value, and apply it to the input video.
  5783. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5784. to an RGB input video.
  5785. These filters accept the following parameters:
  5786. @table @option
  5787. @item c0
  5788. set first pixel component expression
  5789. @item c1
  5790. set second pixel component expression
  5791. @item c2
  5792. set third pixel component expression
  5793. @item c3
  5794. set fourth pixel component expression, corresponds to the alpha component
  5795. @item r
  5796. set red component expression
  5797. @item g
  5798. set green component expression
  5799. @item b
  5800. set blue component expression
  5801. @item a
  5802. alpha component expression
  5803. @item y
  5804. set Y/luminance component expression
  5805. @item u
  5806. set U/Cb component expression
  5807. @item v
  5808. set V/Cr component expression
  5809. @end table
  5810. Each of them specifies the expression to use for computing the lookup table for
  5811. the corresponding pixel component values.
  5812. The exact component associated to each of the @var{c*} options depends on the
  5813. format in input.
  5814. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5815. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5816. The expressions can contain the following constants and functions:
  5817. @table @option
  5818. @item w
  5819. @item h
  5820. The input width and height.
  5821. @item val
  5822. The input value for the pixel component.
  5823. @item clipval
  5824. The input value, clipped to the @var{minval}-@var{maxval} range.
  5825. @item maxval
  5826. The maximum value for the pixel component.
  5827. @item minval
  5828. The minimum value for the pixel component.
  5829. @item negval
  5830. The negated value for the pixel component value, clipped to the
  5831. @var{minval}-@var{maxval} range; it corresponds to the expression
  5832. "maxval-clipval+minval".
  5833. @item clip(val)
  5834. The computed value in @var{val}, clipped to the
  5835. @var{minval}-@var{maxval} range.
  5836. @item gammaval(gamma)
  5837. The computed gamma correction value of the pixel component value,
  5838. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5839. expression
  5840. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5841. @end table
  5842. All expressions default to "val".
  5843. @subsection Examples
  5844. @itemize
  5845. @item
  5846. Negate input video:
  5847. @example
  5848. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5849. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5850. @end example
  5851. The above is the same as:
  5852. @example
  5853. lutrgb="r=negval:g=negval:b=negval"
  5854. lutyuv="y=negval:u=negval:v=negval"
  5855. @end example
  5856. @item
  5857. Negate luminance:
  5858. @example
  5859. lutyuv=y=negval
  5860. @end example
  5861. @item
  5862. Remove chroma components, turning the video into a graytone image:
  5863. @example
  5864. lutyuv="u=128:v=128"
  5865. @end example
  5866. @item
  5867. Apply a luma burning effect:
  5868. @example
  5869. lutyuv="y=2*val"
  5870. @end example
  5871. @item
  5872. Remove green and blue components:
  5873. @example
  5874. lutrgb="g=0:b=0"
  5875. @end example
  5876. @item
  5877. Set a constant alpha channel value on input:
  5878. @example
  5879. format=rgba,lutrgb=a="maxval-minval/2"
  5880. @end example
  5881. @item
  5882. Correct luminance gamma by a factor of 0.5:
  5883. @example
  5884. lutyuv=y=gammaval(0.5)
  5885. @end example
  5886. @item
  5887. Discard least significant bits of luma:
  5888. @example
  5889. lutyuv=y='bitand(val, 128+64+32)'
  5890. @end example
  5891. @end itemize
  5892. @section maskedmerge
  5893. Merge the first input stream with the second input stream using per pixel
  5894. weights in the third input stream.
  5895. A value of 0 in the third stream pixel component means that pixel component
  5896. from first stream is returned unchanged, while maximum value (eg. 255 for
  5897. 8-bit videos) means that pixel component from second stream is returned
  5898. unchanged. Intermediate values define the amount of merging between both
  5899. input stream's pixel components.
  5900. This filter accepts the following options:
  5901. @table @option
  5902. @item planes
  5903. Set which planes will be processed as bitmap, unprocessed planes will be
  5904. copied from first stream.
  5905. By default value 0xf, all planes will be processed.
  5906. @end table
  5907. @section mcdeint
  5908. Apply motion-compensation deinterlacing.
  5909. It needs one field per frame as input and must thus be used together
  5910. with yadif=1/3 or equivalent.
  5911. This filter accepts the following options:
  5912. @table @option
  5913. @item mode
  5914. Set the deinterlacing mode.
  5915. It accepts one of the following values:
  5916. @table @samp
  5917. @item fast
  5918. @item medium
  5919. @item slow
  5920. use iterative motion estimation
  5921. @item extra_slow
  5922. like @samp{slow}, but use multiple reference frames.
  5923. @end table
  5924. Default value is @samp{fast}.
  5925. @item parity
  5926. Set the picture field parity assumed for the input video. It must be
  5927. one of the following values:
  5928. @table @samp
  5929. @item 0, tff
  5930. assume top field first
  5931. @item 1, bff
  5932. assume bottom field first
  5933. @end table
  5934. Default value is @samp{bff}.
  5935. @item qp
  5936. Set per-block quantization parameter (QP) used by the internal
  5937. encoder.
  5938. Higher values should result in a smoother motion vector field but less
  5939. optimal individual vectors. Default value is 1.
  5940. @end table
  5941. @section mergeplanes
  5942. Merge color channel components from several video streams.
  5943. The filter accepts up to 4 input streams, and merge selected input
  5944. planes to the output video.
  5945. This filter accepts the following options:
  5946. @table @option
  5947. @item mapping
  5948. Set input to output plane mapping. Default is @code{0}.
  5949. The mappings is specified as a bitmap. It should be specified as a
  5950. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5951. mapping for the first plane of the output stream. 'A' sets the number of
  5952. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5953. corresponding input to use (from 0 to 3). The rest of the mappings is
  5954. similar, 'Bb' describes the mapping for the output stream second
  5955. plane, 'Cc' describes the mapping for the output stream third plane and
  5956. 'Dd' describes the mapping for the output stream fourth plane.
  5957. @item format
  5958. Set output pixel format. Default is @code{yuva444p}.
  5959. @end table
  5960. @subsection Examples
  5961. @itemize
  5962. @item
  5963. Merge three gray video streams of same width and height into single video stream:
  5964. @example
  5965. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5966. @end example
  5967. @item
  5968. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5969. @example
  5970. [a0][a1]mergeplanes=0x00010210:yuva444p
  5971. @end example
  5972. @item
  5973. Swap Y and A plane in yuva444p stream:
  5974. @example
  5975. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5976. @end example
  5977. @item
  5978. Swap U and V plane in yuv420p stream:
  5979. @example
  5980. format=yuv420p,mergeplanes=0x000201:yuv420p
  5981. @end example
  5982. @item
  5983. Cast a rgb24 clip to yuv444p:
  5984. @example
  5985. format=rgb24,mergeplanes=0x000102:yuv444p
  5986. @end example
  5987. @end itemize
  5988. @section mpdecimate
  5989. Drop frames that do not differ greatly from the previous frame in
  5990. order to reduce frame rate.
  5991. The main use of this filter is for very-low-bitrate encoding
  5992. (e.g. streaming over dialup modem), but it could in theory be used for
  5993. fixing movies that were inverse-telecined incorrectly.
  5994. A description of the accepted options follows.
  5995. @table @option
  5996. @item max
  5997. Set the maximum number of consecutive frames which can be dropped (if
  5998. positive), or the minimum interval between dropped frames (if
  5999. negative). If the value is 0, the frame is dropped unregarding the
  6000. number of previous sequentially dropped frames.
  6001. Default value is 0.
  6002. @item hi
  6003. @item lo
  6004. @item frac
  6005. Set the dropping threshold values.
  6006. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6007. represent actual pixel value differences, so a threshold of 64
  6008. corresponds to 1 unit of difference for each pixel, or the same spread
  6009. out differently over the block.
  6010. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6011. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6012. meaning the whole image) differ by more than a threshold of @option{lo}.
  6013. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6014. 64*5, and default value for @option{frac} is 0.33.
  6015. @end table
  6016. @section negate
  6017. Negate input video.
  6018. It accepts an integer in input; if non-zero it negates the
  6019. alpha component (if available). The default value in input is 0.
  6020. @section noformat
  6021. Force libavfilter not to use any of the specified pixel formats for the
  6022. input to the next filter.
  6023. It accepts the following parameters:
  6024. @table @option
  6025. @item pix_fmts
  6026. A '|'-separated list of pixel format names, such as
  6027. apix_fmts=yuv420p|monow|rgb24".
  6028. @end table
  6029. @subsection Examples
  6030. @itemize
  6031. @item
  6032. Force libavfilter to use a format different from @var{yuv420p} for the
  6033. input to the vflip filter:
  6034. @example
  6035. noformat=pix_fmts=yuv420p,vflip
  6036. @end example
  6037. @item
  6038. Convert the input video to any of the formats not contained in the list:
  6039. @example
  6040. noformat=yuv420p|yuv444p|yuv410p
  6041. @end example
  6042. @end itemize
  6043. @section noise
  6044. Add noise on video input frame.
  6045. The filter accepts the following options:
  6046. @table @option
  6047. @item all_seed
  6048. @item c0_seed
  6049. @item c1_seed
  6050. @item c2_seed
  6051. @item c3_seed
  6052. Set noise seed for specific pixel component or all pixel components in case
  6053. of @var{all_seed}. Default value is @code{123457}.
  6054. @item all_strength, alls
  6055. @item c0_strength, c0s
  6056. @item c1_strength, c1s
  6057. @item c2_strength, c2s
  6058. @item c3_strength, c3s
  6059. Set noise strength for specific pixel component or all pixel components in case
  6060. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6061. @item all_flags, allf
  6062. @item c0_flags, c0f
  6063. @item c1_flags, c1f
  6064. @item c2_flags, c2f
  6065. @item c3_flags, c3f
  6066. Set pixel component flags or set flags for all components if @var{all_flags}.
  6067. Available values for component flags are:
  6068. @table @samp
  6069. @item a
  6070. averaged temporal noise (smoother)
  6071. @item p
  6072. mix random noise with a (semi)regular pattern
  6073. @item t
  6074. temporal noise (noise pattern changes between frames)
  6075. @item u
  6076. uniform noise (gaussian otherwise)
  6077. @end table
  6078. @end table
  6079. @subsection Examples
  6080. Add temporal and uniform noise to input video:
  6081. @example
  6082. noise=alls=20:allf=t+u
  6083. @end example
  6084. @section null
  6085. Pass the video source unchanged to the output.
  6086. @section ocr
  6087. Optical Character Recognition
  6088. This filter uses Tesseract for optical character recognition.
  6089. It accepts the following options:
  6090. @table @option
  6091. @item datapath
  6092. Set datapath to tesseract data. Default is to use whatever was
  6093. set at installation.
  6094. @item language
  6095. Set language, default is "eng".
  6096. @item whitelist
  6097. Set character whitelist.
  6098. @item blacklist
  6099. Set character blacklist.
  6100. @end table
  6101. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6102. @section ocv
  6103. Apply a video transform using libopencv.
  6104. To enable this filter, install the libopencv library and headers and
  6105. configure FFmpeg with @code{--enable-libopencv}.
  6106. It accepts the following parameters:
  6107. @table @option
  6108. @item filter_name
  6109. The name of the libopencv filter to apply.
  6110. @item filter_params
  6111. The parameters to pass to the libopencv filter. If not specified, the default
  6112. values are assumed.
  6113. @end table
  6114. Refer to the official libopencv documentation for more precise
  6115. information:
  6116. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  6117. Several libopencv filters are supported; see the following subsections.
  6118. @anchor{dilate}
  6119. @subsection dilate
  6120. Dilate an image by using a specific structuring element.
  6121. It corresponds to the libopencv function @code{cvDilate}.
  6122. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  6123. @var{struct_el} represents a structuring element, and has the syntax:
  6124. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  6125. @var{cols} and @var{rows} represent the number of columns and rows of
  6126. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  6127. point, and @var{shape} the shape for the structuring element. @var{shape}
  6128. must be "rect", "cross", "ellipse", or "custom".
  6129. If the value for @var{shape} is "custom", it must be followed by a
  6130. string of the form "=@var{filename}". The file with name
  6131. @var{filename} is assumed to represent a binary image, with each
  6132. printable character corresponding to a bright pixel. When a custom
  6133. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  6134. or columns and rows of the read file are assumed instead.
  6135. The default value for @var{struct_el} is "3x3+0x0/rect".
  6136. @var{nb_iterations} specifies the number of times the transform is
  6137. applied to the image, and defaults to 1.
  6138. Some examples:
  6139. @example
  6140. # Use the default values
  6141. ocv=dilate
  6142. # Dilate using a structuring element with a 5x5 cross, iterating two times
  6143. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  6144. # Read the shape from the file diamond.shape, iterating two times.
  6145. # The file diamond.shape may contain a pattern of characters like this
  6146. # *
  6147. # ***
  6148. # *****
  6149. # ***
  6150. # *
  6151. # The specified columns and rows are ignored
  6152. # but the anchor point coordinates are not
  6153. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  6154. @end example
  6155. @subsection erode
  6156. Erode an image by using a specific structuring element.
  6157. It corresponds to the libopencv function @code{cvErode}.
  6158. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  6159. with the same syntax and semantics as the @ref{dilate} filter.
  6160. @subsection smooth
  6161. Smooth the input video.
  6162. The filter takes the following parameters:
  6163. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  6164. @var{type} is the type of smooth filter to apply, and must be one of
  6165. the following values: "blur", "blur_no_scale", "median", "gaussian",
  6166. or "bilateral". The default value is "gaussian".
  6167. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  6168. depend on the smooth type. @var{param1} and
  6169. @var{param2} accept integer positive values or 0. @var{param3} and
  6170. @var{param4} accept floating point values.
  6171. The default value for @var{param1} is 3. The default value for the
  6172. other parameters is 0.
  6173. These parameters correspond to the parameters assigned to the
  6174. libopencv function @code{cvSmooth}.
  6175. @anchor{overlay}
  6176. @section overlay
  6177. Overlay one video on top of another.
  6178. It takes two inputs and has one output. The first input is the "main"
  6179. video on which the second input is overlaid.
  6180. It accepts the following parameters:
  6181. A description of the accepted options follows.
  6182. @table @option
  6183. @item x
  6184. @item y
  6185. Set the expression for the x and y coordinates of the overlaid video
  6186. on the main video. Default value is "0" for both expressions. In case
  6187. the expression is invalid, it is set to a huge value (meaning that the
  6188. overlay will not be displayed within the output visible area).
  6189. @item eof_action
  6190. The action to take when EOF is encountered on the secondary input; it accepts
  6191. one of the following values:
  6192. @table @option
  6193. @item repeat
  6194. Repeat the last frame (the default).
  6195. @item endall
  6196. End both streams.
  6197. @item pass
  6198. Pass the main input through.
  6199. @end table
  6200. @item eval
  6201. Set when the expressions for @option{x}, and @option{y} are evaluated.
  6202. It accepts the following values:
  6203. @table @samp
  6204. @item init
  6205. only evaluate expressions once during the filter initialization or
  6206. when a command is processed
  6207. @item frame
  6208. evaluate expressions for each incoming frame
  6209. @end table
  6210. Default value is @samp{frame}.
  6211. @item shortest
  6212. If set to 1, force the output to terminate when the shortest input
  6213. terminates. Default value is 0.
  6214. @item format
  6215. Set the format for the output video.
  6216. It accepts the following values:
  6217. @table @samp
  6218. @item yuv420
  6219. force YUV420 output
  6220. @item yuv422
  6221. force YUV422 output
  6222. @item yuv444
  6223. force YUV444 output
  6224. @item rgb
  6225. force RGB output
  6226. @end table
  6227. Default value is @samp{yuv420}.
  6228. @item rgb @emph{(deprecated)}
  6229. If set to 1, force the filter to accept inputs in the RGB
  6230. color space. Default value is 0. This option is deprecated, use
  6231. @option{format} instead.
  6232. @item repeatlast
  6233. If set to 1, force the filter to draw the last overlay frame over the
  6234. main input until the end of the stream. A value of 0 disables this
  6235. behavior. Default value is 1.
  6236. @end table
  6237. The @option{x}, and @option{y} expressions can contain the following
  6238. parameters.
  6239. @table @option
  6240. @item main_w, W
  6241. @item main_h, H
  6242. The main input width and height.
  6243. @item overlay_w, w
  6244. @item overlay_h, h
  6245. The overlay input width and height.
  6246. @item x
  6247. @item y
  6248. The computed values for @var{x} and @var{y}. They are evaluated for
  6249. each new frame.
  6250. @item hsub
  6251. @item vsub
  6252. horizontal and vertical chroma subsample values of the output
  6253. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  6254. @var{vsub} is 1.
  6255. @item n
  6256. the number of input frame, starting from 0
  6257. @item pos
  6258. the position in the file of the input frame, NAN if unknown
  6259. @item t
  6260. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  6261. @end table
  6262. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  6263. when evaluation is done @emph{per frame}, and will evaluate to NAN
  6264. when @option{eval} is set to @samp{init}.
  6265. Be aware that frames are taken from each input video in timestamp
  6266. order, hence, if their initial timestamps differ, it is a good idea
  6267. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  6268. have them begin in the same zero timestamp, as the example for
  6269. the @var{movie} filter does.
  6270. You can chain together more overlays but you should test the
  6271. efficiency of such approach.
  6272. @subsection Commands
  6273. This filter supports the following commands:
  6274. @table @option
  6275. @item x
  6276. @item y
  6277. Modify the x and y of the overlay input.
  6278. The command accepts the same syntax of the corresponding option.
  6279. If the specified expression is not valid, it is kept at its current
  6280. value.
  6281. @end table
  6282. @subsection Examples
  6283. @itemize
  6284. @item
  6285. Draw the overlay at 10 pixels from the bottom right corner of the main
  6286. video:
  6287. @example
  6288. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  6289. @end example
  6290. Using named options the example above becomes:
  6291. @example
  6292. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  6293. @end example
  6294. @item
  6295. Insert a transparent PNG logo in the bottom left corner of the input,
  6296. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  6297. @example
  6298. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  6299. @end example
  6300. @item
  6301. Insert 2 different transparent PNG logos (second logo on bottom
  6302. right corner) using the @command{ffmpeg} tool:
  6303. @example
  6304. 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
  6305. @end example
  6306. @item
  6307. Add a transparent color layer on top of the main video; @code{WxH}
  6308. must specify the size of the main input to the overlay filter:
  6309. @example
  6310. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  6311. @end example
  6312. @item
  6313. Play an original video and a filtered version (here with the deshake
  6314. filter) side by side using the @command{ffplay} tool:
  6315. @example
  6316. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  6317. @end example
  6318. The above command is the same as:
  6319. @example
  6320. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  6321. @end example
  6322. @item
  6323. Make a sliding overlay appearing from the left to the right top part of the
  6324. screen starting since time 2:
  6325. @example
  6326. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  6327. @end example
  6328. @item
  6329. Compose output by putting two input videos side to side:
  6330. @example
  6331. ffmpeg -i left.avi -i right.avi -filter_complex "
  6332. nullsrc=size=200x100 [background];
  6333. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  6334. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  6335. [background][left] overlay=shortest=1 [background+left];
  6336. [background+left][right] overlay=shortest=1:x=100 [left+right]
  6337. "
  6338. @end example
  6339. @item
  6340. Mask 10-20 seconds of a video by applying the delogo filter to a section
  6341. @example
  6342. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6343. -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]'
  6344. masked.avi
  6345. @end example
  6346. @item
  6347. Chain several overlays in cascade:
  6348. @example
  6349. nullsrc=s=200x200 [bg];
  6350. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6351. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6352. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6353. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6354. [in3] null, [mid2] overlay=100:100 [out0]
  6355. @end example
  6356. @end itemize
  6357. @section owdenoise
  6358. Apply Overcomplete Wavelet denoiser.
  6359. The filter accepts the following options:
  6360. @table @option
  6361. @item depth
  6362. Set depth.
  6363. Larger depth values will denoise lower frequency components more, but
  6364. slow down filtering.
  6365. Must be an int in the range 8-16, default is @code{8}.
  6366. @item luma_strength, ls
  6367. Set luma strength.
  6368. Must be a double value in the range 0-1000, default is @code{1.0}.
  6369. @item chroma_strength, cs
  6370. Set chroma strength.
  6371. Must be a double value in the range 0-1000, default is @code{1.0}.
  6372. @end table
  6373. @anchor{pad}
  6374. @section pad
  6375. Add paddings to the input image, and place the original input at the
  6376. provided @var{x}, @var{y} coordinates.
  6377. It accepts the following parameters:
  6378. @table @option
  6379. @item width, w
  6380. @item height, h
  6381. Specify an expression for the size of the output image with the
  6382. paddings added. If the value for @var{width} or @var{height} is 0, the
  6383. corresponding input size is used for the output.
  6384. The @var{width} expression can reference the value set by the
  6385. @var{height} expression, and vice versa.
  6386. The default value of @var{width} and @var{height} is 0.
  6387. @item x
  6388. @item y
  6389. Specify the offsets to place the input image at within the padded area,
  6390. with respect to the top/left border of the output image.
  6391. The @var{x} expression can reference the value set by the @var{y}
  6392. expression, and vice versa.
  6393. The default value of @var{x} and @var{y} is 0.
  6394. @item color
  6395. Specify the color of the padded area. For the syntax of this option,
  6396. check the "Color" section in the ffmpeg-utils manual.
  6397. The default value of @var{color} is "black".
  6398. @end table
  6399. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6400. options are expressions containing the following constants:
  6401. @table @option
  6402. @item in_w
  6403. @item in_h
  6404. The input video width and height.
  6405. @item iw
  6406. @item ih
  6407. These are the same as @var{in_w} and @var{in_h}.
  6408. @item out_w
  6409. @item out_h
  6410. The output width and height (the size of the padded area), as
  6411. specified by the @var{width} and @var{height} expressions.
  6412. @item ow
  6413. @item oh
  6414. These are the same as @var{out_w} and @var{out_h}.
  6415. @item x
  6416. @item y
  6417. The x and y offsets as specified by the @var{x} and @var{y}
  6418. expressions, or NAN if not yet specified.
  6419. @item a
  6420. same as @var{iw} / @var{ih}
  6421. @item sar
  6422. input sample aspect ratio
  6423. @item dar
  6424. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6425. @item hsub
  6426. @item vsub
  6427. The horizontal and vertical chroma subsample values. For example for the
  6428. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6429. @end table
  6430. @subsection Examples
  6431. @itemize
  6432. @item
  6433. Add paddings with the color "violet" to the input video. The output video
  6434. size is 640x480, and the top-left corner of the input video is placed at
  6435. column 0, row 40
  6436. @example
  6437. pad=640:480:0:40:violet
  6438. @end example
  6439. The example above is equivalent to the following command:
  6440. @example
  6441. pad=width=640:height=480:x=0:y=40:color=violet
  6442. @end example
  6443. @item
  6444. Pad the input to get an output with dimensions increased by 3/2,
  6445. and put the input video at the center of the padded area:
  6446. @example
  6447. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6448. @end example
  6449. @item
  6450. Pad the input to get a squared output with size equal to the maximum
  6451. value between the input width and height, and put the input video at
  6452. the center of the padded area:
  6453. @example
  6454. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6455. @end example
  6456. @item
  6457. Pad the input to get a final w/h ratio of 16:9:
  6458. @example
  6459. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6460. @end example
  6461. @item
  6462. In case of anamorphic video, in order to set the output display aspect
  6463. correctly, it is necessary to use @var{sar} in the expression,
  6464. according to the relation:
  6465. @example
  6466. (ih * X / ih) * sar = output_dar
  6467. X = output_dar / sar
  6468. @end example
  6469. Thus the previous example needs to be modified to:
  6470. @example
  6471. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6472. @end example
  6473. @item
  6474. Double the output size and put the input video in the bottom-right
  6475. corner of the output padded area:
  6476. @example
  6477. pad="2*iw:2*ih:ow-iw:oh-ih"
  6478. @end example
  6479. @end itemize
  6480. @anchor{palettegen}
  6481. @section palettegen
  6482. Generate one palette for a whole video stream.
  6483. It accepts the following options:
  6484. @table @option
  6485. @item max_colors
  6486. Set the maximum number of colors to quantize in the palette.
  6487. Note: the palette will still contain 256 colors; the unused palette entries
  6488. will be black.
  6489. @item reserve_transparent
  6490. Create a palette of 255 colors maximum and reserve the last one for
  6491. transparency. Reserving the transparency color is useful for GIF optimization.
  6492. If not set, the maximum of colors in the palette will be 256. You probably want
  6493. to disable this option for a standalone image.
  6494. Set by default.
  6495. @item stats_mode
  6496. Set statistics mode.
  6497. It accepts the following values:
  6498. @table @samp
  6499. @item full
  6500. Compute full frame histograms.
  6501. @item diff
  6502. Compute histograms only for the part that differs from previous frame. This
  6503. might be relevant to give more importance to the moving part of your input if
  6504. the background is static.
  6505. @end table
  6506. Default value is @var{full}.
  6507. @end table
  6508. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6509. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6510. color quantization of the palette. This information is also visible at
  6511. @var{info} logging level.
  6512. @subsection Examples
  6513. @itemize
  6514. @item
  6515. Generate a representative palette of a given video using @command{ffmpeg}:
  6516. @example
  6517. ffmpeg -i input.mkv -vf palettegen palette.png
  6518. @end example
  6519. @end itemize
  6520. @section paletteuse
  6521. Use a palette to downsample an input video stream.
  6522. The filter takes two inputs: one video stream and a palette. The palette must
  6523. be a 256 pixels image.
  6524. It accepts the following options:
  6525. @table @option
  6526. @item dither
  6527. Select dithering mode. Available algorithms are:
  6528. @table @samp
  6529. @item bayer
  6530. Ordered 8x8 bayer dithering (deterministic)
  6531. @item heckbert
  6532. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6533. Note: this dithering is sometimes considered "wrong" and is included as a
  6534. reference.
  6535. @item floyd_steinberg
  6536. Floyd and Steingberg dithering (error diffusion)
  6537. @item sierra2
  6538. Frankie Sierra dithering v2 (error diffusion)
  6539. @item sierra2_4a
  6540. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6541. @end table
  6542. Default is @var{sierra2_4a}.
  6543. @item bayer_scale
  6544. When @var{bayer} dithering is selected, this option defines the scale of the
  6545. pattern (how much the crosshatch pattern is visible). A low value means more
  6546. visible pattern for less banding, and higher value means less visible pattern
  6547. at the cost of more banding.
  6548. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6549. @item diff_mode
  6550. If set, define the zone to process
  6551. @table @samp
  6552. @item rectangle
  6553. Only the changing rectangle will be reprocessed. This is similar to GIF
  6554. cropping/offsetting compression mechanism. This option can be useful for speed
  6555. if only a part of the image is changing, and has use cases such as limiting the
  6556. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6557. moving scene (it leads to more deterministic output if the scene doesn't change
  6558. much, and as a result less moving noise and better GIF compression).
  6559. @end table
  6560. Default is @var{none}.
  6561. @end table
  6562. @subsection Examples
  6563. @itemize
  6564. @item
  6565. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6566. using @command{ffmpeg}:
  6567. @example
  6568. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6569. @end example
  6570. @end itemize
  6571. @section perspective
  6572. Correct perspective of video not recorded perpendicular to the screen.
  6573. A description of the accepted parameters follows.
  6574. @table @option
  6575. @item x0
  6576. @item y0
  6577. @item x1
  6578. @item y1
  6579. @item x2
  6580. @item y2
  6581. @item x3
  6582. @item y3
  6583. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6584. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6585. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6586. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6587. then the corners of the source will be sent to the specified coordinates.
  6588. The expressions can use the following variables:
  6589. @table @option
  6590. @item W
  6591. @item H
  6592. the width and height of video frame.
  6593. @end table
  6594. @item interpolation
  6595. Set interpolation for perspective correction.
  6596. It accepts the following values:
  6597. @table @samp
  6598. @item linear
  6599. @item cubic
  6600. @end table
  6601. Default value is @samp{linear}.
  6602. @item sense
  6603. Set interpretation of coordinate options.
  6604. It accepts the following values:
  6605. @table @samp
  6606. @item 0, source
  6607. Send point in the source specified by the given coordinates to
  6608. the corners of the destination.
  6609. @item 1, destination
  6610. Send the corners of the source to the point in the destination specified
  6611. by the given coordinates.
  6612. Default value is @samp{source}.
  6613. @end table
  6614. @end table
  6615. @section phase
  6616. Delay interlaced video by one field time so that the field order changes.
  6617. The intended use is to fix PAL movies that have been captured with the
  6618. opposite field order to the film-to-video transfer.
  6619. A description of the accepted parameters follows.
  6620. @table @option
  6621. @item mode
  6622. Set phase mode.
  6623. It accepts the following values:
  6624. @table @samp
  6625. @item t
  6626. Capture field order top-first, transfer bottom-first.
  6627. Filter will delay the bottom field.
  6628. @item b
  6629. Capture field order bottom-first, transfer top-first.
  6630. Filter will delay the top field.
  6631. @item p
  6632. Capture and transfer with the same field order. This mode only exists
  6633. for the documentation of the other options to refer to, but if you
  6634. actually select it, the filter will faithfully do nothing.
  6635. @item a
  6636. Capture field order determined automatically by field flags, transfer
  6637. opposite.
  6638. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6639. basis using field flags. If no field information is available,
  6640. then this works just like @samp{u}.
  6641. @item u
  6642. Capture unknown or varying, transfer opposite.
  6643. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6644. analyzing the images and selecting the alternative that produces best
  6645. match between the fields.
  6646. @item T
  6647. Capture top-first, transfer unknown or varying.
  6648. Filter selects among @samp{t} and @samp{p} using image analysis.
  6649. @item B
  6650. Capture bottom-first, transfer unknown or varying.
  6651. Filter selects among @samp{b} and @samp{p} using image analysis.
  6652. @item A
  6653. Capture determined by field flags, transfer unknown or varying.
  6654. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6655. image analysis. If no field information is available, then this works just
  6656. like @samp{U}. This is the default mode.
  6657. @item U
  6658. Both capture and transfer unknown or varying.
  6659. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6660. @end table
  6661. @end table
  6662. @section pixdesctest
  6663. Pixel format descriptor test filter, mainly useful for internal
  6664. testing. The output video should be equal to the input video.
  6665. For example:
  6666. @example
  6667. format=monow, pixdesctest
  6668. @end example
  6669. can be used to test the monowhite pixel format descriptor definition.
  6670. @section pp
  6671. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6672. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6673. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6674. Each subfilter and some options have a short and a long name that can be used
  6675. interchangeably, i.e. dr/dering are the same.
  6676. The filters accept the following options:
  6677. @table @option
  6678. @item subfilters
  6679. Set postprocessing subfilters string.
  6680. @end table
  6681. All subfilters share common options to determine their scope:
  6682. @table @option
  6683. @item a/autoq
  6684. Honor the quality commands for this subfilter.
  6685. @item c/chrom
  6686. Do chrominance filtering, too (default).
  6687. @item y/nochrom
  6688. Do luminance filtering only (no chrominance).
  6689. @item n/noluma
  6690. Do chrominance filtering only (no luminance).
  6691. @end table
  6692. These options can be appended after the subfilter name, separated by a '|'.
  6693. Available subfilters are:
  6694. @table @option
  6695. @item hb/hdeblock[|difference[|flatness]]
  6696. Horizontal deblocking filter
  6697. @table @option
  6698. @item difference
  6699. Difference factor where higher values mean more deblocking (default: @code{32}).
  6700. @item flatness
  6701. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6702. @end table
  6703. @item vb/vdeblock[|difference[|flatness]]
  6704. Vertical deblocking filter
  6705. @table @option
  6706. @item difference
  6707. Difference factor where higher values mean more deblocking (default: @code{32}).
  6708. @item flatness
  6709. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6710. @end table
  6711. @item ha/hadeblock[|difference[|flatness]]
  6712. Accurate horizontal deblocking filter
  6713. @table @option
  6714. @item difference
  6715. Difference factor where higher values mean more deblocking (default: @code{32}).
  6716. @item flatness
  6717. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6718. @end table
  6719. @item va/vadeblock[|difference[|flatness]]
  6720. Accurate vertical deblocking filter
  6721. @table @option
  6722. @item difference
  6723. Difference factor where higher values mean more deblocking (default: @code{32}).
  6724. @item flatness
  6725. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6726. @end table
  6727. @end table
  6728. The horizontal and vertical deblocking filters share the difference and
  6729. flatness values so you cannot set different horizontal and vertical
  6730. thresholds.
  6731. @table @option
  6732. @item h1/x1hdeblock
  6733. Experimental horizontal deblocking filter
  6734. @item v1/x1vdeblock
  6735. Experimental vertical deblocking filter
  6736. @item dr/dering
  6737. Deringing filter
  6738. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6739. @table @option
  6740. @item threshold1
  6741. larger -> stronger filtering
  6742. @item threshold2
  6743. larger -> stronger filtering
  6744. @item threshold3
  6745. larger -> stronger filtering
  6746. @end table
  6747. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6748. @table @option
  6749. @item f/fullyrange
  6750. Stretch luminance to @code{0-255}.
  6751. @end table
  6752. @item lb/linblenddeint
  6753. Linear blend deinterlacing filter that deinterlaces the given block by
  6754. filtering all lines with a @code{(1 2 1)} filter.
  6755. @item li/linipoldeint
  6756. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6757. linearly interpolating every second line.
  6758. @item ci/cubicipoldeint
  6759. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6760. cubically interpolating every second line.
  6761. @item md/mediandeint
  6762. Median deinterlacing filter that deinterlaces the given block by applying a
  6763. median filter to every second line.
  6764. @item fd/ffmpegdeint
  6765. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6766. second line with a @code{(-1 4 2 4 -1)} filter.
  6767. @item l5/lowpass5
  6768. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6769. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6770. @item fq/forceQuant[|quantizer]
  6771. Overrides the quantizer table from the input with the constant quantizer you
  6772. specify.
  6773. @table @option
  6774. @item quantizer
  6775. Quantizer to use
  6776. @end table
  6777. @item de/default
  6778. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6779. @item fa/fast
  6780. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6781. @item ac
  6782. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6783. @end table
  6784. @subsection Examples
  6785. @itemize
  6786. @item
  6787. Apply horizontal and vertical deblocking, deringing and automatic
  6788. brightness/contrast:
  6789. @example
  6790. pp=hb/vb/dr/al
  6791. @end example
  6792. @item
  6793. Apply default filters without brightness/contrast correction:
  6794. @example
  6795. pp=de/-al
  6796. @end example
  6797. @item
  6798. Apply default filters and temporal denoiser:
  6799. @example
  6800. pp=default/tmpnoise|1|2|3
  6801. @end example
  6802. @item
  6803. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6804. automatically depending on available CPU time:
  6805. @example
  6806. pp=hb|y/vb|a
  6807. @end example
  6808. @end itemize
  6809. @section pp7
  6810. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6811. similar to spp = 6 with 7 point DCT, where only the center sample is
  6812. used after IDCT.
  6813. The filter accepts the following options:
  6814. @table @option
  6815. @item qp
  6816. Force a constant quantization parameter. It accepts an integer in range
  6817. 0 to 63. If not set, the filter will use the QP from the video stream
  6818. (if available).
  6819. @item mode
  6820. Set thresholding mode. Available modes are:
  6821. @table @samp
  6822. @item hard
  6823. Set hard thresholding.
  6824. @item soft
  6825. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6826. @item medium
  6827. Set medium thresholding (good results, default).
  6828. @end table
  6829. @end table
  6830. @section psnr
  6831. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6832. Ratio) between two input videos.
  6833. This filter takes in input two input videos, the first input is
  6834. considered the "main" source and is passed unchanged to the
  6835. output. The second input is used as a "reference" video for computing
  6836. the PSNR.
  6837. Both video inputs must have the same resolution and pixel format for
  6838. this filter to work correctly. Also it assumes that both inputs
  6839. have the same number of frames, which are compared one by one.
  6840. The obtained average PSNR is printed through the logging system.
  6841. The filter stores the accumulated MSE (mean squared error) of each
  6842. frame, and at the end of the processing it is averaged across all frames
  6843. equally, and the following formula is applied to obtain the PSNR:
  6844. @example
  6845. PSNR = 10*log10(MAX^2/MSE)
  6846. @end example
  6847. Where MAX is the average of the maximum values of each component of the
  6848. image.
  6849. The description of the accepted parameters follows.
  6850. @table @option
  6851. @item stats_file, f
  6852. If specified the filter will use the named file to save the PSNR of
  6853. each individual frame. When filename equals "-" the data is sent to
  6854. standard output.
  6855. @end table
  6856. The file printed if @var{stats_file} is selected, contains a sequence of
  6857. key/value pairs of the form @var{key}:@var{value} for each compared
  6858. couple of frames.
  6859. A description of each shown parameter follows:
  6860. @table @option
  6861. @item n
  6862. sequential number of the input frame, starting from 1
  6863. @item mse_avg
  6864. Mean Square Error pixel-by-pixel average difference of the compared
  6865. frames, averaged over all the image components.
  6866. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6867. Mean Square Error pixel-by-pixel average difference of the compared
  6868. frames for the component specified by the suffix.
  6869. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6870. Peak Signal to Noise ratio of the compared frames for the component
  6871. specified by the suffix.
  6872. @end table
  6873. For example:
  6874. @example
  6875. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6876. [main][ref] psnr="stats_file=stats.log" [out]
  6877. @end example
  6878. On this example the input file being processed is compared with the
  6879. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6880. is stored in @file{stats.log}.
  6881. @anchor{pullup}
  6882. @section pullup
  6883. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6884. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6885. content.
  6886. The pullup filter is designed to take advantage of future context in making
  6887. its decisions. This filter is stateless in the sense that it does not lock
  6888. onto a pattern to follow, but it instead looks forward to the following
  6889. fields in order to identify matches and rebuild progressive frames.
  6890. To produce content with an even framerate, insert the fps filter after
  6891. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6892. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6893. The filter accepts the following options:
  6894. @table @option
  6895. @item jl
  6896. @item jr
  6897. @item jt
  6898. @item jb
  6899. These options set the amount of "junk" to ignore at the left, right, top, and
  6900. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6901. while top and bottom are in units of 2 lines.
  6902. The default is 8 pixels on each side.
  6903. @item sb
  6904. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6905. filter generating an occasional mismatched frame, but it may also cause an
  6906. excessive number of frames to be dropped during high motion sequences.
  6907. Conversely, setting it to -1 will make filter match fields more easily.
  6908. This may help processing of video where there is slight blurring between
  6909. the fields, but may also cause there to be interlaced frames in the output.
  6910. Default value is @code{0}.
  6911. @item mp
  6912. Set the metric plane to use. It accepts the following values:
  6913. @table @samp
  6914. @item l
  6915. Use luma plane.
  6916. @item u
  6917. Use chroma blue plane.
  6918. @item v
  6919. Use chroma red plane.
  6920. @end table
  6921. This option may be set to use chroma plane instead of the default luma plane
  6922. for doing filter's computations. This may improve accuracy on very clean
  6923. source material, but more likely will decrease accuracy, especially if there
  6924. is chroma noise (rainbow effect) or any grayscale video.
  6925. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6926. load and make pullup usable in realtime on slow machines.
  6927. @end table
  6928. For best results (without duplicated frames in the output file) it is
  6929. necessary to change the output frame rate. For example, to inverse
  6930. telecine NTSC input:
  6931. @example
  6932. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6933. @end example
  6934. @section qp
  6935. Change video quantization parameters (QP).
  6936. The filter accepts the following option:
  6937. @table @option
  6938. @item qp
  6939. Set expression for quantization parameter.
  6940. @end table
  6941. The expression is evaluated through the eval API and can contain, among others,
  6942. the following constants:
  6943. @table @var
  6944. @item known
  6945. 1 if index is not 129, 0 otherwise.
  6946. @item qp
  6947. Sequentional index starting from -129 to 128.
  6948. @end table
  6949. @subsection Examples
  6950. @itemize
  6951. @item
  6952. Some equation like:
  6953. @example
  6954. qp=2+2*sin(PI*qp)
  6955. @end example
  6956. @end itemize
  6957. @section random
  6958. Flush video frames from internal cache of frames into a random order.
  6959. No frame is discarded.
  6960. Inspired by @ref{frei0r} nervous filter.
  6961. @table @option
  6962. @item frames
  6963. Set size in number of frames of internal cache, in range from @code{2} to
  6964. @code{512}. Default is @code{30}.
  6965. @item seed
  6966. Set seed for random number generator, must be an integer included between
  6967. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6968. less than @code{0}, the filter will try to use a good random seed on a
  6969. best effort basis.
  6970. @end table
  6971. @section removegrain
  6972. The removegrain filter is a spatial denoiser for progressive video.
  6973. @table @option
  6974. @item m0
  6975. Set mode for the first plane.
  6976. @item m1
  6977. Set mode for the second plane.
  6978. @item m2
  6979. Set mode for the third plane.
  6980. @item m3
  6981. Set mode for the fourth plane.
  6982. @end table
  6983. Range of mode is from 0 to 24. Description of each mode follows:
  6984. @table @var
  6985. @item 0
  6986. Leave input plane unchanged. Default.
  6987. @item 1
  6988. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6989. @item 2
  6990. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6991. @item 3
  6992. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6993. @item 4
  6994. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6995. This is equivalent to a median filter.
  6996. @item 5
  6997. Line-sensitive clipping giving the minimal change.
  6998. @item 6
  6999. Line-sensitive clipping, intermediate.
  7000. @item 7
  7001. Line-sensitive clipping, intermediate.
  7002. @item 8
  7003. Line-sensitive clipping, intermediate.
  7004. @item 9
  7005. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7006. @item 10
  7007. Replaces the target pixel with the closest neighbour.
  7008. @item 11
  7009. [1 2 1] horizontal and vertical kernel blur.
  7010. @item 12
  7011. Same as mode 11.
  7012. @item 13
  7013. Bob mode, interpolates top field from the line where the neighbours
  7014. pixels are the closest.
  7015. @item 14
  7016. Bob mode, interpolates bottom field from the line where the neighbours
  7017. pixels are the closest.
  7018. @item 15
  7019. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7020. interpolation formula.
  7021. @item 16
  7022. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7023. interpolation formula.
  7024. @item 17
  7025. Clips the pixel with the minimum and maximum of respectively the maximum and
  7026. minimum of each pair of opposite neighbour pixels.
  7027. @item 18
  7028. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7029. the current pixel is minimal.
  7030. @item 19
  7031. Replaces the pixel with the average of its 8 neighbours.
  7032. @item 20
  7033. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7034. @item 21
  7035. Clips pixels using the averages of opposite neighbour.
  7036. @item 22
  7037. Same as mode 21 but simpler and faster.
  7038. @item 23
  7039. Small edge and halo removal, but reputed useless.
  7040. @item 24
  7041. Similar as 23.
  7042. @end table
  7043. @section removelogo
  7044. Suppress a TV station logo, using an image file to determine which
  7045. pixels comprise the logo. It works by filling in the pixels that
  7046. comprise the logo with neighboring pixels.
  7047. The filter accepts the following options:
  7048. @table @option
  7049. @item filename, f
  7050. Set the filter bitmap file, which can be any image format supported by
  7051. libavformat. The width and height of the image file must match those of the
  7052. video stream being processed.
  7053. @end table
  7054. Pixels in the provided bitmap image with a value of zero are not
  7055. considered part of the logo, non-zero pixels are considered part of
  7056. the logo. If you use white (255) for the logo and black (0) for the
  7057. rest, you will be safe. For making the filter bitmap, it is
  7058. recommended to take a screen capture of a black frame with the logo
  7059. visible, and then using a threshold filter followed by the erode
  7060. filter once or twice.
  7061. If needed, little splotches can be fixed manually. Remember that if
  7062. logo pixels are not covered, the filter quality will be much
  7063. reduced. Marking too many pixels as part of the logo does not hurt as
  7064. much, but it will increase the amount of blurring needed to cover over
  7065. the image and will destroy more information than necessary, and extra
  7066. pixels will slow things down on a large logo.
  7067. @section repeatfields
  7068. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7069. fields based on its value.
  7070. @section reverse, areverse
  7071. Reverse a clip.
  7072. Warning: This filter requires memory to buffer the entire clip, so trimming
  7073. is suggested.
  7074. @subsection Examples
  7075. @itemize
  7076. @item
  7077. Take the first 5 seconds of a clip, and reverse it.
  7078. @example
  7079. trim=end=5,reverse
  7080. @end example
  7081. @end itemize
  7082. @section rotate
  7083. Rotate video by an arbitrary angle expressed in radians.
  7084. The filter accepts the following options:
  7085. A description of the optional parameters follows.
  7086. @table @option
  7087. @item angle, a
  7088. Set an expression for the angle by which to rotate the input video
  7089. clockwise, expressed as a number of radians. A negative value will
  7090. result in a counter-clockwise rotation. By default it is set to "0".
  7091. This expression is evaluated for each frame.
  7092. @item out_w, ow
  7093. Set the output width expression, default value is "iw".
  7094. This expression is evaluated just once during configuration.
  7095. @item out_h, oh
  7096. Set the output height expression, default value is "ih".
  7097. This expression is evaluated just once during configuration.
  7098. @item bilinear
  7099. Enable bilinear interpolation if set to 1, a value of 0 disables
  7100. it. Default value is 1.
  7101. @item fillcolor, c
  7102. Set the color used to fill the output area not covered by the rotated
  7103. image. For the general syntax of this option, check the "Color" section in the
  7104. ffmpeg-utils manual. If the special value "none" is selected then no
  7105. background is printed (useful for example if the background is never shown).
  7106. Default value is "black".
  7107. @end table
  7108. The expressions for the angle and the output size can contain the
  7109. following constants and functions:
  7110. @table @option
  7111. @item n
  7112. sequential number of the input frame, starting from 0. It is always NAN
  7113. before the first frame is filtered.
  7114. @item t
  7115. time in seconds of the input frame, it is set to 0 when the filter is
  7116. configured. It is always NAN before the first frame is filtered.
  7117. @item hsub
  7118. @item vsub
  7119. horizontal and vertical chroma subsample values. For example for the
  7120. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7121. @item in_w, iw
  7122. @item in_h, ih
  7123. the input video width and height
  7124. @item out_w, ow
  7125. @item out_h, oh
  7126. the output width and height, that is the size of the padded area as
  7127. specified by the @var{width} and @var{height} expressions
  7128. @item rotw(a)
  7129. @item roth(a)
  7130. the minimal width/height required for completely containing the input
  7131. video rotated by @var{a} radians.
  7132. These are only available when computing the @option{out_w} and
  7133. @option{out_h} expressions.
  7134. @end table
  7135. @subsection Examples
  7136. @itemize
  7137. @item
  7138. Rotate the input by PI/6 radians clockwise:
  7139. @example
  7140. rotate=PI/6
  7141. @end example
  7142. @item
  7143. Rotate the input by PI/6 radians counter-clockwise:
  7144. @example
  7145. rotate=-PI/6
  7146. @end example
  7147. @item
  7148. Rotate the input by 45 degrees clockwise:
  7149. @example
  7150. rotate=45*PI/180
  7151. @end example
  7152. @item
  7153. Apply a constant rotation with period T, starting from an angle of PI/3:
  7154. @example
  7155. rotate=PI/3+2*PI*t/T
  7156. @end example
  7157. @item
  7158. Make the input video rotation oscillating with a period of T
  7159. seconds and an amplitude of A radians:
  7160. @example
  7161. rotate=A*sin(2*PI/T*t)
  7162. @end example
  7163. @item
  7164. Rotate the video, output size is chosen so that the whole rotating
  7165. input video is always completely contained in the output:
  7166. @example
  7167. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  7168. @end example
  7169. @item
  7170. Rotate the video, reduce the output size so that no background is ever
  7171. shown:
  7172. @example
  7173. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  7174. @end example
  7175. @end itemize
  7176. @subsection Commands
  7177. The filter supports the following commands:
  7178. @table @option
  7179. @item a, angle
  7180. Set the angle expression.
  7181. The command accepts the same syntax of the corresponding option.
  7182. If the specified expression is not valid, it is kept at its current
  7183. value.
  7184. @end table
  7185. @section sab
  7186. Apply Shape Adaptive Blur.
  7187. The filter accepts the following options:
  7188. @table @option
  7189. @item luma_radius, lr
  7190. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  7191. value is 1.0. A greater value will result in a more blurred image, and
  7192. in slower processing.
  7193. @item luma_pre_filter_radius, lpfr
  7194. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  7195. value is 1.0.
  7196. @item luma_strength, ls
  7197. Set luma maximum difference between pixels to still be considered, must
  7198. be a value in the 0.1-100.0 range, default value is 1.0.
  7199. @item chroma_radius, cr
  7200. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  7201. greater value will result in a more blurred image, and in slower
  7202. processing.
  7203. @item chroma_pre_filter_radius, cpfr
  7204. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  7205. @item chroma_strength, cs
  7206. Set chroma maximum difference between pixels to still be considered,
  7207. must be a value in the 0.1-100.0 range.
  7208. @end table
  7209. Each chroma option value, if not explicitly specified, is set to the
  7210. corresponding luma option value.
  7211. @anchor{scale}
  7212. @section scale
  7213. Scale (resize) the input video, using the libswscale library.
  7214. The scale filter forces the output display aspect ratio to be the same
  7215. of the input, by changing the output sample aspect ratio.
  7216. If the input image format is different from the format requested by
  7217. the next filter, the scale filter will convert the input to the
  7218. requested format.
  7219. @subsection Options
  7220. The filter accepts the following options, or any of the options
  7221. supported by the libswscale scaler.
  7222. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  7223. the complete list of scaler options.
  7224. @table @option
  7225. @item width, w
  7226. @item height, h
  7227. Set the output video dimension expression. Default value is the input
  7228. dimension.
  7229. If the value is 0, the input width is used for the output.
  7230. If one of the values is -1, the scale filter will use a value that
  7231. maintains the aspect ratio of the input image, calculated from the
  7232. other specified dimension. If both of them are -1, the input size is
  7233. used
  7234. If one of the values is -n with n > 1, the scale filter will also use a value
  7235. that maintains the aspect ratio of the input image, calculated from the other
  7236. specified dimension. After that it will, however, make sure that the calculated
  7237. dimension is divisible by n and adjust the value if necessary.
  7238. See below for the list of accepted constants for use in the dimension
  7239. expression.
  7240. @item interl
  7241. Set the interlacing mode. It accepts the following values:
  7242. @table @samp
  7243. @item 1
  7244. Force interlaced aware scaling.
  7245. @item 0
  7246. Do not apply interlaced scaling.
  7247. @item -1
  7248. Select interlaced aware scaling depending on whether the source frames
  7249. are flagged as interlaced or not.
  7250. @end table
  7251. Default value is @samp{0}.
  7252. @item flags
  7253. Set libswscale scaling flags. See
  7254. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  7255. complete list of values. If not explicitly specified the filter applies
  7256. the default flags.
  7257. @item size, s
  7258. Set the video size. For the syntax of this option, check the
  7259. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7260. @item in_color_matrix
  7261. @item out_color_matrix
  7262. Set in/output YCbCr color space type.
  7263. This allows the autodetected value to be overridden as well as allows forcing
  7264. a specific value used for the output and encoder.
  7265. If not specified, the color space type depends on the pixel format.
  7266. Possible values:
  7267. @table @samp
  7268. @item auto
  7269. Choose automatically.
  7270. @item bt709
  7271. Format conforming to International Telecommunication Union (ITU)
  7272. Recommendation BT.709.
  7273. @item fcc
  7274. Set color space conforming to the United States Federal Communications
  7275. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  7276. @item bt601
  7277. Set color space conforming to:
  7278. @itemize
  7279. @item
  7280. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  7281. @item
  7282. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  7283. @item
  7284. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  7285. @end itemize
  7286. @item smpte240m
  7287. Set color space conforming to SMPTE ST 240:1999.
  7288. @end table
  7289. @item in_range
  7290. @item out_range
  7291. Set in/output YCbCr sample range.
  7292. This allows the autodetected value to be overridden as well as allows forcing
  7293. a specific value used for the output and encoder. If not specified, the
  7294. range depends on the pixel format. Possible values:
  7295. @table @samp
  7296. @item auto
  7297. Choose automatically.
  7298. @item jpeg/full/pc
  7299. Set full range (0-255 in case of 8-bit luma).
  7300. @item mpeg/tv
  7301. Set "MPEG" range (16-235 in case of 8-bit luma).
  7302. @end table
  7303. @item force_original_aspect_ratio
  7304. Enable decreasing or increasing output video width or height if necessary to
  7305. keep the original aspect ratio. Possible values:
  7306. @table @samp
  7307. @item disable
  7308. Scale the video as specified and disable this feature.
  7309. @item decrease
  7310. The output video dimensions will automatically be decreased if needed.
  7311. @item increase
  7312. The output video dimensions will automatically be increased if needed.
  7313. @end table
  7314. One useful instance of this option is that when you know a specific device's
  7315. maximum allowed resolution, you can use this to limit the output video to
  7316. that, while retaining the aspect ratio. For example, device A allows
  7317. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  7318. decrease) and specifying 1280x720 to the command line makes the output
  7319. 1280x533.
  7320. Please note that this is a different thing than specifying -1 for @option{w}
  7321. or @option{h}, you still need to specify the output resolution for this option
  7322. to work.
  7323. @end table
  7324. The values of the @option{w} and @option{h} options are expressions
  7325. containing the following constants:
  7326. @table @var
  7327. @item in_w
  7328. @item in_h
  7329. The input width and height
  7330. @item iw
  7331. @item ih
  7332. These are the same as @var{in_w} and @var{in_h}.
  7333. @item out_w
  7334. @item out_h
  7335. The output (scaled) width and height
  7336. @item ow
  7337. @item oh
  7338. These are the same as @var{out_w} and @var{out_h}
  7339. @item a
  7340. The same as @var{iw} / @var{ih}
  7341. @item sar
  7342. input sample aspect ratio
  7343. @item dar
  7344. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7345. @item hsub
  7346. @item vsub
  7347. horizontal and vertical input chroma subsample values. For example for the
  7348. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7349. @item ohsub
  7350. @item ovsub
  7351. horizontal and vertical output chroma subsample values. For example for the
  7352. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7353. @end table
  7354. @subsection Examples
  7355. @itemize
  7356. @item
  7357. Scale the input video to a size of 200x100
  7358. @example
  7359. scale=w=200:h=100
  7360. @end example
  7361. This is equivalent to:
  7362. @example
  7363. scale=200:100
  7364. @end example
  7365. or:
  7366. @example
  7367. scale=200x100
  7368. @end example
  7369. @item
  7370. Specify a size abbreviation for the output size:
  7371. @example
  7372. scale=qcif
  7373. @end example
  7374. which can also be written as:
  7375. @example
  7376. scale=size=qcif
  7377. @end example
  7378. @item
  7379. Scale the input to 2x:
  7380. @example
  7381. scale=w=2*iw:h=2*ih
  7382. @end example
  7383. @item
  7384. The above is the same as:
  7385. @example
  7386. scale=2*in_w:2*in_h
  7387. @end example
  7388. @item
  7389. Scale the input to 2x with forced interlaced scaling:
  7390. @example
  7391. scale=2*iw:2*ih:interl=1
  7392. @end example
  7393. @item
  7394. Scale the input to half size:
  7395. @example
  7396. scale=w=iw/2:h=ih/2
  7397. @end example
  7398. @item
  7399. Increase the width, and set the height to the same size:
  7400. @example
  7401. scale=3/2*iw:ow
  7402. @end example
  7403. @item
  7404. Seek Greek harmony:
  7405. @example
  7406. scale=iw:1/PHI*iw
  7407. scale=ih*PHI:ih
  7408. @end example
  7409. @item
  7410. Increase the height, and set the width to 3/2 of the height:
  7411. @example
  7412. scale=w=3/2*oh:h=3/5*ih
  7413. @end example
  7414. @item
  7415. Increase the size, making the size a multiple of the chroma
  7416. subsample values:
  7417. @example
  7418. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7419. @end example
  7420. @item
  7421. Increase the width to a maximum of 500 pixels,
  7422. keeping the same aspect ratio as the input:
  7423. @example
  7424. scale=w='min(500\, iw*3/2):h=-1'
  7425. @end example
  7426. @end itemize
  7427. @subsection Commands
  7428. This filter supports the following commands:
  7429. @table @option
  7430. @item width, w
  7431. @item height, h
  7432. Set the output video dimension expression.
  7433. The command accepts the same syntax of the corresponding option.
  7434. If the specified expression is not valid, it is kept at its current
  7435. value.
  7436. @end table
  7437. @section scale2ref
  7438. Scale (resize) the input video, based on a reference video.
  7439. See the scale filter for available options, scale2ref supports the same but
  7440. uses the reference video instead of the main input as basis.
  7441. @subsection Examples
  7442. @itemize
  7443. @item
  7444. Scale a subtitle stream to match the main video in size before overlaying
  7445. @example
  7446. 'scale2ref[b][a];[a][b]overlay'
  7447. @end example
  7448. @end itemize
  7449. @section separatefields
  7450. The @code{separatefields} takes a frame-based video input and splits
  7451. each frame into its components fields, producing a new half height clip
  7452. with twice the frame rate and twice the frame count.
  7453. This filter use field-dominance information in frame to decide which
  7454. of each pair of fields to place first in the output.
  7455. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7456. @section setdar, setsar
  7457. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7458. output video.
  7459. This is done by changing the specified Sample (aka Pixel) Aspect
  7460. Ratio, according to the following equation:
  7461. @example
  7462. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7463. @end example
  7464. Keep in mind that the @code{setdar} filter does not modify the pixel
  7465. dimensions of the video frame. Also, the display aspect ratio set by
  7466. this filter may be changed by later filters in the filterchain,
  7467. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7468. applied.
  7469. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7470. the filter output video.
  7471. Note that as a consequence of the application of this filter, the
  7472. output display aspect ratio will change according to the equation
  7473. above.
  7474. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7475. filter may be changed by later filters in the filterchain, e.g. if
  7476. another "setsar" or a "setdar" filter is applied.
  7477. It accepts the following parameters:
  7478. @table @option
  7479. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7480. Set the aspect ratio used by the filter.
  7481. The parameter can be a floating point number string, an expression, or
  7482. a string of the form @var{num}:@var{den}, where @var{num} and
  7483. @var{den} are the numerator and denominator of the aspect ratio. If
  7484. the parameter is not specified, it is assumed the value "0".
  7485. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7486. should be escaped.
  7487. @item max
  7488. Set the maximum integer value to use for expressing numerator and
  7489. denominator when reducing the expressed aspect ratio to a rational.
  7490. Default value is @code{100}.
  7491. @end table
  7492. The parameter @var{sar} is an expression containing
  7493. the following constants:
  7494. @table @option
  7495. @item E, PI, PHI
  7496. These are approximated values for the mathematical constants e
  7497. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7498. @item w, h
  7499. The input width and height.
  7500. @item a
  7501. These are the same as @var{w} / @var{h}.
  7502. @item sar
  7503. The input sample aspect ratio.
  7504. @item dar
  7505. The input display aspect ratio. It is the same as
  7506. (@var{w} / @var{h}) * @var{sar}.
  7507. @item hsub, vsub
  7508. Horizontal and vertical chroma subsample values. For example, for the
  7509. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7510. @end table
  7511. @subsection Examples
  7512. @itemize
  7513. @item
  7514. To change the display aspect ratio to 16:9, specify one of the following:
  7515. @example
  7516. setdar=dar=1.77777
  7517. setdar=dar=16/9
  7518. setdar=dar=1.77777
  7519. @end example
  7520. @item
  7521. To change the sample aspect ratio to 10:11, specify:
  7522. @example
  7523. setsar=sar=10/11
  7524. @end example
  7525. @item
  7526. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7527. 1000 in the aspect ratio reduction, use the command:
  7528. @example
  7529. setdar=ratio=16/9:max=1000
  7530. @end example
  7531. @end itemize
  7532. @anchor{setfield}
  7533. @section setfield
  7534. Force field for the output video frame.
  7535. The @code{setfield} filter marks the interlace type field for the
  7536. output frames. It does not change the input frame, but only sets the
  7537. corresponding property, which affects how the frame is treated by
  7538. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7539. The filter accepts the following options:
  7540. @table @option
  7541. @item mode
  7542. Available values are:
  7543. @table @samp
  7544. @item auto
  7545. Keep the same field property.
  7546. @item bff
  7547. Mark the frame as bottom-field-first.
  7548. @item tff
  7549. Mark the frame as top-field-first.
  7550. @item prog
  7551. Mark the frame as progressive.
  7552. @end table
  7553. @end table
  7554. @section showinfo
  7555. Show a line containing various information for each input video frame.
  7556. The input video is not modified.
  7557. The shown line contains a sequence of key/value pairs of the form
  7558. @var{key}:@var{value}.
  7559. The following values are shown in the output:
  7560. @table @option
  7561. @item n
  7562. The (sequential) number of the input frame, starting from 0.
  7563. @item pts
  7564. The Presentation TimeStamp of the input frame, expressed as a number of
  7565. time base units. The time base unit depends on the filter input pad.
  7566. @item pts_time
  7567. The Presentation TimeStamp of the input frame, expressed as a number of
  7568. seconds.
  7569. @item pos
  7570. The position of the frame in the input stream, or -1 if this information is
  7571. unavailable and/or meaningless (for example in case of synthetic video).
  7572. @item fmt
  7573. The pixel format name.
  7574. @item sar
  7575. The sample aspect ratio of the input frame, expressed in the form
  7576. @var{num}/@var{den}.
  7577. @item s
  7578. The size of the input frame. For the syntax of this option, check the
  7579. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7580. @item i
  7581. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7582. for bottom field first).
  7583. @item iskey
  7584. This is 1 if the frame is a key frame, 0 otherwise.
  7585. @item type
  7586. The picture type of the input frame ("I" for an I-frame, "P" for a
  7587. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7588. Also refer to the documentation of the @code{AVPictureType} enum and of
  7589. the @code{av_get_picture_type_char} function defined in
  7590. @file{libavutil/avutil.h}.
  7591. @item checksum
  7592. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7593. @item plane_checksum
  7594. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7595. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7596. @end table
  7597. @section showpalette
  7598. Displays the 256 colors palette of each frame. This filter is only relevant for
  7599. @var{pal8} pixel format frames.
  7600. It accepts the following option:
  7601. @table @option
  7602. @item s
  7603. Set the size of the box used to represent one palette color entry. Default is
  7604. @code{30} (for a @code{30x30} pixel box).
  7605. @end table
  7606. @section shuffleframes
  7607. Reorder and/or duplicate video frames.
  7608. It accepts the following parameters:
  7609. @table @option
  7610. @item mapping
  7611. Set the destination indexes of input frames.
  7612. This is space or '|' separated list of indexes that maps input frames to output
  7613. frames. Number of indexes also sets maximal value that each index may have.
  7614. @end table
  7615. The first frame has the index 0. The default is to keep the input unchanged.
  7616. Swap second and third frame of every three frames of the input:
  7617. @example
  7618. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  7619. @end example
  7620. @section shuffleplanes
  7621. Reorder and/or duplicate video planes.
  7622. It accepts the following parameters:
  7623. @table @option
  7624. @item map0
  7625. The index of the input plane to be used as the first output plane.
  7626. @item map1
  7627. The index of the input plane to be used as the second output plane.
  7628. @item map2
  7629. The index of the input plane to be used as the third output plane.
  7630. @item map3
  7631. The index of the input plane to be used as the fourth output plane.
  7632. @end table
  7633. The first plane has the index 0. The default is to keep the input unchanged.
  7634. Swap the second and third planes of the input:
  7635. @example
  7636. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7637. @end example
  7638. @anchor{signalstats}
  7639. @section signalstats
  7640. Evaluate various visual metrics that assist in determining issues associated
  7641. with the digitization of analog video media.
  7642. By default the filter will log these metadata values:
  7643. @table @option
  7644. @item YMIN
  7645. Display the minimal Y value contained within the input frame. Expressed in
  7646. range of [0-255].
  7647. @item YLOW
  7648. Display the Y value at the 10% percentile within the input frame. Expressed in
  7649. range of [0-255].
  7650. @item YAVG
  7651. Display the average Y value within the input frame. Expressed in range of
  7652. [0-255].
  7653. @item YHIGH
  7654. Display the Y value at the 90% percentile within the input frame. Expressed in
  7655. range of [0-255].
  7656. @item YMAX
  7657. Display the maximum Y value contained within the input frame. Expressed in
  7658. range of [0-255].
  7659. @item UMIN
  7660. Display the minimal U value contained within the input frame. Expressed in
  7661. range of [0-255].
  7662. @item ULOW
  7663. Display the U value at the 10% percentile within the input frame. Expressed in
  7664. range of [0-255].
  7665. @item UAVG
  7666. Display the average U value within the input frame. Expressed in range of
  7667. [0-255].
  7668. @item UHIGH
  7669. Display the U value at the 90% percentile within the input frame. Expressed in
  7670. range of [0-255].
  7671. @item UMAX
  7672. Display the maximum U value contained within the input frame. Expressed in
  7673. range of [0-255].
  7674. @item VMIN
  7675. Display the minimal V value contained within the input frame. Expressed in
  7676. range of [0-255].
  7677. @item VLOW
  7678. Display the V value at the 10% percentile within the input frame. Expressed in
  7679. range of [0-255].
  7680. @item VAVG
  7681. Display the average V value within the input frame. Expressed in range of
  7682. [0-255].
  7683. @item VHIGH
  7684. Display the V value at the 90% percentile within the input frame. Expressed in
  7685. range of [0-255].
  7686. @item VMAX
  7687. Display the maximum V value contained within the input frame. Expressed in
  7688. range of [0-255].
  7689. @item SATMIN
  7690. Display the minimal saturation value contained within the input frame.
  7691. Expressed in range of [0-~181.02].
  7692. @item SATLOW
  7693. Display the saturation value at the 10% percentile within the input frame.
  7694. Expressed in range of [0-~181.02].
  7695. @item SATAVG
  7696. Display the average saturation value within the input frame. Expressed in range
  7697. of [0-~181.02].
  7698. @item SATHIGH
  7699. Display the saturation value at the 90% percentile within the input frame.
  7700. Expressed in range of [0-~181.02].
  7701. @item SATMAX
  7702. Display the maximum saturation value contained within the input frame.
  7703. Expressed in range of [0-~181.02].
  7704. @item HUEMED
  7705. Display the median value for hue within the input frame. Expressed in range of
  7706. [0-360].
  7707. @item HUEAVG
  7708. Display the average value for hue within the input frame. Expressed in range of
  7709. [0-360].
  7710. @item YDIF
  7711. Display the average of sample value difference between all values of the Y
  7712. plane in the current frame and corresponding values of the previous input frame.
  7713. Expressed in range of [0-255].
  7714. @item UDIF
  7715. Display the average of sample value difference between all values of the U
  7716. plane in the current frame and corresponding values of the previous input frame.
  7717. Expressed in range of [0-255].
  7718. @item VDIF
  7719. Display the average of sample value difference between all values of the V
  7720. plane in the current frame and corresponding values of the previous input frame.
  7721. Expressed in range of [0-255].
  7722. @end table
  7723. The filter accepts the following options:
  7724. @table @option
  7725. @item stat
  7726. @item out
  7727. @option{stat} specify an additional form of image analysis.
  7728. @option{out} output video with the specified type of pixel highlighted.
  7729. Both options accept the following values:
  7730. @table @samp
  7731. @item tout
  7732. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7733. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7734. include the results of video dropouts, head clogs, or tape tracking issues.
  7735. @item vrep
  7736. Identify @var{vertical line repetition}. Vertical line repetition includes
  7737. similar rows of pixels within a frame. In born-digital video vertical line
  7738. repetition is common, but this pattern is uncommon in video digitized from an
  7739. analog source. When it occurs in video that results from the digitization of an
  7740. analog source it can indicate concealment from a dropout compensator.
  7741. @item brng
  7742. Identify pixels that fall outside of legal broadcast range.
  7743. @end table
  7744. @item color, c
  7745. Set the highlight color for the @option{out} option. The default color is
  7746. yellow.
  7747. @end table
  7748. @subsection Examples
  7749. @itemize
  7750. @item
  7751. Output data of various video metrics:
  7752. @example
  7753. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7754. @end example
  7755. @item
  7756. Output specific data about the minimum and maximum values of the Y plane per frame:
  7757. @example
  7758. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7759. @end example
  7760. @item
  7761. Playback video while highlighting pixels that are outside of broadcast range in red.
  7762. @example
  7763. ffplay example.mov -vf signalstats="out=brng:color=red"
  7764. @end example
  7765. @item
  7766. Playback video with signalstats metadata drawn over the frame.
  7767. @example
  7768. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7769. @end example
  7770. The contents of signalstat_drawtext.txt used in the command are:
  7771. @example
  7772. time %@{pts:hms@}
  7773. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7774. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7775. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7776. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7777. @end example
  7778. @end itemize
  7779. @anchor{smartblur}
  7780. @section smartblur
  7781. Blur the input video without impacting the outlines.
  7782. It accepts the following options:
  7783. @table @option
  7784. @item luma_radius, lr
  7785. Set the luma radius. The option value must be a float number in
  7786. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7787. used to blur the image (slower if larger). Default value is 1.0.
  7788. @item luma_strength, ls
  7789. Set the luma strength. The option value must be a float number
  7790. in the range [-1.0,1.0] that configures the blurring. A value included
  7791. in [0.0,1.0] will blur the image whereas a value included in
  7792. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7793. @item luma_threshold, lt
  7794. Set the luma threshold used as a coefficient to determine
  7795. whether a pixel should be blurred or not. The option value must be an
  7796. integer in the range [-30,30]. A value of 0 will filter all the image,
  7797. a value included in [0,30] will filter flat areas and a value included
  7798. in [-30,0] will filter edges. Default value is 0.
  7799. @item chroma_radius, cr
  7800. Set the chroma radius. The option value must be a float number in
  7801. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7802. used to blur the image (slower if larger). Default value is 1.0.
  7803. @item chroma_strength, cs
  7804. Set the chroma strength. The option value must be a float number
  7805. in the range [-1.0,1.0] that configures the blurring. A value included
  7806. in [0.0,1.0] will blur the image whereas a value included in
  7807. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7808. @item chroma_threshold, ct
  7809. Set the chroma threshold used as a coefficient to determine
  7810. whether a pixel should be blurred or not. The option value must be an
  7811. integer in the range [-30,30]. A value of 0 will filter all the image,
  7812. a value included in [0,30] will filter flat areas and a value included
  7813. in [-30,0] will filter edges. Default value is 0.
  7814. @end table
  7815. If a chroma option is not explicitly set, the corresponding luma value
  7816. is set.
  7817. @section ssim
  7818. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7819. This filter takes in input two input videos, the first input is
  7820. considered the "main" source and is passed unchanged to the
  7821. output. The second input is used as a "reference" video for computing
  7822. the SSIM.
  7823. Both video inputs must have the same resolution and pixel format for
  7824. this filter to work correctly. Also it assumes that both inputs
  7825. have the same number of frames, which are compared one by one.
  7826. The filter stores the calculated SSIM of each frame.
  7827. The description of the accepted parameters follows.
  7828. @table @option
  7829. @item stats_file, f
  7830. If specified the filter will use the named file to save the SSIM of
  7831. each individual frame. When filename equals "-" the data is sent to
  7832. standard output.
  7833. @end table
  7834. The file printed if @var{stats_file} is selected, contains a sequence of
  7835. key/value pairs of the form @var{key}:@var{value} for each compared
  7836. couple of frames.
  7837. A description of each shown parameter follows:
  7838. @table @option
  7839. @item n
  7840. sequential number of the input frame, starting from 1
  7841. @item Y, U, V, R, G, B
  7842. SSIM of the compared frames for the component specified by the suffix.
  7843. @item All
  7844. SSIM of the compared frames for the whole frame.
  7845. @item dB
  7846. Same as above but in dB representation.
  7847. @end table
  7848. For example:
  7849. @example
  7850. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7851. [main][ref] ssim="stats_file=stats.log" [out]
  7852. @end example
  7853. On this example the input file being processed is compared with the
  7854. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7855. is stored in @file{stats.log}.
  7856. Another example with both psnr and ssim at same time:
  7857. @example
  7858. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7859. @end example
  7860. @section stereo3d
  7861. Convert between different stereoscopic image formats.
  7862. The filters accept the following options:
  7863. @table @option
  7864. @item in
  7865. Set stereoscopic image format of input.
  7866. Available values for input image formats are:
  7867. @table @samp
  7868. @item sbsl
  7869. side by side parallel (left eye left, right eye right)
  7870. @item sbsr
  7871. side by side crosseye (right eye left, left eye right)
  7872. @item sbs2l
  7873. side by side parallel with half width resolution
  7874. (left eye left, right eye right)
  7875. @item sbs2r
  7876. side by side crosseye with half width resolution
  7877. (right eye left, left eye right)
  7878. @item abl
  7879. above-below (left eye above, right eye below)
  7880. @item abr
  7881. above-below (right eye above, left eye below)
  7882. @item ab2l
  7883. above-below with half height resolution
  7884. (left eye above, right eye below)
  7885. @item ab2r
  7886. above-below with half height resolution
  7887. (right eye above, left eye below)
  7888. @item al
  7889. alternating frames (left eye first, right eye second)
  7890. @item ar
  7891. alternating frames (right eye first, left eye second)
  7892. @item irl
  7893. interleaved rows (left eye has top row, right eye starts on next row)
  7894. @item irr
  7895. interleaved rows (right eye has top row, left eye starts on next row)
  7896. Default value is @samp{sbsl}.
  7897. @end table
  7898. @item out
  7899. Set stereoscopic image format of output.
  7900. Available values for output image formats are all the input formats as well as:
  7901. @table @samp
  7902. @item arbg
  7903. anaglyph red/blue gray
  7904. (red filter on left eye, blue filter on right eye)
  7905. @item argg
  7906. anaglyph red/green gray
  7907. (red filter on left eye, green filter on right eye)
  7908. @item arcg
  7909. anaglyph red/cyan gray
  7910. (red filter on left eye, cyan filter on right eye)
  7911. @item arch
  7912. anaglyph red/cyan half colored
  7913. (red filter on left eye, cyan filter on right eye)
  7914. @item arcc
  7915. anaglyph red/cyan color
  7916. (red filter on left eye, cyan filter on right eye)
  7917. @item arcd
  7918. anaglyph red/cyan color optimized with the least squares projection of dubois
  7919. (red filter on left eye, cyan filter on right eye)
  7920. @item agmg
  7921. anaglyph green/magenta gray
  7922. (green filter on left eye, magenta filter on right eye)
  7923. @item agmh
  7924. anaglyph green/magenta half colored
  7925. (green filter on left eye, magenta filter on right eye)
  7926. @item agmc
  7927. anaglyph green/magenta colored
  7928. (green filter on left eye, magenta filter on right eye)
  7929. @item agmd
  7930. anaglyph green/magenta color optimized with the least squares projection of dubois
  7931. (green filter on left eye, magenta filter on right eye)
  7932. @item aybg
  7933. anaglyph yellow/blue gray
  7934. (yellow filter on left eye, blue filter on right eye)
  7935. @item aybh
  7936. anaglyph yellow/blue half colored
  7937. (yellow filter on left eye, blue filter on right eye)
  7938. @item aybc
  7939. anaglyph yellow/blue colored
  7940. (yellow filter on left eye, blue filter on right eye)
  7941. @item aybd
  7942. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7943. (yellow filter on left eye, blue filter on right eye)
  7944. @item ml
  7945. mono output (left eye only)
  7946. @item mr
  7947. mono output (right eye only)
  7948. @item chl
  7949. checkerboard, left eye first
  7950. @item chr
  7951. checkerboard, right eye first
  7952. @item icl
  7953. interleaved columns, left eye first
  7954. @item icr
  7955. interleaved columns, right eye first
  7956. @end table
  7957. Default value is @samp{arcd}.
  7958. @end table
  7959. @subsection Examples
  7960. @itemize
  7961. @item
  7962. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7963. @example
  7964. stereo3d=sbsl:aybd
  7965. @end example
  7966. @item
  7967. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  7968. @example
  7969. stereo3d=abl:sbsr
  7970. @end example
  7971. @end itemize
  7972. @anchor{spp}
  7973. @section spp
  7974. Apply a simple postprocessing filter that compresses and decompresses the image
  7975. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7976. and average the results.
  7977. The filter accepts the following options:
  7978. @table @option
  7979. @item quality
  7980. Set quality. This option defines the number of levels for averaging. It accepts
  7981. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7982. effect. A value of @code{6} means the higher quality. For each increment of
  7983. that value the speed drops by a factor of approximately 2. Default value is
  7984. @code{3}.
  7985. @item qp
  7986. Force a constant quantization parameter. If not set, the filter will use the QP
  7987. from the video stream (if available).
  7988. @item mode
  7989. Set thresholding mode. Available modes are:
  7990. @table @samp
  7991. @item hard
  7992. Set hard thresholding (default).
  7993. @item soft
  7994. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7995. @end table
  7996. @item use_bframe_qp
  7997. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7998. option may cause flicker since the B-Frames have often larger QP. Default is
  7999. @code{0} (not enabled).
  8000. @end table
  8001. @anchor{subtitles}
  8002. @section subtitles
  8003. Draw subtitles on top of input video using the libass library.
  8004. To enable compilation of this filter you need to configure FFmpeg with
  8005. @code{--enable-libass}. This filter also requires a build with libavcodec and
  8006. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  8007. Alpha) subtitles format.
  8008. The filter accepts the following options:
  8009. @table @option
  8010. @item filename, f
  8011. Set the filename of the subtitle file to read. It must be specified.
  8012. @item original_size
  8013. Specify the size of the original video, the video for which the ASS file
  8014. was composed. For the syntax of this option, check the
  8015. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8016. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  8017. correctly scale the fonts if the aspect ratio has been changed.
  8018. @item fontsdir
  8019. Set a directory path containing fonts that can be used by the filter.
  8020. These fonts will be used in addition to whatever the font provider uses.
  8021. @item charenc
  8022. Set subtitles input character encoding. @code{subtitles} filter only. Only
  8023. useful if not UTF-8.
  8024. @item stream_index, si
  8025. Set subtitles stream index. @code{subtitles} filter only.
  8026. @item force_style
  8027. Override default style or script info parameters of the subtitles. It accepts a
  8028. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  8029. @end table
  8030. If the first key is not specified, it is assumed that the first value
  8031. specifies the @option{filename}.
  8032. For example, to render the file @file{sub.srt} on top of the input
  8033. video, use the command:
  8034. @example
  8035. subtitles=sub.srt
  8036. @end example
  8037. which is equivalent to:
  8038. @example
  8039. subtitles=filename=sub.srt
  8040. @end example
  8041. To render the default subtitles stream from file @file{video.mkv}, use:
  8042. @example
  8043. subtitles=video.mkv
  8044. @end example
  8045. To render the second subtitles stream from that file, use:
  8046. @example
  8047. subtitles=video.mkv:si=1
  8048. @end example
  8049. To make the subtitles stream from @file{sub.srt} appear in transparent green
  8050. @code{DejaVu Serif}, use:
  8051. @example
  8052. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  8053. @end example
  8054. @section super2xsai
  8055. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  8056. Interpolate) pixel art scaling algorithm.
  8057. Useful for enlarging pixel art images without reducing sharpness.
  8058. @section swapuv
  8059. Swap U & V plane.
  8060. @section telecine
  8061. Apply telecine process to the video.
  8062. This filter accepts the following options:
  8063. @table @option
  8064. @item first_field
  8065. @table @samp
  8066. @item top, t
  8067. top field first
  8068. @item bottom, b
  8069. bottom field first
  8070. The default value is @code{top}.
  8071. @end table
  8072. @item pattern
  8073. A string of numbers representing the pulldown pattern you wish to apply.
  8074. The default value is @code{23}.
  8075. @end table
  8076. @example
  8077. Some typical patterns:
  8078. NTSC output (30i):
  8079. 27.5p: 32222
  8080. 24p: 23 (classic)
  8081. 24p: 2332 (preferred)
  8082. 20p: 33
  8083. 18p: 334
  8084. 16p: 3444
  8085. PAL output (25i):
  8086. 27.5p: 12222
  8087. 24p: 222222222223 ("Euro pulldown")
  8088. 16.67p: 33
  8089. 16p: 33333334
  8090. @end example
  8091. @section thumbnail
  8092. Select the most representative frame in a given sequence of consecutive frames.
  8093. The filter accepts the following options:
  8094. @table @option
  8095. @item n
  8096. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  8097. will pick one of them, and then handle the next batch of @var{n} frames until
  8098. the end. Default is @code{100}.
  8099. @end table
  8100. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  8101. value will result in a higher memory usage, so a high value is not recommended.
  8102. @subsection Examples
  8103. @itemize
  8104. @item
  8105. Extract one picture each 50 frames:
  8106. @example
  8107. thumbnail=50
  8108. @end example
  8109. @item
  8110. Complete example of a thumbnail creation with @command{ffmpeg}:
  8111. @example
  8112. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  8113. @end example
  8114. @end itemize
  8115. @section tile
  8116. Tile several successive frames together.
  8117. The filter accepts the following options:
  8118. @table @option
  8119. @item layout
  8120. Set the grid size (i.e. the number of lines and columns). For the syntax of
  8121. this option, check the
  8122. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8123. @item nb_frames
  8124. Set the maximum number of frames to render in the given area. It must be less
  8125. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  8126. the area will be used.
  8127. @item margin
  8128. Set the outer border margin in pixels.
  8129. @item padding
  8130. Set the inner border thickness (i.e. the number of pixels between frames). For
  8131. more advanced padding options (such as having different values for the edges),
  8132. refer to the pad video filter.
  8133. @item color
  8134. Specify the color of the unused area. For the syntax of this option, check the
  8135. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  8136. is "black".
  8137. @end table
  8138. @subsection Examples
  8139. @itemize
  8140. @item
  8141. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  8142. @example
  8143. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  8144. @end example
  8145. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  8146. duplicating each output frame to accommodate the originally detected frame
  8147. rate.
  8148. @item
  8149. Display @code{5} pictures in an area of @code{3x2} frames,
  8150. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  8151. mixed flat and named options:
  8152. @example
  8153. tile=3x2:nb_frames=5:padding=7:margin=2
  8154. @end example
  8155. @end itemize
  8156. @section tinterlace
  8157. Perform various types of temporal field interlacing.
  8158. Frames are counted starting from 1, so the first input frame is
  8159. considered odd.
  8160. The filter accepts the following options:
  8161. @table @option
  8162. @item mode
  8163. Specify the mode of the interlacing. This option can also be specified
  8164. as a value alone. See below for a list of values for this option.
  8165. Available values are:
  8166. @table @samp
  8167. @item merge, 0
  8168. Move odd frames into the upper field, even into the lower field,
  8169. generating a double height frame at half frame rate.
  8170. @example
  8171. ------> time
  8172. Input:
  8173. Frame 1 Frame 2 Frame 3 Frame 4
  8174. 11111 22222 33333 44444
  8175. 11111 22222 33333 44444
  8176. 11111 22222 33333 44444
  8177. 11111 22222 33333 44444
  8178. Output:
  8179. 11111 33333
  8180. 22222 44444
  8181. 11111 33333
  8182. 22222 44444
  8183. 11111 33333
  8184. 22222 44444
  8185. 11111 33333
  8186. 22222 44444
  8187. @end example
  8188. @item drop_odd, 1
  8189. Only output even frames, odd frames are dropped, generating a frame with
  8190. unchanged height at half frame rate.
  8191. @example
  8192. ------> time
  8193. Input:
  8194. Frame 1 Frame 2 Frame 3 Frame 4
  8195. 11111 22222 33333 44444
  8196. 11111 22222 33333 44444
  8197. 11111 22222 33333 44444
  8198. 11111 22222 33333 44444
  8199. Output:
  8200. 22222 44444
  8201. 22222 44444
  8202. 22222 44444
  8203. 22222 44444
  8204. @end example
  8205. @item drop_even, 2
  8206. Only output odd frames, even frames are dropped, generating a frame with
  8207. unchanged height at half frame rate.
  8208. @example
  8209. ------> time
  8210. Input:
  8211. Frame 1 Frame 2 Frame 3 Frame 4
  8212. 11111 22222 33333 44444
  8213. 11111 22222 33333 44444
  8214. 11111 22222 33333 44444
  8215. 11111 22222 33333 44444
  8216. Output:
  8217. 11111 33333
  8218. 11111 33333
  8219. 11111 33333
  8220. 11111 33333
  8221. @end example
  8222. @item pad, 3
  8223. Expand each frame to full height, but pad alternate lines with black,
  8224. generating a frame with double height at the same input frame rate.
  8225. @example
  8226. ------> time
  8227. Input:
  8228. Frame 1 Frame 2 Frame 3 Frame 4
  8229. 11111 22222 33333 44444
  8230. 11111 22222 33333 44444
  8231. 11111 22222 33333 44444
  8232. 11111 22222 33333 44444
  8233. Output:
  8234. 11111 ..... 33333 .....
  8235. ..... 22222 ..... 44444
  8236. 11111 ..... 33333 .....
  8237. ..... 22222 ..... 44444
  8238. 11111 ..... 33333 .....
  8239. ..... 22222 ..... 44444
  8240. 11111 ..... 33333 .....
  8241. ..... 22222 ..... 44444
  8242. @end example
  8243. @item interleave_top, 4
  8244. Interleave the upper field from odd frames with the lower field from
  8245. even frames, generating a frame with unchanged height at half frame rate.
  8246. @example
  8247. ------> time
  8248. Input:
  8249. Frame 1 Frame 2 Frame 3 Frame 4
  8250. 11111<- 22222 33333<- 44444
  8251. 11111 22222<- 33333 44444<-
  8252. 11111<- 22222 33333<- 44444
  8253. 11111 22222<- 33333 44444<-
  8254. Output:
  8255. 11111 33333
  8256. 22222 44444
  8257. 11111 33333
  8258. 22222 44444
  8259. @end example
  8260. @item interleave_bottom, 5
  8261. Interleave the lower field from odd frames with the upper field from
  8262. even frames, generating a frame with unchanged height at half frame rate.
  8263. @example
  8264. ------> time
  8265. Input:
  8266. Frame 1 Frame 2 Frame 3 Frame 4
  8267. 11111 22222<- 33333 44444<-
  8268. 11111<- 22222 33333<- 44444
  8269. 11111 22222<- 33333 44444<-
  8270. 11111<- 22222 33333<- 44444
  8271. Output:
  8272. 22222 44444
  8273. 11111 33333
  8274. 22222 44444
  8275. 11111 33333
  8276. @end example
  8277. @item interlacex2, 6
  8278. Double frame rate with unchanged height. Frames are inserted each
  8279. containing the second temporal field from the previous input frame and
  8280. the first temporal field from the next input frame. This mode relies on
  8281. the top_field_first flag. Useful for interlaced video displays with no
  8282. field synchronisation.
  8283. @example
  8284. ------> time
  8285. Input:
  8286. Frame 1 Frame 2 Frame 3 Frame 4
  8287. 11111 22222 33333 44444
  8288. 11111 22222 33333 44444
  8289. 11111 22222 33333 44444
  8290. 11111 22222 33333 44444
  8291. Output:
  8292. 11111 22222 22222 33333 33333 44444 44444
  8293. 11111 11111 22222 22222 33333 33333 44444
  8294. 11111 22222 22222 33333 33333 44444 44444
  8295. 11111 11111 22222 22222 33333 33333 44444
  8296. @end example
  8297. @item mergex2, 7
  8298. Move odd frames into the upper field, even into the lower field,
  8299. generating a double height frame at same frame rate.
  8300. @example
  8301. ------> time
  8302. Input:
  8303. Frame 1 Frame 2 Frame 3 Frame 4
  8304. 11111 22222 33333 44444
  8305. 11111 22222 33333 44444
  8306. 11111 22222 33333 44444
  8307. 11111 22222 33333 44444
  8308. Output:
  8309. 11111 33333 33333 55555
  8310. 22222 22222 44444 44444
  8311. 11111 33333 33333 55555
  8312. 22222 22222 44444 44444
  8313. 11111 33333 33333 55555
  8314. 22222 22222 44444 44444
  8315. 11111 33333 33333 55555
  8316. 22222 22222 44444 44444
  8317. @end example
  8318. @end table
  8319. Numeric values are deprecated but are accepted for backward
  8320. compatibility reasons.
  8321. Default mode is @code{merge}.
  8322. @item flags
  8323. Specify flags influencing the filter process.
  8324. Available value for @var{flags} is:
  8325. @table @option
  8326. @item low_pass_filter, vlfp
  8327. Enable vertical low-pass filtering in the filter.
  8328. Vertical low-pass filtering is required when creating an interlaced
  8329. destination from a progressive source which contains high-frequency
  8330. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  8331. patterning.
  8332. Vertical low-pass filtering can only be enabled for @option{mode}
  8333. @var{interleave_top} and @var{interleave_bottom}.
  8334. @end table
  8335. @end table
  8336. @section transpose
  8337. Transpose rows with columns in the input video and optionally flip it.
  8338. It accepts the following parameters:
  8339. @table @option
  8340. @item dir
  8341. Specify the transposition direction.
  8342. Can assume the following values:
  8343. @table @samp
  8344. @item 0, 4, cclock_flip
  8345. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  8346. @example
  8347. L.R L.l
  8348. . . -> . .
  8349. l.r R.r
  8350. @end example
  8351. @item 1, 5, clock
  8352. Rotate by 90 degrees clockwise, that is:
  8353. @example
  8354. L.R l.L
  8355. . . -> . .
  8356. l.r r.R
  8357. @end example
  8358. @item 2, 6, cclock
  8359. Rotate by 90 degrees counterclockwise, that is:
  8360. @example
  8361. L.R R.r
  8362. . . -> . .
  8363. l.r L.l
  8364. @end example
  8365. @item 3, 7, clock_flip
  8366. Rotate by 90 degrees clockwise and vertically flip, that is:
  8367. @example
  8368. L.R r.R
  8369. . . -> . .
  8370. l.r l.L
  8371. @end example
  8372. @end table
  8373. For values between 4-7, the transposition is only done if the input
  8374. video geometry is portrait and not landscape. These values are
  8375. deprecated, the @code{passthrough} option should be used instead.
  8376. Numerical values are deprecated, and should be dropped in favor of
  8377. symbolic constants.
  8378. @item passthrough
  8379. Do not apply the transposition if the input geometry matches the one
  8380. specified by the specified value. It accepts the following values:
  8381. @table @samp
  8382. @item none
  8383. Always apply transposition.
  8384. @item portrait
  8385. Preserve portrait geometry (when @var{height} >= @var{width}).
  8386. @item landscape
  8387. Preserve landscape geometry (when @var{width} >= @var{height}).
  8388. @end table
  8389. Default value is @code{none}.
  8390. @end table
  8391. For example to rotate by 90 degrees clockwise and preserve portrait
  8392. layout:
  8393. @example
  8394. transpose=dir=1:passthrough=portrait
  8395. @end example
  8396. The command above can also be specified as:
  8397. @example
  8398. transpose=1:portrait
  8399. @end example
  8400. @section trim
  8401. Trim the input so that the output contains one continuous subpart of the input.
  8402. It accepts the following parameters:
  8403. @table @option
  8404. @item start
  8405. Specify the time of the start of the kept section, i.e. the frame with the
  8406. timestamp @var{start} will be the first frame in the output.
  8407. @item end
  8408. Specify the time of the first frame that will be dropped, i.e. the frame
  8409. immediately preceding the one with the timestamp @var{end} will be the last
  8410. frame in the output.
  8411. @item start_pts
  8412. This is the same as @var{start}, except this option sets the start timestamp
  8413. in timebase units instead of seconds.
  8414. @item end_pts
  8415. This is the same as @var{end}, except this option sets the end timestamp
  8416. in timebase units instead of seconds.
  8417. @item duration
  8418. The maximum duration of the output in seconds.
  8419. @item start_frame
  8420. The number of the first frame that should be passed to the output.
  8421. @item end_frame
  8422. The number of the first frame that should be dropped.
  8423. @end table
  8424. @option{start}, @option{end}, and @option{duration} are expressed as time
  8425. duration specifications; see
  8426. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8427. for the accepted syntax.
  8428. Note that the first two sets of the start/end options and the @option{duration}
  8429. option look at the frame timestamp, while the _frame variants simply count the
  8430. frames that pass through the filter. Also note that this filter does not modify
  8431. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8432. setpts filter after the trim filter.
  8433. If multiple start or end options are set, this filter tries to be greedy and
  8434. keep all the frames that match at least one of the specified constraints. To keep
  8435. only the part that matches all the constraints at once, chain multiple trim
  8436. filters.
  8437. The defaults are such that all the input is kept. So it is possible to set e.g.
  8438. just the end values to keep everything before the specified time.
  8439. Examples:
  8440. @itemize
  8441. @item
  8442. Drop everything except the second minute of input:
  8443. @example
  8444. ffmpeg -i INPUT -vf trim=60:120
  8445. @end example
  8446. @item
  8447. Keep only the first second:
  8448. @example
  8449. ffmpeg -i INPUT -vf trim=duration=1
  8450. @end example
  8451. @end itemize
  8452. @anchor{unsharp}
  8453. @section unsharp
  8454. Sharpen or blur the input video.
  8455. It accepts the following parameters:
  8456. @table @option
  8457. @item luma_msize_x, lx
  8458. Set the luma matrix horizontal size. It must be an odd integer between
  8459. 3 and 63. The default value is 5.
  8460. @item luma_msize_y, ly
  8461. Set the luma matrix vertical size. It must be an odd integer between 3
  8462. and 63. The default value is 5.
  8463. @item luma_amount, la
  8464. Set the luma effect strength. It must be a floating point number, reasonable
  8465. values lay between -1.5 and 1.5.
  8466. Negative values will blur the input video, while positive values will
  8467. sharpen it, a value of zero will disable the effect.
  8468. Default value is 1.0.
  8469. @item chroma_msize_x, cx
  8470. Set the chroma matrix horizontal size. It must be an odd integer
  8471. between 3 and 63. The default value is 5.
  8472. @item chroma_msize_y, cy
  8473. Set the chroma matrix vertical size. It must be an odd integer
  8474. between 3 and 63. The default value is 5.
  8475. @item chroma_amount, ca
  8476. Set the chroma effect strength. It must be a floating point number, reasonable
  8477. values lay between -1.5 and 1.5.
  8478. Negative values will blur the input video, while positive values will
  8479. sharpen it, a value of zero will disable the effect.
  8480. Default value is 0.0.
  8481. @item opencl
  8482. If set to 1, specify using OpenCL capabilities, only available if
  8483. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8484. @end table
  8485. All parameters are optional and default to the equivalent of the
  8486. string '5:5:1.0:5:5:0.0'.
  8487. @subsection Examples
  8488. @itemize
  8489. @item
  8490. Apply strong luma sharpen effect:
  8491. @example
  8492. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8493. @end example
  8494. @item
  8495. Apply a strong blur of both luma and chroma parameters:
  8496. @example
  8497. unsharp=7:7:-2:7:7:-2
  8498. @end example
  8499. @end itemize
  8500. @section uspp
  8501. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8502. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8503. shifts and average the results.
  8504. The way this differs from the behavior of spp is that uspp actually encodes &
  8505. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8506. DCT similar to MJPEG.
  8507. The filter accepts the following options:
  8508. @table @option
  8509. @item quality
  8510. Set quality. This option defines the number of levels for averaging. It accepts
  8511. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8512. effect. A value of @code{8} means the higher quality. For each increment of
  8513. that value the speed drops by a factor of approximately 2. Default value is
  8514. @code{3}.
  8515. @item qp
  8516. Force a constant quantization parameter. If not set, the filter will use the QP
  8517. from the video stream (if available).
  8518. @end table
  8519. @section vectorscope
  8520. Display 2 color component values in the two dimensional graph (which is called
  8521. a vectorscope).
  8522. This filter accepts the following options:
  8523. @table @option
  8524. @item mode, m
  8525. Set vectorscope mode.
  8526. It accepts the following values:
  8527. @table @samp
  8528. @item gray
  8529. Gray values are displayed on graph, higher brightness means more pixels have
  8530. same component color value on location in graph. This is the default mode.
  8531. @item color
  8532. Gray values are displayed on graph. Surrounding pixels values which are not
  8533. present in video frame are drawn in gradient of 2 color components which are
  8534. set by option @code{x} and @code{y}.
  8535. @item color2
  8536. Actual color components values present in video frame are displayed on graph.
  8537. @item color3
  8538. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8539. on graph increases value of another color component, which is luminance by
  8540. default values of @code{x} and @code{y}.
  8541. @item color4
  8542. Actual colors present in video frame are displayed on graph. If two different
  8543. colors map to same position on graph then color with higher value of component
  8544. not present in graph is picked.
  8545. @end table
  8546. @item x
  8547. Set which color component will be represented on X-axis. Default is @code{1}.
  8548. @item y
  8549. Set which color component will be represented on Y-axis. Default is @code{2}.
  8550. @item intensity, i
  8551. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8552. of color component which represents frequency of (X, Y) location in graph.
  8553. @item envelope, e
  8554. @table @samp
  8555. @item none
  8556. No envelope, this is default.
  8557. @item instant
  8558. Instant envelope, even darkest single pixel will be clearly highlighted.
  8559. @item peak
  8560. Hold maximum and minimum values presented in graph over time. This way you
  8561. can still spot out of range values without constantly looking at vectorscope.
  8562. @item peak+instant
  8563. Peak and instant envelope combined together.
  8564. @end table
  8565. @end table
  8566. @anchor{vidstabdetect}
  8567. @section vidstabdetect
  8568. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8569. @ref{vidstabtransform} for pass 2.
  8570. This filter generates a file with relative translation and rotation
  8571. transform information about subsequent frames, which is then used by
  8572. the @ref{vidstabtransform} filter.
  8573. To enable compilation of this filter you need to configure FFmpeg with
  8574. @code{--enable-libvidstab}.
  8575. This filter accepts the following options:
  8576. @table @option
  8577. @item result
  8578. Set the path to the file used to write the transforms information.
  8579. Default value is @file{transforms.trf}.
  8580. @item shakiness
  8581. Set how shaky the video is and how quick the camera is. It accepts an
  8582. integer in the range 1-10, a value of 1 means little shakiness, a
  8583. value of 10 means strong shakiness. Default value is 5.
  8584. @item accuracy
  8585. Set the accuracy of the detection process. It must be a value in the
  8586. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8587. accuracy. Default value is 15.
  8588. @item stepsize
  8589. Set stepsize of the search process. The region around minimum is
  8590. scanned with 1 pixel resolution. Default value is 6.
  8591. @item mincontrast
  8592. Set minimum contrast. Below this value a local measurement field is
  8593. discarded. Must be a floating point value in the range 0-1. Default
  8594. value is 0.3.
  8595. @item tripod
  8596. Set reference frame number for tripod mode.
  8597. If enabled, the motion of the frames is compared to a reference frame
  8598. in the filtered stream, identified by the specified number. The idea
  8599. is to compensate all movements in a more-or-less static scene and keep
  8600. the camera view absolutely still.
  8601. If set to 0, it is disabled. The frames are counted starting from 1.
  8602. @item show
  8603. Show fields and transforms in the resulting frames. It accepts an
  8604. integer in the range 0-2. Default value is 0, which disables any
  8605. visualization.
  8606. @end table
  8607. @subsection Examples
  8608. @itemize
  8609. @item
  8610. Use default values:
  8611. @example
  8612. vidstabdetect
  8613. @end example
  8614. @item
  8615. Analyze strongly shaky movie and put the results in file
  8616. @file{mytransforms.trf}:
  8617. @example
  8618. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8619. @end example
  8620. @item
  8621. Visualize the result of internal transformations in the resulting
  8622. video:
  8623. @example
  8624. vidstabdetect=show=1
  8625. @end example
  8626. @item
  8627. Analyze a video with medium shakiness using @command{ffmpeg}:
  8628. @example
  8629. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8630. @end example
  8631. @end itemize
  8632. @anchor{vidstabtransform}
  8633. @section vidstabtransform
  8634. Video stabilization/deshaking: pass 2 of 2,
  8635. see @ref{vidstabdetect} for pass 1.
  8636. Read a file with transform information for each frame and
  8637. apply/compensate them. Together with the @ref{vidstabdetect}
  8638. filter this can be used to deshake videos. See also
  8639. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8640. the @ref{unsharp} filter, see below.
  8641. To enable compilation of this filter you need to configure FFmpeg with
  8642. @code{--enable-libvidstab}.
  8643. @subsection Options
  8644. @table @option
  8645. @item input
  8646. Set path to the file used to read the transforms. Default value is
  8647. @file{transforms.trf}.
  8648. @item smoothing
  8649. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8650. camera movements. Default value is 10.
  8651. For example a number of 10 means that 21 frames are used (10 in the
  8652. past and 10 in the future) to smoothen the motion in the video. A
  8653. larger value leads to a smoother video, but limits the acceleration of
  8654. the camera (pan/tilt movements). 0 is a special case where a static
  8655. camera is simulated.
  8656. @item optalgo
  8657. Set the camera path optimization algorithm.
  8658. Accepted values are:
  8659. @table @samp
  8660. @item gauss
  8661. gaussian kernel low-pass filter on camera motion (default)
  8662. @item avg
  8663. averaging on transformations
  8664. @end table
  8665. @item maxshift
  8666. Set maximal number of pixels to translate frames. Default value is -1,
  8667. meaning no limit.
  8668. @item maxangle
  8669. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8670. value is -1, meaning no limit.
  8671. @item crop
  8672. Specify how to deal with borders that may be visible due to movement
  8673. compensation.
  8674. Available values are:
  8675. @table @samp
  8676. @item keep
  8677. keep image information from previous frame (default)
  8678. @item black
  8679. fill the border black
  8680. @end table
  8681. @item invert
  8682. Invert transforms if set to 1. Default value is 0.
  8683. @item relative
  8684. Consider transforms as relative to previous frame if set to 1,
  8685. absolute if set to 0. Default value is 0.
  8686. @item zoom
  8687. Set percentage to zoom. A positive value will result in a zoom-in
  8688. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8689. zoom).
  8690. @item optzoom
  8691. Set optimal zooming to avoid borders.
  8692. Accepted values are:
  8693. @table @samp
  8694. @item 0
  8695. disabled
  8696. @item 1
  8697. optimal static zoom value is determined (only very strong movements
  8698. will lead to visible borders) (default)
  8699. @item 2
  8700. optimal adaptive zoom value is determined (no borders will be
  8701. visible), see @option{zoomspeed}
  8702. @end table
  8703. Note that the value given at zoom is added to the one calculated here.
  8704. @item zoomspeed
  8705. Set percent to zoom maximally each frame (enabled when
  8706. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8707. 0.25.
  8708. @item interpol
  8709. Specify type of interpolation.
  8710. Available values are:
  8711. @table @samp
  8712. @item no
  8713. no interpolation
  8714. @item linear
  8715. linear only horizontal
  8716. @item bilinear
  8717. linear in both directions (default)
  8718. @item bicubic
  8719. cubic in both directions (slow)
  8720. @end table
  8721. @item tripod
  8722. Enable virtual tripod mode if set to 1, which is equivalent to
  8723. @code{relative=0:smoothing=0}. Default value is 0.
  8724. Use also @code{tripod} option of @ref{vidstabdetect}.
  8725. @item debug
  8726. Increase log verbosity if set to 1. Also the detected global motions
  8727. are written to the temporary file @file{global_motions.trf}. Default
  8728. value is 0.
  8729. @end table
  8730. @subsection Examples
  8731. @itemize
  8732. @item
  8733. Use @command{ffmpeg} for a typical stabilization with default values:
  8734. @example
  8735. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8736. @end example
  8737. Note the use of the @ref{unsharp} filter which is always recommended.
  8738. @item
  8739. Zoom in a bit more and load transform data from a given file:
  8740. @example
  8741. vidstabtransform=zoom=5:input="mytransforms.trf"
  8742. @end example
  8743. @item
  8744. Smoothen the video even more:
  8745. @example
  8746. vidstabtransform=smoothing=30
  8747. @end example
  8748. @end itemize
  8749. @section vflip
  8750. Flip the input video vertically.
  8751. For example, to vertically flip a video with @command{ffmpeg}:
  8752. @example
  8753. ffmpeg -i in.avi -vf "vflip" out.avi
  8754. @end example
  8755. @anchor{vignette}
  8756. @section vignette
  8757. Make or reverse a natural vignetting effect.
  8758. The filter accepts the following options:
  8759. @table @option
  8760. @item angle, a
  8761. Set lens angle expression as a number of radians.
  8762. The value is clipped in the @code{[0,PI/2]} range.
  8763. Default value: @code{"PI/5"}
  8764. @item x0
  8765. @item y0
  8766. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8767. by default.
  8768. @item mode
  8769. Set forward/backward mode.
  8770. Available modes are:
  8771. @table @samp
  8772. @item forward
  8773. The larger the distance from the central point, the darker the image becomes.
  8774. @item backward
  8775. The larger the distance from the central point, the brighter the image becomes.
  8776. This can be used to reverse a vignette effect, though there is no automatic
  8777. detection to extract the lens @option{angle} and other settings (yet). It can
  8778. also be used to create a burning effect.
  8779. @end table
  8780. Default value is @samp{forward}.
  8781. @item eval
  8782. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8783. It accepts the following values:
  8784. @table @samp
  8785. @item init
  8786. Evaluate expressions only once during the filter initialization.
  8787. @item frame
  8788. Evaluate expressions for each incoming frame. This is way slower than the
  8789. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8790. allows advanced dynamic expressions.
  8791. @end table
  8792. Default value is @samp{init}.
  8793. @item dither
  8794. Set dithering to reduce the circular banding effects. Default is @code{1}
  8795. (enabled).
  8796. @item aspect
  8797. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8798. Setting this value to the SAR of the input will make a rectangular vignetting
  8799. following the dimensions of the video.
  8800. Default is @code{1/1}.
  8801. @end table
  8802. @subsection Expressions
  8803. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8804. following parameters.
  8805. @table @option
  8806. @item w
  8807. @item h
  8808. input width and height
  8809. @item n
  8810. the number of input frame, starting from 0
  8811. @item pts
  8812. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8813. @var{TB} units, NAN if undefined
  8814. @item r
  8815. frame rate of the input video, NAN if the input frame rate is unknown
  8816. @item t
  8817. the PTS (Presentation TimeStamp) of the filtered video frame,
  8818. expressed in seconds, NAN if undefined
  8819. @item tb
  8820. time base of the input video
  8821. @end table
  8822. @subsection Examples
  8823. @itemize
  8824. @item
  8825. Apply simple strong vignetting effect:
  8826. @example
  8827. vignette=PI/4
  8828. @end example
  8829. @item
  8830. Make a flickering vignetting:
  8831. @example
  8832. vignette='PI/4+random(1)*PI/50':eval=frame
  8833. @end example
  8834. @end itemize
  8835. @section vstack
  8836. Stack input videos vertically.
  8837. All streams must be of same pixel format and of same width.
  8838. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  8839. to create same output.
  8840. The filter accept the following option:
  8841. @table @option
  8842. @item inputs
  8843. Set number of input streams. Default is 2.
  8844. @end table
  8845. @section w3fdif
  8846. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8847. Deinterlacing Filter").
  8848. Based on the process described by Martin Weston for BBC R&D, and
  8849. implemented based on the de-interlace algorithm written by Jim
  8850. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8851. uses filter coefficients calculated by BBC R&D.
  8852. There are two sets of filter coefficients, so called "simple":
  8853. and "complex". Which set of filter coefficients is used can
  8854. be set by passing an optional parameter:
  8855. @table @option
  8856. @item filter
  8857. Set the interlacing filter coefficients. Accepts one of the following values:
  8858. @table @samp
  8859. @item simple
  8860. Simple filter coefficient set.
  8861. @item complex
  8862. More-complex filter coefficient set.
  8863. @end table
  8864. Default value is @samp{complex}.
  8865. @item deint
  8866. Specify which frames to deinterlace. Accept one of the following values:
  8867. @table @samp
  8868. @item all
  8869. Deinterlace all frames,
  8870. @item interlaced
  8871. Only deinterlace frames marked as interlaced.
  8872. @end table
  8873. Default value is @samp{all}.
  8874. @end table
  8875. @section waveform
  8876. Video waveform monitor.
  8877. The waveform monitor plots color component intensity. By default luminance
  8878. only. Each column of the waveform corresponds to a column of pixels in the
  8879. source video.
  8880. It accepts the following options:
  8881. @table @option
  8882. @item mode, m
  8883. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8884. In row mode, the graph on the left side represents color component value 0 and
  8885. the right side represents value = 255. In column mode, the top side represents
  8886. color component value = 0 and bottom side represents value = 255.
  8887. @item intensity, i
  8888. Set intensity. Smaller values are useful to find out how many values of the same
  8889. luminance are distributed across input rows/columns.
  8890. Default value is @code{0.04}. Allowed range is [0, 1].
  8891. @item mirror, r
  8892. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8893. In mirrored mode, higher values will be represented on the left
  8894. side for @code{row} mode and at the top for @code{column} mode. Default is
  8895. @code{1} (mirrored).
  8896. @item display, d
  8897. Set display mode.
  8898. It accepts the following values:
  8899. @table @samp
  8900. @item overlay
  8901. Presents information identical to that in the @code{parade}, except
  8902. that the graphs representing color components are superimposed directly
  8903. over one another.
  8904. This display mode makes it easier to spot relative differences or similarities
  8905. in overlapping areas of the color components that are supposed to be identical,
  8906. such as neutral whites, grays, or blacks.
  8907. @item parade
  8908. Display separate graph for the color components side by side in
  8909. @code{row} mode or one below the other in @code{column} mode.
  8910. Using this display mode makes it easy to spot color casts in the highlights
  8911. and shadows of an image, by comparing the contours of the top and the bottom
  8912. graphs of each waveform. Since whites, grays, and blacks are characterized
  8913. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8914. should display three waveforms of roughly equal width/height. If not, the
  8915. correction is easy to perform by making level adjustments the three waveforms.
  8916. @end table
  8917. Default is @code{parade}.
  8918. @item components, c
  8919. Set which color components to display. Default is 1, which means only luminance
  8920. or red color component if input is in RGB colorspace. If is set for example to
  8921. 7 it will display all 3 (if) available color components.
  8922. @item envelope, e
  8923. @table @samp
  8924. @item none
  8925. No envelope, this is default.
  8926. @item instant
  8927. Instant envelope, minimum and maximum values presented in graph will be easily
  8928. visible even with small @code{step} value.
  8929. @item peak
  8930. Hold minimum and maximum values presented in graph across time. This way you
  8931. can still spot out of range values without constantly looking at waveforms.
  8932. @item peak+instant
  8933. Peak and instant envelope combined together.
  8934. @end table
  8935. @item filter, f
  8936. @table @samp
  8937. @item lowpass
  8938. No filtering, this is default.
  8939. @item flat
  8940. Luma and chroma combined together.
  8941. @item aflat
  8942. Similar as above, but shows difference between blue and red chroma.
  8943. @item chroma
  8944. Displays only chroma.
  8945. @item achroma
  8946. Similar as above, but shows difference between blue and red chroma.
  8947. @item color
  8948. Displays actual color value on waveform.
  8949. @end table
  8950. @end table
  8951. @section xbr
  8952. Apply the xBR high-quality magnification filter which is designed for pixel
  8953. art. It follows a set of edge-detection rules, see
  8954. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8955. It accepts the following option:
  8956. @table @option
  8957. @item n
  8958. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8959. @code{3xBR} and @code{4} for @code{4xBR}.
  8960. Default is @code{3}.
  8961. @end table
  8962. @anchor{yadif}
  8963. @section yadif
  8964. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8965. filter").
  8966. It accepts the following parameters:
  8967. @table @option
  8968. @item mode
  8969. The interlacing mode to adopt. It accepts one of the following values:
  8970. @table @option
  8971. @item 0, send_frame
  8972. Output one frame for each frame.
  8973. @item 1, send_field
  8974. Output one frame for each field.
  8975. @item 2, send_frame_nospatial
  8976. Like @code{send_frame}, but it skips the spatial interlacing check.
  8977. @item 3, send_field_nospatial
  8978. Like @code{send_field}, but it skips the spatial interlacing check.
  8979. @end table
  8980. The default value is @code{send_frame}.
  8981. @item parity
  8982. The picture field parity assumed for the input interlaced video. It accepts one
  8983. of the following values:
  8984. @table @option
  8985. @item 0, tff
  8986. Assume the top field is first.
  8987. @item 1, bff
  8988. Assume the bottom field is first.
  8989. @item -1, auto
  8990. Enable automatic detection of field parity.
  8991. @end table
  8992. The default value is @code{auto}.
  8993. If the interlacing is unknown or the decoder does not export this information,
  8994. top field first will be assumed.
  8995. @item deint
  8996. Specify which frames to deinterlace. Accept one of the following
  8997. values:
  8998. @table @option
  8999. @item 0, all
  9000. Deinterlace all frames.
  9001. @item 1, interlaced
  9002. Only deinterlace frames marked as interlaced.
  9003. @end table
  9004. The default value is @code{all}.
  9005. @end table
  9006. @section zoompan
  9007. Apply Zoom & Pan effect.
  9008. This filter accepts the following options:
  9009. @table @option
  9010. @item zoom, z
  9011. Set the zoom expression. Default is 1.
  9012. @item x
  9013. @item y
  9014. Set the x and y expression. Default is 0.
  9015. @item d
  9016. Set the duration expression in number of frames.
  9017. This sets for how many number of frames effect will last for
  9018. single input image.
  9019. @item s
  9020. Set the output image size, default is 'hd720'.
  9021. @end table
  9022. Each expression can contain the following constants:
  9023. @table @option
  9024. @item in_w, iw
  9025. Input width.
  9026. @item in_h, ih
  9027. Input height.
  9028. @item out_w, ow
  9029. Output width.
  9030. @item out_h, oh
  9031. Output height.
  9032. @item in
  9033. Input frame count.
  9034. @item on
  9035. Output frame count.
  9036. @item x
  9037. @item y
  9038. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  9039. for current input frame.
  9040. @item px
  9041. @item py
  9042. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  9043. not yet such frame (first input frame).
  9044. @item zoom
  9045. Last calculated zoom from 'z' expression for current input frame.
  9046. @item pzoom
  9047. Last calculated zoom of last output frame of previous input frame.
  9048. @item duration
  9049. Number of output frames for current input frame. Calculated from 'd' expression
  9050. for each input frame.
  9051. @item pduration
  9052. number of output frames created for previous input frame
  9053. @item a
  9054. Rational number: input width / input height
  9055. @item sar
  9056. sample aspect ratio
  9057. @item dar
  9058. display aspect ratio
  9059. @end table
  9060. @subsection Examples
  9061. @itemize
  9062. @item
  9063. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  9064. @example
  9065. 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
  9066. @end example
  9067. @item
  9068. Zoom-in up to 1.5 and pan always at center of picture:
  9069. @example
  9070. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  9071. @end example
  9072. @end itemize
  9073. @section zscale
  9074. Scale (resize) the input video, using the z.lib library:
  9075. https://github.com/sekrit-twc/zimg.
  9076. The zscale filter forces the output display aspect ratio to be the same
  9077. as the input, by changing the output sample aspect ratio.
  9078. If the input image format is different from the format requested by
  9079. the next filter, the zscale filter will convert the input to the
  9080. requested format.
  9081. @subsection Options
  9082. The filter accepts the following options.
  9083. @table @option
  9084. @item width, w
  9085. @item height, h
  9086. Set the output video dimension expression. Default value is the input
  9087. dimension.
  9088. If the @var{width} or @var{w} is 0, the input width is used for the output.
  9089. If the @var{height} or @var{h} is 0, the input height is used for the output.
  9090. If one of the values is -1, the zscale filter will use a value that
  9091. maintains the aspect ratio of the input image, calculated from the
  9092. other specified dimension. If both of them are -1, the input size is
  9093. used
  9094. If one of the values is -n with n > 1, the zscale filter will also use a value
  9095. that maintains the aspect ratio of the input image, calculated from the other
  9096. specified dimension. After that it will, however, make sure that the calculated
  9097. dimension is divisible by n and adjust the value if necessary.
  9098. See below for the list of accepted constants for use in the dimension
  9099. expression.
  9100. @item size, s
  9101. Set the video size. For the syntax of this option, check the
  9102. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9103. @item dither, d
  9104. Set the dither type.
  9105. Possible values are:
  9106. @table @var
  9107. @item none
  9108. @item ordered
  9109. @item random
  9110. @item error_diffusion
  9111. @end table
  9112. Default is none.
  9113. @item filter, f
  9114. Set the resize filter type.
  9115. Possible values are:
  9116. @table @var
  9117. @item point
  9118. @item bilinear
  9119. @item bicubic
  9120. @item spline16
  9121. @item spline36
  9122. @item lanczos
  9123. @end table
  9124. Default is bilinear.
  9125. @item range, r
  9126. Set the color range.
  9127. Possible values are:
  9128. @table @var
  9129. @item input
  9130. @item limited
  9131. @item full
  9132. @end table
  9133. Default is same as input.
  9134. @item primaries, p
  9135. Set the color primaries.
  9136. Possible values are:
  9137. @table @var
  9138. @item input
  9139. @item 709
  9140. @item unspecified
  9141. @item 170m
  9142. @item 240m
  9143. @item 2020
  9144. @end table
  9145. Default is same as input.
  9146. @item transfer, t
  9147. Set the transfer characteristics.
  9148. Possible values are:
  9149. @table @var
  9150. @item input
  9151. @item 709
  9152. @item unspecified
  9153. @item 601
  9154. @item linear
  9155. @item 2020_10
  9156. @item 2020_12
  9157. @end table
  9158. Default is same as input.
  9159. @item matrix, m
  9160. Set the colorspace matrix.
  9161. Possible value are:
  9162. @table @var
  9163. @item input
  9164. @item 709
  9165. @item unspecified
  9166. @item 470bg
  9167. @item 170m
  9168. @item 2020_ncl
  9169. @item 2020_cl
  9170. @end table
  9171. Default is same as input.
  9172. @end table
  9173. The values of the @option{w} and @option{h} options are expressions
  9174. containing the following constants:
  9175. @table @var
  9176. @item in_w
  9177. @item in_h
  9178. The input width and height
  9179. @item iw
  9180. @item ih
  9181. These are the same as @var{in_w} and @var{in_h}.
  9182. @item out_w
  9183. @item out_h
  9184. The output (scaled) width and height
  9185. @item ow
  9186. @item oh
  9187. These are the same as @var{out_w} and @var{out_h}
  9188. @item a
  9189. The same as @var{iw} / @var{ih}
  9190. @item sar
  9191. input sample aspect ratio
  9192. @item dar
  9193. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  9194. @item hsub
  9195. @item vsub
  9196. horizontal and vertical input chroma subsample values. For example for the
  9197. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9198. @item ohsub
  9199. @item ovsub
  9200. horizontal and vertical output chroma subsample values. For example for the
  9201. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9202. @end table
  9203. @table @option
  9204. @end table
  9205. @c man end VIDEO FILTERS
  9206. @chapter Video Sources
  9207. @c man begin VIDEO SOURCES
  9208. Below is a description of the currently available video sources.
  9209. @section buffer
  9210. Buffer video frames, and make them available to the filter chain.
  9211. This source is mainly intended for a programmatic use, in particular
  9212. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  9213. It accepts the following parameters:
  9214. @table @option
  9215. @item video_size
  9216. Specify the size (width and height) of the buffered video frames. For the
  9217. syntax of this option, check the
  9218. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9219. @item width
  9220. The input video width.
  9221. @item height
  9222. The input video height.
  9223. @item pix_fmt
  9224. A string representing the pixel format of the buffered video frames.
  9225. It may be a number corresponding to a pixel format, or a pixel format
  9226. name.
  9227. @item time_base
  9228. Specify the timebase assumed by the timestamps of the buffered frames.
  9229. @item frame_rate
  9230. Specify the frame rate expected for the video stream.
  9231. @item pixel_aspect, sar
  9232. The sample (pixel) aspect ratio of the input video.
  9233. @item sws_param
  9234. Specify the optional parameters to be used for the scale filter which
  9235. is automatically inserted when an input change is detected in the
  9236. input size or format.
  9237. @end table
  9238. For example:
  9239. @example
  9240. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  9241. @end example
  9242. will instruct the source to accept video frames with size 320x240 and
  9243. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  9244. square pixels (1:1 sample aspect ratio).
  9245. Since the pixel format with name "yuv410p" corresponds to the number 6
  9246. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  9247. this example corresponds to:
  9248. @example
  9249. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  9250. @end example
  9251. Alternatively, the options can be specified as a flat string, but this
  9252. syntax is deprecated:
  9253. @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}]
  9254. @section cellauto
  9255. Create a pattern generated by an elementary cellular automaton.
  9256. The initial state of the cellular automaton can be defined through the
  9257. @option{filename}, and @option{pattern} options. If such options are
  9258. not specified an initial state is created randomly.
  9259. At each new frame a new row in the video is filled with the result of
  9260. the cellular automaton next generation. The behavior when the whole
  9261. frame is filled is defined by the @option{scroll} option.
  9262. This source accepts the following options:
  9263. @table @option
  9264. @item filename, f
  9265. Read the initial cellular automaton state, i.e. the starting row, from
  9266. the specified file.
  9267. In the file, each non-whitespace character is considered an alive
  9268. cell, a newline will terminate the row, and further characters in the
  9269. file will be ignored.
  9270. @item pattern, p
  9271. Read the initial cellular automaton state, i.e. the starting row, from
  9272. the specified string.
  9273. Each non-whitespace character in the string is considered an alive
  9274. cell, a newline will terminate the row, and further characters in the
  9275. string will be ignored.
  9276. @item rate, r
  9277. Set the video rate, that is the number of frames generated per second.
  9278. Default is 25.
  9279. @item random_fill_ratio, ratio
  9280. Set the random fill ratio for the initial cellular automaton row. It
  9281. is a floating point number value ranging from 0 to 1, defaults to
  9282. 1/PHI.
  9283. This option is ignored when a file or a pattern is specified.
  9284. @item random_seed, seed
  9285. Set the seed for filling randomly the initial row, must be an integer
  9286. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9287. set to -1, the filter will try to use a good random seed on a best
  9288. effort basis.
  9289. @item rule
  9290. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  9291. Default value is 110.
  9292. @item size, s
  9293. Set the size of the output video. For the syntax of this option, check the
  9294. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9295. If @option{filename} or @option{pattern} is specified, the size is set
  9296. by default to the width of the specified initial state row, and the
  9297. height is set to @var{width} * PHI.
  9298. If @option{size} is set, it must contain the width of the specified
  9299. pattern string, and the specified pattern will be centered in the
  9300. larger row.
  9301. If a filename or a pattern string is not specified, the size value
  9302. defaults to "320x518" (used for a randomly generated initial state).
  9303. @item scroll
  9304. If set to 1, scroll the output upward when all the rows in the output
  9305. have been already filled. If set to 0, the new generated row will be
  9306. written over the top row just after the bottom row is filled.
  9307. Defaults to 1.
  9308. @item start_full, full
  9309. If set to 1, completely fill the output with generated rows before
  9310. outputting the first frame.
  9311. This is the default behavior, for disabling set the value to 0.
  9312. @item stitch
  9313. If set to 1, stitch the left and right row edges together.
  9314. This is the default behavior, for disabling set the value to 0.
  9315. @end table
  9316. @subsection Examples
  9317. @itemize
  9318. @item
  9319. Read the initial state from @file{pattern}, and specify an output of
  9320. size 200x400.
  9321. @example
  9322. cellauto=f=pattern:s=200x400
  9323. @end example
  9324. @item
  9325. Generate a random initial row with a width of 200 cells, with a fill
  9326. ratio of 2/3:
  9327. @example
  9328. cellauto=ratio=2/3:s=200x200
  9329. @end example
  9330. @item
  9331. Create a pattern generated by rule 18 starting by a single alive cell
  9332. centered on an initial row with width 100:
  9333. @example
  9334. cellauto=p=@@:s=100x400:full=0:rule=18
  9335. @end example
  9336. @item
  9337. Specify a more elaborated initial pattern:
  9338. @example
  9339. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  9340. @end example
  9341. @end itemize
  9342. @section mandelbrot
  9343. Generate a Mandelbrot set fractal, and progressively zoom towards the
  9344. point specified with @var{start_x} and @var{start_y}.
  9345. This source accepts the following options:
  9346. @table @option
  9347. @item end_pts
  9348. Set the terminal pts value. Default value is 400.
  9349. @item end_scale
  9350. Set the terminal scale value.
  9351. Must be a floating point value. Default value is 0.3.
  9352. @item inner
  9353. Set the inner coloring mode, that is the algorithm used to draw the
  9354. Mandelbrot fractal internal region.
  9355. It shall assume one of the following values:
  9356. @table @option
  9357. @item black
  9358. Set black mode.
  9359. @item convergence
  9360. Show time until convergence.
  9361. @item mincol
  9362. Set color based on point closest to the origin of the iterations.
  9363. @item period
  9364. Set period mode.
  9365. @end table
  9366. Default value is @var{mincol}.
  9367. @item bailout
  9368. Set the bailout value. Default value is 10.0.
  9369. @item maxiter
  9370. Set the maximum of iterations performed by the rendering
  9371. algorithm. Default value is 7189.
  9372. @item outer
  9373. Set outer coloring mode.
  9374. It shall assume one of following values:
  9375. @table @option
  9376. @item iteration_count
  9377. Set iteration cound mode.
  9378. @item normalized_iteration_count
  9379. set normalized iteration count mode.
  9380. @end table
  9381. Default value is @var{normalized_iteration_count}.
  9382. @item rate, r
  9383. Set frame rate, expressed as number of frames per second. Default
  9384. value is "25".
  9385. @item size, s
  9386. Set frame size. For the syntax of this option, check the "Video
  9387. size" section in the ffmpeg-utils manual. Default value is "640x480".
  9388. @item start_scale
  9389. Set the initial scale value. Default value is 3.0.
  9390. @item start_x
  9391. Set the initial x position. Must be a floating point value between
  9392. -100 and 100. Default value is -0.743643887037158704752191506114774.
  9393. @item start_y
  9394. Set the initial y position. Must be a floating point value between
  9395. -100 and 100. Default value is -0.131825904205311970493132056385139.
  9396. @end table
  9397. @section mptestsrc
  9398. Generate various test patterns, as generated by the MPlayer test filter.
  9399. The size of the generated video is fixed, and is 256x256.
  9400. This source is useful in particular for testing encoding features.
  9401. This source accepts the following options:
  9402. @table @option
  9403. @item rate, r
  9404. Specify the frame rate of the sourced video, as the number of frames
  9405. generated per second. It has to be a string in the format
  9406. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9407. number or a valid video frame rate abbreviation. The default value is
  9408. "25".
  9409. @item duration, d
  9410. Set the duration of the sourced video. See
  9411. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9412. for the accepted syntax.
  9413. If not specified, or the expressed duration is negative, the video is
  9414. supposed to be generated forever.
  9415. @item test, t
  9416. Set the number or the name of the test to perform. Supported tests are:
  9417. @table @option
  9418. @item dc_luma
  9419. @item dc_chroma
  9420. @item freq_luma
  9421. @item freq_chroma
  9422. @item amp_luma
  9423. @item amp_chroma
  9424. @item cbp
  9425. @item mv
  9426. @item ring1
  9427. @item ring2
  9428. @item all
  9429. @end table
  9430. Default value is "all", which will cycle through the list of all tests.
  9431. @end table
  9432. Some examples:
  9433. @example
  9434. mptestsrc=t=dc_luma
  9435. @end example
  9436. will generate a "dc_luma" test pattern.
  9437. @section frei0r_src
  9438. Provide a frei0r source.
  9439. To enable compilation of this filter you need to install the frei0r
  9440. header and configure FFmpeg with @code{--enable-frei0r}.
  9441. This source accepts the following parameters:
  9442. @table @option
  9443. @item size
  9444. The size of the video to generate. For the syntax of this option, check the
  9445. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9446. @item framerate
  9447. The framerate of the generated video. It may be a string of the form
  9448. @var{num}/@var{den} or a frame rate abbreviation.
  9449. @item filter_name
  9450. The name to the frei0r source to load. For more information regarding frei0r and
  9451. how to set the parameters, read the @ref{frei0r} section in the video filters
  9452. documentation.
  9453. @item filter_params
  9454. A '|'-separated list of parameters to pass to the frei0r source.
  9455. @end table
  9456. For example, to generate a frei0r partik0l source with size 200x200
  9457. and frame rate 10 which is overlaid on the overlay filter main input:
  9458. @example
  9459. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  9460. @end example
  9461. @section life
  9462. Generate a life pattern.
  9463. This source is based on a generalization of John Conway's life game.
  9464. The sourced input represents a life grid, each pixel represents a cell
  9465. which can be in one of two possible states, alive or dead. Every cell
  9466. interacts with its eight neighbours, which are the cells that are
  9467. horizontally, vertically, or diagonally adjacent.
  9468. At each interaction the grid evolves according to the adopted rule,
  9469. which specifies the number of neighbor alive cells which will make a
  9470. cell stay alive or born. The @option{rule} option allows one to specify
  9471. the rule to adopt.
  9472. This source accepts the following options:
  9473. @table @option
  9474. @item filename, f
  9475. Set the file from which to read the initial grid state. In the file,
  9476. each non-whitespace character is considered an alive cell, and newline
  9477. is used to delimit the end of each row.
  9478. If this option is not specified, the initial grid is generated
  9479. randomly.
  9480. @item rate, r
  9481. Set the video rate, that is the number of frames generated per second.
  9482. Default is 25.
  9483. @item random_fill_ratio, ratio
  9484. Set the random fill ratio for the initial random grid. It is a
  9485. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  9486. It is ignored when a file is specified.
  9487. @item random_seed, seed
  9488. Set the seed for filling the initial random grid, must be an integer
  9489. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9490. set to -1, the filter will try to use a good random seed on a best
  9491. effort basis.
  9492. @item rule
  9493. Set the life rule.
  9494. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  9495. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  9496. @var{NS} specifies the number of alive neighbor cells which make a
  9497. live cell stay alive, and @var{NB} the number of alive neighbor cells
  9498. which make a dead cell to become alive (i.e. to "born").
  9499. "s" and "b" can be used in place of "S" and "B", respectively.
  9500. Alternatively a rule can be specified by an 18-bits integer. The 9
  9501. high order bits are used to encode the next cell state if it is alive
  9502. for each number of neighbor alive cells, the low order bits specify
  9503. the rule for "borning" new cells. Higher order bits encode for an
  9504. higher number of neighbor cells.
  9505. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  9506. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  9507. Default value is "S23/B3", which is the original Conway's game of life
  9508. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  9509. cells, and will born a new cell if there are three alive cells around
  9510. a dead cell.
  9511. @item size, s
  9512. Set the size of the output video. For the syntax of this option, check the
  9513. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9514. If @option{filename} is specified, the size is set by default to the
  9515. same size of the input file. If @option{size} is set, it must contain
  9516. the size specified in the input file, and the initial grid defined in
  9517. that file is centered in the larger resulting area.
  9518. If a filename is not specified, the size value defaults to "320x240"
  9519. (used for a randomly generated initial grid).
  9520. @item stitch
  9521. If set to 1, stitch the left and right grid edges together, and the
  9522. top and bottom edges also. Defaults to 1.
  9523. @item mold
  9524. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9525. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9526. value from 0 to 255.
  9527. @item life_color
  9528. Set the color of living (or new born) cells.
  9529. @item death_color
  9530. Set the color of dead cells. If @option{mold} is set, this is the first color
  9531. used to represent a dead cell.
  9532. @item mold_color
  9533. Set mold color, for definitely dead and moldy cells.
  9534. For the syntax of these 3 color options, check the "Color" section in the
  9535. ffmpeg-utils manual.
  9536. @end table
  9537. @subsection Examples
  9538. @itemize
  9539. @item
  9540. Read a grid from @file{pattern}, and center it on a grid of size
  9541. 300x300 pixels:
  9542. @example
  9543. life=f=pattern:s=300x300
  9544. @end example
  9545. @item
  9546. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9547. @example
  9548. life=ratio=2/3:s=200x200
  9549. @end example
  9550. @item
  9551. Specify a custom rule for evolving a randomly generated grid:
  9552. @example
  9553. life=rule=S14/B34
  9554. @end example
  9555. @item
  9556. Full example with slow death effect (mold) using @command{ffplay}:
  9557. @example
  9558. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9559. @end example
  9560. @end itemize
  9561. @anchor{allrgb}
  9562. @anchor{allyuv}
  9563. @anchor{color}
  9564. @anchor{haldclutsrc}
  9565. @anchor{nullsrc}
  9566. @anchor{rgbtestsrc}
  9567. @anchor{smptebars}
  9568. @anchor{smptehdbars}
  9569. @anchor{testsrc}
  9570. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9571. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9572. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9573. The @code{color} source provides an uniformly colored input.
  9574. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9575. @ref{haldclut} filter.
  9576. The @code{nullsrc} source returns unprocessed video frames. It is
  9577. mainly useful to be employed in analysis / debugging tools, or as the
  9578. source for filters which ignore the input data.
  9579. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9580. detecting RGB vs BGR issues. You should see a red, green and blue
  9581. stripe from top to bottom.
  9582. The @code{smptebars} source generates a color bars pattern, based on
  9583. the SMPTE Engineering Guideline EG 1-1990.
  9584. The @code{smptehdbars} source generates a color bars pattern, based on
  9585. the SMPTE RP 219-2002.
  9586. The @code{testsrc} source generates a test video pattern, showing a
  9587. color pattern, a scrolling gradient and a timestamp. This is mainly
  9588. intended for testing purposes.
  9589. The sources accept the following parameters:
  9590. @table @option
  9591. @item color, c
  9592. Specify the color of the source, only available in the @code{color}
  9593. source. For the syntax of this option, check the "Color" section in the
  9594. ffmpeg-utils manual.
  9595. @item level
  9596. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9597. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9598. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9599. coded on a @code{1/(N*N)} scale.
  9600. @item size, s
  9601. Specify the size of the sourced video. For the syntax of this option, check the
  9602. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9603. The default value is @code{320x240}.
  9604. This option is not available with the @code{haldclutsrc} filter.
  9605. @item rate, r
  9606. Specify the frame rate of the sourced video, as the number of frames
  9607. generated per second. It has to be a string in the format
  9608. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9609. number or a valid video frame rate abbreviation. The default value is
  9610. "25".
  9611. @item sar
  9612. Set the sample aspect ratio of the sourced video.
  9613. @item duration, d
  9614. Set the duration of the sourced video. See
  9615. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9616. for the accepted syntax.
  9617. If not specified, or the expressed duration is negative, the video is
  9618. supposed to be generated forever.
  9619. @item decimals, n
  9620. Set the number of decimals to show in the timestamp, only available in the
  9621. @code{testsrc} source.
  9622. The displayed timestamp value will correspond to the original
  9623. timestamp value multiplied by the power of 10 of the specified
  9624. value. Default value is 0.
  9625. @end table
  9626. For example the following:
  9627. @example
  9628. testsrc=duration=5.3:size=qcif:rate=10
  9629. @end example
  9630. will generate a video with a duration of 5.3 seconds, with size
  9631. 176x144 and a frame rate of 10 frames per second.
  9632. The following graph description will generate a red source
  9633. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9634. frames per second.
  9635. @example
  9636. color=c=red@@0.2:s=qcif:r=10
  9637. @end example
  9638. If the input content is to be ignored, @code{nullsrc} can be used. The
  9639. following command generates noise in the luminance plane by employing
  9640. the @code{geq} filter:
  9641. @example
  9642. nullsrc=s=256x256, geq=random(1)*255:128:128
  9643. @end example
  9644. @subsection Commands
  9645. The @code{color} source supports the following commands:
  9646. @table @option
  9647. @item c, color
  9648. Set the color of the created image. Accepts the same syntax of the
  9649. corresponding @option{color} option.
  9650. @end table
  9651. @c man end VIDEO SOURCES
  9652. @chapter Video Sinks
  9653. @c man begin VIDEO SINKS
  9654. Below is a description of the currently available video sinks.
  9655. @section buffersink
  9656. Buffer video frames, and make them available to the end of the filter
  9657. graph.
  9658. This sink is mainly intended for programmatic use, in particular
  9659. through the interface defined in @file{libavfilter/buffersink.h}
  9660. or the options system.
  9661. It accepts a pointer to an AVBufferSinkContext structure, which
  9662. defines the incoming buffers' formats, to be passed as the opaque
  9663. parameter to @code{avfilter_init_filter} for initialization.
  9664. @section nullsink
  9665. Null video sink: do absolutely nothing with the input video. It is
  9666. mainly useful as a template and for use in analysis / debugging
  9667. tools.
  9668. @c man end VIDEO SINKS
  9669. @chapter Multimedia Filters
  9670. @c man begin MULTIMEDIA FILTERS
  9671. Below is a description of the currently available multimedia filters.
  9672. @section aphasemeter
  9673. Convert input audio to a video output, displaying the audio phase.
  9674. The filter accepts the following options:
  9675. @table @option
  9676. @item rate, r
  9677. Set the output frame rate. Default value is @code{25}.
  9678. @item size, s
  9679. Set the video size for the output. For the syntax of this option, check the
  9680. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9681. Default value is @code{800x400}.
  9682. @item rc
  9683. @item gc
  9684. @item bc
  9685. Specify the red, green, blue contrast. Default values are @code{2},
  9686. @code{7} and @code{1}.
  9687. Allowed range is @code{[0, 255]}.
  9688. @item mpc
  9689. Set color which will be used for drawing median phase. If color is
  9690. @code{none} which is default, no median phase value will be drawn.
  9691. @end table
  9692. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9693. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9694. The @code{-1} means left and right channels are completely out of phase and
  9695. @code{1} means channels are in phase.
  9696. @section avectorscope
  9697. Convert input audio to a video output, representing the audio vector
  9698. scope.
  9699. The filter is used to measure the difference between channels of stereo
  9700. audio stream. A monoaural signal, consisting of identical left and right
  9701. signal, results in straight vertical line. Any stereo separation is visible
  9702. as a deviation from this line, creating a Lissajous figure.
  9703. If the straight (or deviation from it) but horizontal line appears this
  9704. indicates that the left and right channels are out of phase.
  9705. The filter accepts the following options:
  9706. @table @option
  9707. @item mode, m
  9708. Set the vectorscope mode.
  9709. Available values are:
  9710. @table @samp
  9711. @item lissajous
  9712. Lissajous rotated by 45 degrees.
  9713. @item lissajous_xy
  9714. Same as above but not rotated.
  9715. @item polar
  9716. Shape resembling half of circle.
  9717. @end table
  9718. Default value is @samp{lissajous}.
  9719. @item size, s
  9720. Set the video size for the output. For the syntax of this option, check the
  9721. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9722. Default value is @code{400x400}.
  9723. @item rate, r
  9724. Set the output frame rate. Default value is @code{25}.
  9725. @item rc
  9726. @item gc
  9727. @item bc
  9728. @item ac
  9729. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9730. @code{160}, @code{80} and @code{255}.
  9731. Allowed range is @code{[0, 255]}.
  9732. @item rf
  9733. @item gf
  9734. @item bf
  9735. @item af
  9736. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9737. @code{10}, @code{5} and @code{5}.
  9738. Allowed range is @code{[0, 255]}.
  9739. @item zoom
  9740. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9741. @end table
  9742. @subsection Examples
  9743. @itemize
  9744. @item
  9745. Complete example using @command{ffplay}:
  9746. @example
  9747. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9748. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9749. @end example
  9750. @end itemize
  9751. @section concat
  9752. Concatenate audio and video streams, joining them together one after the
  9753. other.
  9754. The filter works on segments of synchronized video and audio streams. All
  9755. segments must have the same number of streams of each type, and that will
  9756. also be the number of streams at output.
  9757. The filter accepts the following options:
  9758. @table @option
  9759. @item n
  9760. Set the number of segments. Default is 2.
  9761. @item v
  9762. Set the number of output video streams, that is also the number of video
  9763. streams in each segment. Default is 1.
  9764. @item a
  9765. Set the number of output audio streams, that is also the number of audio
  9766. streams in each segment. Default is 0.
  9767. @item unsafe
  9768. Activate unsafe mode: do not fail if segments have a different format.
  9769. @end table
  9770. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9771. @var{a} audio outputs.
  9772. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9773. segment, in the same order as the outputs, then the inputs for the second
  9774. segment, etc.
  9775. Related streams do not always have exactly the same duration, for various
  9776. reasons including codec frame size or sloppy authoring. For that reason,
  9777. related synchronized streams (e.g. a video and its audio track) should be
  9778. concatenated at once. The concat filter will use the duration of the longest
  9779. stream in each segment (except the last one), and if necessary pad shorter
  9780. audio streams with silence.
  9781. For this filter to work correctly, all segments must start at timestamp 0.
  9782. All corresponding streams must have the same parameters in all segments; the
  9783. filtering system will automatically select a common pixel format for video
  9784. streams, and a common sample format, sample rate and channel layout for
  9785. audio streams, but other settings, such as resolution, must be converted
  9786. explicitly by the user.
  9787. Different frame rates are acceptable but will result in variable frame rate
  9788. at output; be sure to configure the output file to handle it.
  9789. @subsection Examples
  9790. @itemize
  9791. @item
  9792. Concatenate an opening, an episode and an ending, all in bilingual version
  9793. (video in stream 0, audio in streams 1 and 2):
  9794. @example
  9795. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9796. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9797. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9798. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9799. @end example
  9800. @item
  9801. Concatenate two parts, handling audio and video separately, using the
  9802. (a)movie sources, and adjusting the resolution:
  9803. @example
  9804. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9805. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9806. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9807. @end example
  9808. Note that a desync will happen at the stitch if the audio and video streams
  9809. do not have exactly the same duration in the first file.
  9810. @end itemize
  9811. @anchor{ebur128}
  9812. @section ebur128
  9813. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9814. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9815. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9816. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9817. The filter also has a video output (see the @var{video} option) with a real
  9818. time graph to observe the loudness evolution. The graphic contains the logged
  9819. message mentioned above, so it is not printed anymore when this option is set,
  9820. unless the verbose logging is set. The main graphing area contains the
  9821. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9822. the momentary loudness (400 milliseconds).
  9823. More information about the Loudness Recommendation EBU R128 on
  9824. @url{http://tech.ebu.ch/loudness}.
  9825. The filter accepts the following options:
  9826. @table @option
  9827. @item video
  9828. Activate the video output. The audio stream is passed unchanged whether this
  9829. option is set or no. The video stream will be the first output stream if
  9830. activated. Default is @code{0}.
  9831. @item size
  9832. Set the video size. This option is for video only. For the syntax of this
  9833. option, check the
  9834. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9835. Default and minimum resolution is @code{640x480}.
  9836. @item meter
  9837. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9838. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9839. other integer value between this range is allowed.
  9840. @item metadata
  9841. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9842. into 100ms output frames, each of them containing various loudness information
  9843. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9844. Default is @code{0}.
  9845. @item framelog
  9846. Force the frame logging level.
  9847. Available values are:
  9848. @table @samp
  9849. @item info
  9850. information logging level
  9851. @item verbose
  9852. verbose logging level
  9853. @end table
  9854. By default, the logging level is set to @var{info}. If the @option{video} or
  9855. the @option{metadata} options are set, it switches to @var{verbose}.
  9856. @item peak
  9857. Set peak mode(s).
  9858. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9859. values are:
  9860. @table @samp
  9861. @item none
  9862. Disable any peak mode (default).
  9863. @item sample
  9864. Enable sample-peak mode.
  9865. Simple peak mode looking for the higher sample value. It logs a message
  9866. for sample-peak (identified by @code{SPK}).
  9867. @item true
  9868. Enable true-peak mode.
  9869. If enabled, the peak lookup is done on an over-sampled version of the input
  9870. stream for better peak accuracy. It logs a message for true-peak.
  9871. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9872. This mode requires a build with @code{libswresample}.
  9873. @end table
  9874. @item dualmono
  9875. Treat mono input files as "dual mono". If a mono file is intended for playback
  9876. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  9877. If set to @code{true}, this option will compensate for this effect.
  9878. Multi-channel input files are not affected by this option.
  9879. @item panlaw
  9880. Set a specific pan law to be used for the measurement of dual mono files.
  9881. This parameter is optional, and has a default value of -3.01dB.
  9882. @end table
  9883. @subsection Examples
  9884. @itemize
  9885. @item
  9886. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9887. @example
  9888. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9889. @end example
  9890. @item
  9891. Run an analysis with @command{ffmpeg}:
  9892. @example
  9893. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9894. @end example
  9895. @end itemize
  9896. @section interleave, ainterleave
  9897. Temporally interleave frames from several inputs.
  9898. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9899. These filters read frames from several inputs and send the oldest
  9900. queued frame to the output.
  9901. Input streams must have a well defined, monotonically increasing frame
  9902. timestamp values.
  9903. In order to submit one frame to output, these filters need to enqueue
  9904. at least one frame for each input, so they cannot work in case one
  9905. input is not yet terminated and will not receive incoming frames.
  9906. For example consider the case when one input is a @code{select} filter
  9907. which always drop input frames. The @code{interleave} filter will keep
  9908. reading from that input, but it will never be able to send new frames
  9909. to output until the input will send an end-of-stream signal.
  9910. Also, depending on inputs synchronization, the filters will drop
  9911. frames in case one input receives more frames than the other ones, and
  9912. the queue is already filled.
  9913. These filters accept the following options:
  9914. @table @option
  9915. @item nb_inputs, n
  9916. Set the number of different inputs, it is 2 by default.
  9917. @end table
  9918. @subsection Examples
  9919. @itemize
  9920. @item
  9921. Interleave frames belonging to different streams using @command{ffmpeg}:
  9922. @example
  9923. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9924. @end example
  9925. @item
  9926. Add flickering blur effect:
  9927. @example
  9928. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9929. @end example
  9930. @end itemize
  9931. @section perms, aperms
  9932. Set read/write permissions for the output frames.
  9933. These filters are mainly aimed at developers to test direct path in the
  9934. following filter in the filtergraph.
  9935. The filters accept the following options:
  9936. @table @option
  9937. @item mode
  9938. Select the permissions mode.
  9939. It accepts the following values:
  9940. @table @samp
  9941. @item none
  9942. Do nothing. This is the default.
  9943. @item ro
  9944. Set all the output frames read-only.
  9945. @item rw
  9946. Set all the output frames directly writable.
  9947. @item toggle
  9948. Make the frame read-only if writable, and writable if read-only.
  9949. @item random
  9950. Set each output frame read-only or writable randomly.
  9951. @end table
  9952. @item seed
  9953. Set the seed for the @var{random} mode, must be an integer included between
  9954. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9955. @code{-1}, the filter will try to use a good random seed on a best effort
  9956. basis.
  9957. @end table
  9958. Note: in case of auto-inserted filter between the permission filter and the
  9959. following one, the permission might not be received as expected in that
  9960. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9961. perms/aperms filter can avoid this problem.
  9962. @section realtime, arealtime
  9963. Slow down filtering to match real time approximatively.
  9964. These filters will pause the filtering for a variable amount of time to
  9965. match the output rate with the input timestamps.
  9966. They are similar to the @option{re} option to @code{ffmpeg}.
  9967. They accept the following options:
  9968. @table @option
  9969. @item limit
  9970. Time limit for the pauses. Any pause longer than that will be considered
  9971. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  9972. @end table
  9973. @section select, aselect
  9974. Select frames to pass in output.
  9975. This filter accepts the following options:
  9976. @table @option
  9977. @item expr, e
  9978. Set expression, which is evaluated for each input frame.
  9979. If the expression is evaluated to zero, the frame is discarded.
  9980. If the evaluation result is negative or NaN, the frame is sent to the
  9981. first output; otherwise it is sent to the output with index
  9982. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9983. For example a value of @code{1.2} corresponds to the output with index
  9984. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9985. @item outputs, n
  9986. Set the number of outputs. The output to which to send the selected
  9987. frame is based on the result of the evaluation. Default value is 1.
  9988. @end table
  9989. The expression can contain the following constants:
  9990. @table @option
  9991. @item n
  9992. The (sequential) number of the filtered frame, starting from 0.
  9993. @item selected_n
  9994. The (sequential) number of the selected frame, starting from 0.
  9995. @item prev_selected_n
  9996. The sequential number of the last selected frame. It's NAN if undefined.
  9997. @item TB
  9998. The timebase of the input timestamps.
  9999. @item pts
  10000. The PTS (Presentation TimeStamp) of the filtered video frame,
  10001. expressed in @var{TB} units. It's NAN if undefined.
  10002. @item t
  10003. The PTS of the filtered video frame,
  10004. expressed in seconds. It's NAN if undefined.
  10005. @item prev_pts
  10006. The PTS of the previously filtered video frame. It's NAN if undefined.
  10007. @item prev_selected_pts
  10008. The PTS of the last previously filtered video frame. It's NAN if undefined.
  10009. @item prev_selected_t
  10010. The PTS of the last previously selected video frame. It's NAN if undefined.
  10011. @item start_pts
  10012. The PTS of the first video frame in the video. It's NAN if undefined.
  10013. @item start_t
  10014. The time of the first video frame in the video. It's NAN if undefined.
  10015. @item pict_type @emph{(video only)}
  10016. The type of the filtered frame. It can assume one of the following
  10017. values:
  10018. @table @option
  10019. @item I
  10020. @item P
  10021. @item B
  10022. @item S
  10023. @item SI
  10024. @item SP
  10025. @item BI
  10026. @end table
  10027. @item interlace_type @emph{(video only)}
  10028. The frame interlace type. It can assume one of the following values:
  10029. @table @option
  10030. @item PROGRESSIVE
  10031. The frame is progressive (not interlaced).
  10032. @item TOPFIRST
  10033. The frame is top-field-first.
  10034. @item BOTTOMFIRST
  10035. The frame is bottom-field-first.
  10036. @end table
  10037. @item consumed_sample_n @emph{(audio only)}
  10038. the number of selected samples before the current frame
  10039. @item samples_n @emph{(audio only)}
  10040. the number of samples in the current frame
  10041. @item sample_rate @emph{(audio only)}
  10042. the input sample rate
  10043. @item key
  10044. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  10045. @item pos
  10046. the position in the file of the filtered frame, -1 if the information
  10047. is not available (e.g. for synthetic video)
  10048. @item scene @emph{(video only)}
  10049. value between 0 and 1 to indicate a new scene; a low value reflects a low
  10050. probability for the current frame to introduce a new scene, while a higher
  10051. value means the current frame is more likely to be one (see the example below)
  10052. @end table
  10053. The default value of the select expression is "1".
  10054. @subsection Examples
  10055. @itemize
  10056. @item
  10057. Select all frames in input:
  10058. @example
  10059. select
  10060. @end example
  10061. The example above is the same as:
  10062. @example
  10063. select=1
  10064. @end example
  10065. @item
  10066. Skip all frames:
  10067. @example
  10068. select=0
  10069. @end example
  10070. @item
  10071. Select only I-frames:
  10072. @example
  10073. select='eq(pict_type\,I)'
  10074. @end example
  10075. @item
  10076. Select one frame every 100:
  10077. @example
  10078. select='not(mod(n\,100))'
  10079. @end example
  10080. @item
  10081. Select only frames contained in the 10-20 time interval:
  10082. @example
  10083. select=between(t\,10\,20)
  10084. @end example
  10085. @item
  10086. Select only I frames contained in the 10-20 time interval:
  10087. @example
  10088. select=between(t\,10\,20)*eq(pict_type\,I)
  10089. @end example
  10090. @item
  10091. Select frames with a minimum distance of 10 seconds:
  10092. @example
  10093. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  10094. @end example
  10095. @item
  10096. Use aselect to select only audio frames with samples number > 100:
  10097. @example
  10098. aselect='gt(samples_n\,100)'
  10099. @end example
  10100. @item
  10101. Create a mosaic of the first scenes:
  10102. @example
  10103. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  10104. @end example
  10105. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  10106. choice.
  10107. @item
  10108. Send even and odd frames to separate outputs, and compose them:
  10109. @example
  10110. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  10111. @end example
  10112. @end itemize
  10113. @section selectivecolor
  10114. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  10115. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  10116. by the "purity" of the color (that is, how saturated it already is).
  10117. This filter is similar to the Adobe Photoshop Selective Color tool.
  10118. The filter accepts the following options:
  10119. @table @option
  10120. @item correction_method
  10121. Select color correction method.
  10122. Available values are:
  10123. @table @samp
  10124. @item absolute
  10125. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  10126. component value).
  10127. @item relative
  10128. Specified adjustments are relative to the original component value.
  10129. @end table
  10130. Default is @code{absolute}.
  10131. @item reds
  10132. Adjustments for red pixels (pixels where the red component is the maximum)
  10133. @item yellows
  10134. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  10135. @item greens
  10136. Adjustments for green pixels (pixels where the green component is the maximum)
  10137. @item cyans
  10138. Adjustments for cyan pixels (pixels where the red component is the minimum)
  10139. @item blues
  10140. Adjustments for blue pixels (pixels where the blue component is the maximum)
  10141. @item magentas
  10142. Adjustments for magenta pixels (pixels where the green component is the minimum)
  10143. @item whites
  10144. Adjustments for white pixels (pixels where all components are greater than 128)
  10145. @item neutrals
  10146. Adjustments for all pixels except pure black and pure white
  10147. @item blacks
  10148. Adjustments for black pixels (pixels where all components are lesser than 128)
  10149. @item psfile
  10150. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  10151. @end table
  10152. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  10153. 4 space separated floating point adjustment values in the [-1,1] range,
  10154. respectively to adjust the amount of cyan, magenta, yellow and black for the
  10155. pixels of its range.
  10156. @subsection Examples
  10157. @itemize
  10158. @item
  10159. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  10160. increase magenta by 27% in blue areas:
  10161. @example
  10162. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  10163. @end example
  10164. @item
  10165. Use a Photoshop selective color preset:
  10166. @example
  10167. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  10168. @end example
  10169. @end itemize
  10170. @section sendcmd, asendcmd
  10171. Send commands to filters in the filtergraph.
  10172. These filters read commands to be sent to other filters in the
  10173. filtergraph.
  10174. @code{sendcmd} must be inserted between two video filters,
  10175. @code{asendcmd} must be inserted between two audio filters, but apart
  10176. from that they act the same way.
  10177. The specification of commands can be provided in the filter arguments
  10178. with the @var{commands} option, or in a file specified by the
  10179. @var{filename} option.
  10180. These filters accept the following options:
  10181. @table @option
  10182. @item commands, c
  10183. Set the commands to be read and sent to the other filters.
  10184. @item filename, f
  10185. Set the filename of the commands to be read and sent to the other
  10186. filters.
  10187. @end table
  10188. @subsection Commands syntax
  10189. A commands description consists of a sequence of interval
  10190. specifications, comprising a list of commands to be executed when a
  10191. particular event related to that interval occurs. The occurring event
  10192. is typically the current frame time entering or leaving a given time
  10193. interval.
  10194. An interval is specified by the following syntax:
  10195. @example
  10196. @var{START}[-@var{END}] @var{COMMANDS};
  10197. @end example
  10198. The time interval is specified by the @var{START} and @var{END} times.
  10199. @var{END} is optional and defaults to the maximum time.
  10200. The current frame time is considered within the specified interval if
  10201. it is included in the interval [@var{START}, @var{END}), that is when
  10202. the time is greater or equal to @var{START} and is lesser than
  10203. @var{END}.
  10204. @var{COMMANDS} consists of a sequence of one or more command
  10205. specifications, separated by ",", relating to that interval. The
  10206. syntax of a command specification is given by:
  10207. @example
  10208. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  10209. @end example
  10210. @var{FLAGS} is optional and specifies the type of events relating to
  10211. the time interval which enable sending the specified command, and must
  10212. be a non-null sequence of identifier flags separated by "+" or "|" and
  10213. enclosed between "[" and "]".
  10214. The following flags are recognized:
  10215. @table @option
  10216. @item enter
  10217. The command is sent when the current frame timestamp enters the
  10218. specified interval. In other words, the command is sent when the
  10219. previous frame timestamp was not in the given interval, and the
  10220. current is.
  10221. @item leave
  10222. The command is sent when the current frame timestamp leaves the
  10223. specified interval. In other words, the command is sent when the
  10224. previous frame timestamp was in the given interval, and the
  10225. current is not.
  10226. @end table
  10227. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  10228. assumed.
  10229. @var{TARGET} specifies the target of the command, usually the name of
  10230. the filter class or a specific filter instance name.
  10231. @var{COMMAND} specifies the name of the command for the target filter.
  10232. @var{ARG} is optional and specifies the optional list of argument for
  10233. the given @var{COMMAND}.
  10234. Between one interval specification and another, whitespaces, or
  10235. sequences of characters starting with @code{#} until the end of line,
  10236. are ignored and can be used to annotate comments.
  10237. A simplified BNF description of the commands specification syntax
  10238. follows:
  10239. @example
  10240. @var{COMMAND_FLAG} ::= "enter" | "leave"
  10241. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  10242. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  10243. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  10244. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  10245. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  10246. @end example
  10247. @subsection Examples
  10248. @itemize
  10249. @item
  10250. Specify audio tempo change at second 4:
  10251. @example
  10252. asendcmd=c='4.0 atempo tempo 1.5',atempo
  10253. @end example
  10254. @item
  10255. Specify a list of drawtext and hue commands in a file.
  10256. @example
  10257. # show text in the interval 5-10
  10258. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  10259. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  10260. # desaturate the image in the interval 15-20
  10261. 15.0-20.0 [enter] hue s 0,
  10262. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  10263. [leave] hue s 1,
  10264. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  10265. # apply an exponential saturation fade-out effect, starting from time 25
  10266. 25 [enter] hue s exp(25-t)
  10267. @end example
  10268. A filtergraph allowing to read and process the above command list
  10269. stored in a file @file{test.cmd}, can be specified with:
  10270. @example
  10271. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  10272. @end example
  10273. @end itemize
  10274. @anchor{setpts}
  10275. @section setpts, asetpts
  10276. Change the PTS (presentation timestamp) of the input frames.
  10277. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  10278. This filter accepts the following options:
  10279. @table @option
  10280. @item expr
  10281. The expression which is evaluated for each frame to construct its timestamp.
  10282. @end table
  10283. The expression is evaluated through the eval API and can contain the following
  10284. constants:
  10285. @table @option
  10286. @item FRAME_RATE
  10287. frame rate, only defined for constant frame-rate video
  10288. @item PTS
  10289. The presentation timestamp in input
  10290. @item N
  10291. The count of the input frame for video or the number of consumed samples,
  10292. not including the current frame for audio, starting from 0.
  10293. @item NB_CONSUMED_SAMPLES
  10294. The number of consumed samples, not including the current frame (only
  10295. audio)
  10296. @item NB_SAMPLES, S
  10297. The number of samples in the current frame (only audio)
  10298. @item SAMPLE_RATE, SR
  10299. The audio sample rate.
  10300. @item STARTPTS
  10301. The PTS of the first frame.
  10302. @item STARTT
  10303. the time in seconds of the first frame
  10304. @item INTERLACED
  10305. State whether the current frame is interlaced.
  10306. @item T
  10307. the time in seconds of the current frame
  10308. @item POS
  10309. original position in the file of the frame, or undefined if undefined
  10310. for the current frame
  10311. @item PREV_INPTS
  10312. The previous input PTS.
  10313. @item PREV_INT
  10314. previous input time in seconds
  10315. @item PREV_OUTPTS
  10316. The previous output PTS.
  10317. @item PREV_OUTT
  10318. previous output time in seconds
  10319. @item RTCTIME
  10320. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  10321. instead.
  10322. @item RTCSTART
  10323. The wallclock (RTC) time at the start of the movie in microseconds.
  10324. @item TB
  10325. The timebase of the input timestamps.
  10326. @end table
  10327. @subsection Examples
  10328. @itemize
  10329. @item
  10330. Start counting PTS from zero
  10331. @example
  10332. setpts=PTS-STARTPTS
  10333. @end example
  10334. @item
  10335. Apply fast motion effect:
  10336. @example
  10337. setpts=0.5*PTS
  10338. @end example
  10339. @item
  10340. Apply slow motion effect:
  10341. @example
  10342. setpts=2.0*PTS
  10343. @end example
  10344. @item
  10345. Set fixed rate of 25 frames per second:
  10346. @example
  10347. setpts=N/(25*TB)
  10348. @end example
  10349. @item
  10350. Set fixed rate 25 fps with some jitter:
  10351. @example
  10352. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  10353. @end example
  10354. @item
  10355. Apply an offset of 10 seconds to the input PTS:
  10356. @example
  10357. setpts=PTS+10/TB
  10358. @end example
  10359. @item
  10360. Generate timestamps from a "live source" and rebase onto the current timebase:
  10361. @example
  10362. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  10363. @end example
  10364. @item
  10365. Generate timestamps by counting samples:
  10366. @example
  10367. asetpts=N/SR/TB
  10368. @end example
  10369. @end itemize
  10370. @section settb, asettb
  10371. Set the timebase to use for the output frames timestamps.
  10372. It is mainly useful for testing timebase configuration.
  10373. It accepts the following parameters:
  10374. @table @option
  10375. @item expr, tb
  10376. The expression which is evaluated into the output timebase.
  10377. @end table
  10378. The value for @option{tb} is an arithmetic expression representing a
  10379. rational. The expression can contain the constants "AVTB" (the default
  10380. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  10381. audio only). Default value is "intb".
  10382. @subsection Examples
  10383. @itemize
  10384. @item
  10385. Set the timebase to 1/25:
  10386. @example
  10387. settb=expr=1/25
  10388. @end example
  10389. @item
  10390. Set the timebase to 1/10:
  10391. @example
  10392. settb=expr=0.1
  10393. @end example
  10394. @item
  10395. Set the timebase to 1001/1000:
  10396. @example
  10397. settb=1+0.001
  10398. @end example
  10399. @item
  10400. Set the timebase to 2*intb:
  10401. @example
  10402. settb=2*intb
  10403. @end example
  10404. @item
  10405. Set the default timebase value:
  10406. @example
  10407. settb=AVTB
  10408. @end example
  10409. @end itemize
  10410. @section showcqt
  10411. Convert input audio to a video output representing frequency spectrum
  10412. logarithmically using Brown-Puckette constant Q transform algorithm with
  10413. direct frequency domain coefficient calculation (but the transform itself
  10414. is not really constant Q, instead the Q factor is actually variable/clamped),
  10415. with musical tone scale, from E0 to D#10.
  10416. The filter accepts the following options:
  10417. @table @option
  10418. @item size, s
  10419. Specify the video size for the output. It must be even. For the syntax of this option,
  10420. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10421. Default value is @code{1920x1080}.
  10422. @item fps, rate, r
  10423. Set the output frame rate. Default value is @code{25}.
  10424. @item bar_h
  10425. Set the bargraph height. It must be even. Default value is @code{-1} which
  10426. computes the bargraph height automatically.
  10427. @item axis_h
  10428. Set the axis height. It must be even. Default value is @code{-1} which computes
  10429. the axis height automatically.
  10430. @item sono_h
  10431. Set the sonogram height. It must be even. Default value is @code{-1} which
  10432. computes the sonogram height automatically.
  10433. @item fullhd
  10434. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  10435. instead. Default value is @code{1}.
  10436. @item sono_v, volume
  10437. Specify the sonogram volume expression. It can contain variables:
  10438. @table @option
  10439. @item bar_v
  10440. the @var{bar_v} evaluated expression
  10441. @item frequency, freq, f
  10442. the frequency where it is evaluated
  10443. @item timeclamp, tc
  10444. the value of @var{timeclamp} option
  10445. @end table
  10446. and functions:
  10447. @table @option
  10448. @item a_weighting(f)
  10449. A-weighting of equal loudness
  10450. @item b_weighting(f)
  10451. B-weighting of equal loudness
  10452. @item c_weighting(f)
  10453. C-weighting of equal loudness.
  10454. @end table
  10455. Default value is @code{16}.
  10456. @item bar_v, volume2
  10457. Specify the bargraph volume expression. It can contain variables:
  10458. @table @option
  10459. @item sono_v
  10460. the @var{sono_v} evaluated expression
  10461. @item frequency, freq, f
  10462. the frequency where it is evaluated
  10463. @item timeclamp, tc
  10464. the value of @var{timeclamp} option
  10465. @end table
  10466. and functions:
  10467. @table @option
  10468. @item a_weighting(f)
  10469. A-weighting of equal loudness
  10470. @item b_weighting(f)
  10471. B-weighting of equal loudness
  10472. @item c_weighting(f)
  10473. C-weighting of equal loudness.
  10474. @end table
  10475. Default value is @code{sono_v}.
  10476. @item sono_g, gamma
  10477. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  10478. higher gamma makes the spectrum having more range. Default value is @code{3}.
  10479. Acceptable range is @code{[1, 7]}.
  10480. @item bar_g, gamma2
  10481. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  10482. @code{[1, 7]}.
  10483. @item timeclamp, tc
  10484. Specify the transform timeclamp. At low frequency, there is trade-off between
  10485. accuracy in time domain and frequency domain. If timeclamp is lower,
  10486. event in time domain is represented more accurately (such as fast bass drum),
  10487. otherwise event in frequency domain is represented more accurately
  10488. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  10489. @item basefreq
  10490. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  10491. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  10492. @item endfreq
  10493. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  10494. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  10495. @item coeffclamp
  10496. This option is deprecated and ignored.
  10497. @item tlength
  10498. Specify the transform length in time domain. Use this option to control accuracy
  10499. trade-off between time domain and frequency domain at every frequency sample.
  10500. It can contain variables:
  10501. @table @option
  10502. @item frequency, freq, f
  10503. the frequency where it is evaluated
  10504. @item timeclamp, tc
  10505. the value of @var{timeclamp} option.
  10506. @end table
  10507. Default value is @code{384*tc/(384+tc*f)}.
  10508. @item count
  10509. Specify the transform count for every video frame. Default value is @code{6}.
  10510. Acceptable range is @code{[1, 30]}.
  10511. @item fcount
  10512. Specify the transform count for every single pixel. Default value is @code{0},
  10513. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  10514. @item fontfile
  10515. Specify font file for use with freetype to draw the axis. If not specified,
  10516. use embedded font. Note that drawing with font file or embedded font is not
  10517. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  10518. option instead.
  10519. @item fontcolor
  10520. Specify font color expression. This is arithmetic expression that should return
  10521. integer value 0xRRGGBB. It can contain variables:
  10522. @table @option
  10523. @item frequency, freq, f
  10524. the frequency where it is evaluated
  10525. @item timeclamp, tc
  10526. the value of @var{timeclamp} option
  10527. @end table
  10528. and functions:
  10529. @table @option
  10530. @item midi(f)
  10531. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  10532. @item r(x), g(x), b(x)
  10533. red, green, and blue value of intensity x.
  10534. @end table
  10535. Default value is @code{st(0, (midi(f)-59.5)/12);
  10536. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  10537. r(1-ld(1)) + b(ld(1))}.
  10538. @item axisfile
  10539. Specify image file to draw the axis. This option override @var{fontfile} and
  10540. @var{fontcolor} option.
  10541. @item axis, text
  10542. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  10543. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  10544. Default value is @code{1}.
  10545. @end table
  10546. @subsection Examples
  10547. @itemize
  10548. @item
  10549. Playing audio while showing the spectrum:
  10550. @example
  10551. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  10552. @end example
  10553. @item
  10554. Same as above, but with frame rate 30 fps:
  10555. @example
  10556. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  10557. @end example
  10558. @item
  10559. Playing at 1280x720:
  10560. @example
  10561. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  10562. @end example
  10563. @item
  10564. Disable sonogram display:
  10565. @example
  10566. sono_h=0
  10567. @end example
  10568. @item
  10569. A1 and its harmonics: A1, A2, (near)E3, A3:
  10570. @example
  10571. 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),
  10572. asplit[a][out1]; [a] showcqt [out0]'
  10573. @end example
  10574. @item
  10575. Same as above, but with more accuracy in frequency domain:
  10576. @example
  10577. 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),
  10578. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  10579. @end example
  10580. @item
  10581. Custom volume:
  10582. @example
  10583. bar_v=10:sono_v=bar_v*a_weighting(f)
  10584. @end example
  10585. @item
  10586. Custom gamma, now spectrum is linear to the amplitude.
  10587. @example
  10588. bar_g=2:sono_g=2
  10589. @end example
  10590. @item
  10591. Custom tlength equation:
  10592. @example
  10593. tc=0.33:tlength='st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))'
  10594. @end example
  10595. @item
  10596. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  10597. @example
  10598. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  10599. @end example
  10600. @item
  10601. Custom frequency range with custom axis using image file:
  10602. @example
  10603. axisfile=myaxis.png:basefreq=40:endfreq=10000
  10604. @end example
  10605. @end itemize
  10606. @section showfreqs
  10607. Convert input audio to video output representing the audio power spectrum.
  10608. Audio amplitude is on Y-axis while frequency is on X-axis.
  10609. The filter accepts the following options:
  10610. @table @option
  10611. @item size, s
  10612. Specify size of video. For the syntax of this option, check the
  10613. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10614. Default is @code{1024x512}.
  10615. @item mode
  10616. Set display mode.
  10617. This set how each frequency bin will be represented.
  10618. It accepts the following values:
  10619. @table @samp
  10620. @item line
  10621. @item bar
  10622. @item dot
  10623. @end table
  10624. Default is @code{bar}.
  10625. @item ascale
  10626. Set amplitude scale.
  10627. It accepts the following values:
  10628. @table @samp
  10629. @item lin
  10630. Linear scale.
  10631. @item sqrt
  10632. Square root scale.
  10633. @item cbrt
  10634. Cubic root scale.
  10635. @item log
  10636. Logarithmic scale.
  10637. @end table
  10638. Default is @code{log}.
  10639. @item fscale
  10640. Set frequency scale.
  10641. It accepts the following values:
  10642. @table @samp
  10643. @item lin
  10644. Linear scale.
  10645. @item log
  10646. Logarithmic scale.
  10647. @item rlog
  10648. Reverse logarithmic scale.
  10649. @end table
  10650. Default is @code{lin}.
  10651. @item win_size
  10652. Set window size.
  10653. It accepts the following values:
  10654. @table @samp
  10655. @item w16
  10656. @item w32
  10657. @item w64
  10658. @item w128
  10659. @item w256
  10660. @item w512
  10661. @item w1024
  10662. @item w2048
  10663. @item w4096
  10664. @item w8192
  10665. @item w16384
  10666. @item w32768
  10667. @item w65536
  10668. @end table
  10669. Default is @code{w2048}
  10670. @item win_func
  10671. Set windowing function.
  10672. It accepts the following values:
  10673. @table @samp
  10674. @item rect
  10675. @item bartlett
  10676. @item hanning
  10677. @item hamming
  10678. @item blackman
  10679. @item welch
  10680. @item flattop
  10681. @item bharris
  10682. @item bnuttall
  10683. @item bhann
  10684. @item sine
  10685. @item nuttall
  10686. @item lanczos
  10687. @item gauss
  10688. @end table
  10689. Default is @code{hanning}.
  10690. @item overlap
  10691. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  10692. which means optimal overlap for selected window function will be picked.
  10693. @item averaging
  10694. Set time averaging. Setting this to 0 will display current maximal peaks.
  10695. Default is @code{1}, which means time averaging is disabled.
  10696. @item colors
  10697. Specify list of colors separated by space or by '|' which will be used to
  10698. draw channel frequencies. Unrecognized or missing colors will be replaced
  10699. by white color.
  10700. @end table
  10701. @section showspectrum
  10702. Convert input audio to a video output, representing the audio frequency
  10703. spectrum.
  10704. The filter accepts the following options:
  10705. @table @option
  10706. @item size, s
  10707. Specify the video size for the output. For the syntax of this option, check the
  10708. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10709. Default value is @code{640x512}.
  10710. @item slide
  10711. Specify how the spectrum should slide along the window.
  10712. It accepts the following values:
  10713. @table @samp
  10714. @item replace
  10715. the samples start again on the left when they reach the right
  10716. @item scroll
  10717. the samples scroll from right to left
  10718. @item fullframe
  10719. frames are only produced when the samples reach the right
  10720. @end table
  10721. Default value is @code{replace}.
  10722. @item mode
  10723. Specify display mode.
  10724. It accepts the following values:
  10725. @table @samp
  10726. @item combined
  10727. all channels are displayed in the same row
  10728. @item separate
  10729. all channels are displayed in separate rows
  10730. @end table
  10731. Default value is @samp{combined}.
  10732. @item color
  10733. Specify display color mode.
  10734. It accepts the following values:
  10735. @table @samp
  10736. @item channel
  10737. each channel is displayed in a separate color
  10738. @item intensity
  10739. each channel is is displayed using the same color scheme
  10740. @end table
  10741. Default value is @samp{channel}.
  10742. @item scale
  10743. Specify scale used for calculating intensity color values.
  10744. It accepts the following values:
  10745. @table @samp
  10746. @item lin
  10747. linear
  10748. @item sqrt
  10749. square root, default
  10750. @item cbrt
  10751. cubic root
  10752. @item log
  10753. logarithmic
  10754. @end table
  10755. Default value is @samp{sqrt}.
  10756. @item saturation
  10757. Set saturation modifier for displayed colors. Negative values provide
  10758. alternative color scheme. @code{0} is no saturation at all.
  10759. Saturation must be in [-10.0, 10.0] range.
  10760. Default value is @code{1}.
  10761. @item win_func
  10762. Set window function.
  10763. It accepts the following values:
  10764. @table @samp
  10765. @item none
  10766. No samples pre-processing (do not expect this to be faster)
  10767. @item hann
  10768. Hann window
  10769. @item hamming
  10770. Hamming window
  10771. @item blackman
  10772. Blackman window
  10773. @end table
  10774. Default value is @code{hann}.
  10775. @end table
  10776. The usage is very similar to the showwaves filter; see the examples in that
  10777. section.
  10778. @subsection Examples
  10779. @itemize
  10780. @item
  10781. Large window with logarithmic color scaling:
  10782. @example
  10783. showspectrum=s=1280x480:scale=log
  10784. @end example
  10785. @item
  10786. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  10787. @example
  10788. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10789. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  10790. @end example
  10791. @end itemize
  10792. @section showvolume
  10793. Convert input audio volume to a video output.
  10794. The filter accepts the following options:
  10795. @table @option
  10796. @item rate, r
  10797. Set video rate.
  10798. @item b
  10799. Set border width, allowed range is [0, 5]. Default is 1.
  10800. @item w
  10801. Set channel width, allowed range is [40, 1080]. Default is 400.
  10802. @item h
  10803. Set channel height, allowed range is [1, 100]. Default is 20.
  10804. @item f
  10805. Set fade, allowed range is [1, 255]. Default is 20.
  10806. @item c
  10807. Set volume color expression.
  10808. The expression can use the following variables:
  10809. @table @option
  10810. @item VOLUME
  10811. Current max volume of channel in dB.
  10812. @item CHANNEL
  10813. Current channel number, starting from 0.
  10814. @end table
  10815. @item t
  10816. If set, displays channel names. Default is enabled.
  10817. @end table
  10818. @section showwaves
  10819. Convert input audio to a video output, representing the samples waves.
  10820. The filter accepts the following options:
  10821. @table @option
  10822. @item size, s
  10823. Specify the video size for the output. For the syntax of this option, check the
  10824. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10825. Default value is @code{600x240}.
  10826. @item mode
  10827. Set display mode.
  10828. Available values are:
  10829. @table @samp
  10830. @item point
  10831. Draw a point for each sample.
  10832. @item line
  10833. Draw a vertical line for each sample.
  10834. @item p2p
  10835. Draw a point for each sample and a line between them.
  10836. @item cline
  10837. Draw a centered vertical line for each sample.
  10838. @end table
  10839. Default value is @code{point}.
  10840. @item n
  10841. Set the number of samples which are printed on the same column. A
  10842. larger value will decrease the frame rate. Must be a positive
  10843. integer. This option can be set only if the value for @var{rate}
  10844. is not explicitly specified.
  10845. @item rate, r
  10846. Set the (approximate) output frame rate. This is done by setting the
  10847. option @var{n}. Default value is "25".
  10848. @item split_channels
  10849. Set if channels should be drawn separately or overlap. Default value is 0.
  10850. @end table
  10851. @subsection Examples
  10852. @itemize
  10853. @item
  10854. Output the input file audio and the corresponding video representation
  10855. at the same time:
  10856. @example
  10857. amovie=a.mp3,asplit[out0],showwaves[out1]
  10858. @end example
  10859. @item
  10860. Create a synthetic signal and show it with showwaves, forcing a
  10861. frame rate of 30 frames per second:
  10862. @example
  10863. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10864. @end example
  10865. @end itemize
  10866. @section showwavespic
  10867. Convert input audio to a single video frame, representing the samples waves.
  10868. The filter accepts the following options:
  10869. @table @option
  10870. @item size, s
  10871. Specify the video size for the output. For the syntax of this option, check the
  10872. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10873. Default value is @code{600x240}.
  10874. @item split_channels
  10875. Set if channels should be drawn separately or overlap. Default value is 0.
  10876. @end table
  10877. @subsection Examples
  10878. @itemize
  10879. @item
  10880. Extract a channel split representation of the wave form of a whole audio track
  10881. in a 1024x800 picture using @command{ffmpeg}:
  10882. @example
  10883. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10884. @end example
  10885. @end itemize
  10886. @section split, asplit
  10887. Split input into several identical outputs.
  10888. @code{asplit} works with audio input, @code{split} with video.
  10889. The filter accepts a single parameter which specifies the number of outputs. If
  10890. unspecified, it defaults to 2.
  10891. @subsection Examples
  10892. @itemize
  10893. @item
  10894. Create two separate outputs from the same input:
  10895. @example
  10896. [in] split [out0][out1]
  10897. @end example
  10898. @item
  10899. To create 3 or more outputs, you need to specify the number of
  10900. outputs, like in:
  10901. @example
  10902. [in] asplit=3 [out0][out1][out2]
  10903. @end example
  10904. @item
  10905. Create two separate outputs from the same input, one cropped and
  10906. one padded:
  10907. @example
  10908. [in] split [splitout1][splitout2];
  10909. [splitout1] crop=100:100:0:0 [cropout];
  10910. [splitout2] pad=200:200:100:100 [padout];
  10911. @end example
  10912. @item
  10913. Create 5 copies of the input audio with @command{ffmpeg}:
  10914. @example
  10915. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10916. @end example
  10917. @end itemize
  10918. @section zmq, azmq
  10919. Receive commands sent through a libzmq client, and forward them to
  10920. filters in the filtergraph.
  10921. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10922. must be inserted between two video filters, @code{azmq} between two
  10923. audio filters.
  10924. To enable these filters you need to install the libzmq library and
  10925. headers and configure FFmpeg with @code{--enable-libzmq}.
  10926. For more information about libzmq see:
  10927. @url{http://www.zeromq.org/}
  10928. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10929. receives messages sent through a network interface defined by the
  10930. @option{bind_address} option.
  10931. The received message must be in the form:
  10932. @example
  10933. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10934. @end example
  10935. @var{TARGET} specifies the target of the command, usually the name of
  10936. the filter class or a specific filter instance name.
  10937. @var{COMMAND} specifies the name of the command for the target filter.
  10938. @var{ARG} is optional and specifies the optional argument list for the
  10939. given @var{COMMAND}.
  10940. Upon reception, the message is processed and the corresponding command
  10941. is injected into the filtergraph. Depending on the result, the filter
  10942. will send a reply to the client, adopting the format:
  10943. @example
  10944. @var{ERROR_CODE} @var{ERROR_REASON}
  10945. @var{MESSAGE}
  10946. @end example
  10947. @var{MESSAGE} is optional.
  10948. @subsection Examples
  10949. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10950. be used to send commands processed by these filters.
  10951. Consider the following filtergraph generated by @command{ffplay}
  10952. @example
  10953. ffplay -dumpgraph 1 -f lavfi "
  10954. color=s=100x100:c=red [l];
  10955. color=s=100x100:c=blue [r];
  10956. nullsrc=s=200x100, zmq [bg];
  10957. [bg][l] overlay [bg+l];
  10958. [bg+l][r] overlay=x=100 "
  10959. @end example
  10960. To change the color of the left side of the video, the following
  10961. command can be used:
  10962. @example
  10963. echo Parsed_color_0 c yellow | tools/zmqsend
  10964. @end example
  10965. To change the right side:
  10966. @example
  10967. echo Parsed_color_1 c pink | tools/zmqsend
  10968. @end example
  10969. @c man end MULTIMEDIA FILTERS
  10970. @chapter Multimedia Sources
  10971. @c man begin MULTIMEDIA SOURCES
  10972. Below is a description of the currently available multimedia sources.
  10973. @section amovie
  10974. This is the same as @ref{movie} source, except it selects an audio
  10975. stream by default.
  10976. @anchor{movie}
  10977. @section movie
  10978. Read audio and/or video stream(s) from a movie container.
  10979. It accepts the following parameters:
  10980. @table @option
  10981. @item filename
  10982. The name of the resource to read (not necessarily a file; it can also be a
  10983. device or a stream accessed through some protocol).
  10984. @item format_name, f
  10985. Specifies the format assumed for the movie to read, and can be either
  10986. the name of a container or an input device. If not specified, the
  10987. format is guessed from @var{movie_name} or by probing.
  10988. @item seek_point, sp
  10989. Specifies the seek point in seconds. The frames will be output
  10990. starting from this seek point. The parameter is evaluated with
  10991. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10992. postfix. The default value is "0".
  10993. @item streams, s
  10994. Specifies the streams to read. Several streams can be specified,
  10995. separated by "+". The source will then have as many outputs, in the
  10996. same order. The syntax is explained in the ``Stream specifiers''
  10997. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10998. respectively the default (best suited) video and audio stream. Default
  10999. is "dv", or "da" if the filter is called as "amovie".
  11000. @item stream_index, si
  11001. Specifies the index of the video stream to read. If the value is -1,
  11002. the most suitable video stream will be automatically selected. The default
  11003. value is "-1". Deprecated. If the filter is called "amovie", it will select
  11004. audio instead of video.
  11005. @item loop
  11006. Specifies how many times to read the stream in sequence.
  11007. If the value is less than 1, the stream will be read again and again.
  11008. Default value is "1".
  11009. Note that when the movie is looped the source timestamps are not
  11010. changed, so it will generate non monotonically increasing timestamps.
  11011. @end table
  11012. It allows overlaying a second video on top of the main input of
  11013. a filtergraph, as shown in this graph:
  11014. @example
  11015. input -----------> deltapts0 --> overlay --> output
  11016. ^
  11017. |
  11018. movie --> scale--> deltapts1 -------+
  11019. @end example
  11020. @subsection Examples
  11021. @itemize
  11022. @item
  11023. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  11024. on top of the input labelled "in":
  11025. @example
  11026. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11027. [in] setpts=PTS-STARTPTS [main];
  11028. [main][over] overlay=16:16 [out]
  11029. @end example
  11030. @item
  11031. Read from a video4linux2 device, and overlay it on top of the input
  11032. labelled "in":
  11033. @example
  11034. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11035. [in] setpts=PTS-STARTPTS [main];
  11036. [main][over] overlay=16:16 [out]
  11037. @end example
  11038. @item
  11039. Read the first video stream and the audio stream with id 0x81 from
  11040. dvd.vob; the video is connected to the pad named "video" and the audio is
  11041. connected to the pad named "audio":
  11042. @example
  11043. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  11044. @end example
  11045. @end itemize
  11046. @c man end MULTIMEDIA SOURCES