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.

11174 lines
302KB

  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. @example
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end example
  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
  93. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  94. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  95. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} functions defined in
  96. @file{libavfilter/avfilter.h}.
  97. A filterchain consists of a sequence of connected filters, each one
  98. connected to the previous one in the sequence. A filterchain is
  99. represented by a list of ","-separated filter descriptions.
  100. A filtergraph consists of a sequence of filterchains. A sequence of
  101. filterchains is represented by a list of ";"-separated filterchain
  102. descriptions.
  103. A filter is represented by a string of the form:
  104. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  105. @var{filter_name} is the name of the filter class of which the
  106. described filter is an instance of, and has to be the name of one of
  107. the filter classes registered in the program.
  108. The name of the filter class is optionally followed by a string
  109. "=@var{arguments}".
  110. @var{arguments} is a string which contains the parameters used to
  111. initialize the filter instance. It may have one of two forms:
  112. @itemize
  113. @item
  114. A ':'-separated list of @var{key=value} pairs.
  115. @item
  116. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  117. the option names in the order they are declared. E.g. the @code{fade} filter
  118. declares three options in this order -- @option{type}, @option{start_frame} and
  119. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  120. @var{in} is assigned to the option @option{type}, @var{0} to
  121. @option{start_frame} and @var{30} to @option{nb_frames}.
  122. @item
  123. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  124. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  125. follow the same constraints order of the previous point. The following
  126. @var{key=value} pairs can be set in any preferred order.
  127. @end itemize
  128. If the option value itself is a list of items (e.g. the @code{format} filter
  129. takes a list of pixel formats), the items in the list are usually separated by
  130. '|'.
  131. The list of arguments can be quoted using the character "'" as initial
  132. and ending mark, and the character '\' for escaping the characters
  133. within the quoted text; otherwise the argument string is considered
  134. terminated when the next special character (belonging to the set
  135. "[]=;,") is encountered.
  136. The name and arguments of the filter are optionally preceded and
  137. followed by a list of link labels.
  138. A link label allows one to name a link and associate it to a filter output
  139. or input pad. The preceding labels @var{in_link_1}
  140. ... @var{in_link_N}, are associated to the filter input pads,
  141. the following labels @var{out_link_1} ... @var{out_link_M}, are
  142. associated to the output pads.
  143. When two link labels with the same name are found in the
  144. filtergraph, a link between the corresponding input and output pad is
  145. created.
  146. If an output pad is not labelled, it is linked by default to the first
  147. unlabelled input pad of the next filter in the filterchain.
  148. For example in the filterchain
  149. @example
  150. nullsrc, split[L1], [L2]overlay, nullsink
  151. @end example
  152. the split filter instance has two output pads, and the overlay filter
  153. instance two input pads. The first output pad of split is labelled
  154. "L1", the first input pad of overlay is labelled "L2", and the second
  155. output pad of split is linked to the second input pad of overlay,
  156. which are both unlabelled.
  157. In a complete filterchain all the unlabelled filter input and output
  158. pads must be connected. A filtergraph is considered valid if all the
  159. filter input and output pads of all the filterchains are connected.
  160. Libavfilter will automatically insert @ref{scale} filters where format
  161. conversion is required. It is possible to specify swscale flags
  162. for those automatically inserted scalers by prepending
  163. @code{sws_flags=@var{flags};}
  164. to the filtergraph description.
  165. Here is a BNF description of the filtergraph syntax:
  166. @example
  167. @var{NAME} ::= sequence of alphanumeric characters and '_'
  168. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  169. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  170. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  171. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  172. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  173. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  174. @end example
  175. @section Notes on filtergraph escaping
  176. Filtergraph description composition entails several levels of
  177. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  178. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  179. information about the employed escaping procedure.
  180. A first level escaping affects the content of each filter option
  181. value, which may contain the special character @code{:} used to
  182. separate values, or one of the escaping characters @code{\'}.
  183. A second level escaping affects the whole filter description, which
  184. may contain the escaping characters @code{\'} or the special
  185. characters @code{[],;} used by the filtergraph description.
  186. Finally, when you specify a filtergraph on a shell commandline, you
  187. need to perform a third level escaping for the shell special
  188. characters contained within it.
  189. For example, consider the following string to be embedded in
  190. the @ref{drawtext} filter description @option{text} value:
  191. @example
  192. this is a 'string': may contain one, or more, special characters
  193. @end example
  194. This string contains the @code{'} special escaping character, and the
  195. @code{:} special character, so it needs to be escaped in this way:
  196. @example
  197. text=this is a \'string\'\: may contain one, or more, special characters
  198. @end example
  199. A second level of escaping is required when embedding the filter
  200. description in a filtergraph description, in order to escape all the
  201. filtergraph special characters. Thus the example above becomes:
  202. @example
  203. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  204. @end example
  205. (note that in addition to the @code{\'} escaping special characters,
  206. also @code{,} needs to be escaped).
  207. Finally an additional level of escaping is needed when writing the
  208. filtergraph description in a shell command, which depends on the
  209. escaping rules of the adopted shell. For example, assuming that
  210. @code{\} is special and needs to be escaped with another @code{\}, the
  211. previous string will finally result in:
  212. @example
  213. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  214. @end example
  215. @chapter Timeline editing
  216. Some filters support a generic @option{enable} option. For the filters
  217. supporting timeline editing, this option can be set to an expression which is
  218. evaluated before sending a frame to the filter. If the evaluation is non-zero,
  219. the filter will be enabled, otherwise the frame will be sent unchanged to the
  220. next filter in the filtergraph.
  221. The expression accepts the following values:
  222. @table @samp
  223. @item t
  224. timestamp expressed in seconds, NAN if the input timestamp is unknown
  225. @item n
  226. sequential number of the input frame, starting from 0
  227. @item pos
  228. the position in the file of the input frame, NAN if unknown
  229. @end table
  230. Additionally, these filters support an @option{enable} command that can be used
  231. to re-define the expression.
  232. Like any other filtering option, the @option{enable} option follows the same
  233. rules.
  234. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  235. minutes, and a @ref{curves} filter starting at 3 seconds:
  236. @example
  237. smartblur = enable='between(t,10,3*60)',
  238. curves = enable='gte(t,3)' : preset=cross_process
  239. @end example
  240. @c man end FILTERGRAPH DESCRIPTION
  241. @chapter Audio Filters
  242. @c man begin AUDIO FILTERS
  243. When you configure your FFmpeg build, you can disable any of the
  244. existing filters using @code{--disable-filters}.
  245. The configure output will show the audio filters included in your
  246. build.
  247. Below is a description of the currently available audio filters.
  248. @section aconvert
  249. Convert the input audio format to the specified formats.
  250. @emph{This filter is deprecated. Use @ref{aformat} instead.}
  251. The filter accepts a string of the form:
  252. "@var{sample_format}:@var{channel_layout}".
  253. @var{sample_format} specifies the sample format, and can be a string or the
  254. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  255. suffix for a planar sample format.
  256. @var{channel_layout} specifies the channel layout, and can be a string
  257. or the corresponding number value defined in @file{libavutil/channel_layout.h}.
  258. The special parameter "auto", signifies that the filter will
  259. automatically select the output format depending on the output filter.
  260. @subsection Examples
  261. @itemize
  262. @item
  263. Convert input to float, planar, stereo:
  264. @example
  265. aconvert=fltp:stereo
  266. @end example
  267. @item
  268. Convert input to unsigned 8-bit, automatically select out channel layout:
  269. @example
  270. aconvert=u8:auto
  271. @end example
  272. @end itemize
  273. @section adelay
  274. Delay one or more audio channels.
  275. Samples in delayed channel are filled with silence.
  276. The filter accepts the following option:
  277. @table @option
  278. @item delays
  279. Set list of delays in milliseconds for each channel separated by '|'.
  280. At least one delay greater than 0 should be provided.
  281. Unused delays will be silently ignored. If number of given delays is
  282. smaller than number of channels all remaining channels will not be delayed.
  283. @end table
  284. @subsection Examples
  285. @itemize
  286. @item
  287. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  288. the second channel (and any other channels that may be present) unchanged.
  289. @example
  290. adelay=1500|0|500
  291. @end example
  292. @end itemize
  293. @section aecho
  294. Apply echoing to the input audio.
  295. Echoes are reflected sound and can occur naturally amongst mountains
  296. (and sometimes large buildings) when talking or shouting; digital echo
  297. effects emulate this behaviour and are often used to help fill out the
  298. sound of a single instrument or vocal. The time difference between the
  299. original signal and the reflection is the @code{delay}, and the
  300. loudness of the reflected signal is the @code{decay}.
  301. Multiple echoes can have different delays and decays.
  302. A description of the accepted parameters follows.
  303. @table @option
  304. @item in_gain
  305. Set input gain of reflected signal. Default is @code{0.6}.
  306. @item out_gain
  307. Set output gain of reflected signal. Default is @code{0.3}.
  308. @item delays
  309. Set list of time intervals in milliseconds between original signal and reflections
  310. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  311. Default is @code{1000}.
  312. @item decays
  313. Set list of loudnesses of reflected signals separated by '|'.
  314. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  315. Default is @code{0.5}.
  316. @end table
  317. @subsection Examples
  318. @itemize
  319. @item
  320. Make it sound as if there are twice as many instruments as are actually playing:
  321. @example
  322. aecho=0.8:0.88:60:0.4
  323. @end example
  324. @item
  325. If delay is very short, then it sound like a (metallic) robot playing music:
  326. @example
  327. aecho=0.8:0.88:6:0.4
  328. @end example
  329. @item
  330. A longer delay will sound like an open air concert in the mountains:
  331. @example
  332. aecho=0.8:0.9:1000:0.3
  333. @end example
  334. @item
  335. Same as above but with one more mountain:
  336. @example
  337. aecho=0.8:0.9:1000|1800:0.3|0.25
  338. @end example
  339. @end itemize
  340. @section aeval
  341. Modify an audio signal according to the specified expressions.
  342. This filter accepts one or more expressions (one for each channel),
  343. which are evaluated and used to modify a corresponding audio signal.
  344. It accepts the following parameters:
  345. @table @option
  346. @item exprs
  347. Set the '|'-separated expressions list for each separate channel. If
  348. the number of input channels is greater than the number of
  349. expressions, the last specified expression is used for the remaining
  350. output channels.
  351. @item channel_layout, c
  352. Set output channel layout. If not specified, the channel layout is
  353. specified by the number of expressions. If set to @samp{same}, it will
  354. use by default the same input channel layout.
  355. @end table
  356. Each expression in @var{exprs} can contain the following constants and functions:
  357. @table @option
  358. @item ch
  359. channel number of the current expression
  360. @item n
  361. number of the evaluated sample, starting from 0
  362. @item s
  363. sample rate
  364. @item t
  365. time of the evaluated sample expressed in seconds
  366. @item nb_in_channels
  367. @item nb_out_channels
  368. input and output number of channels
  369. @item val(CH)
  370. the value of input channel with number @var{CH}
  371. @end table
  372. Note: this filter is slow. For faster processing you should use a
  373. dedicated filter.
  374. @subsection Examples
  375. @itemize
  376. @item
  377. Half volume:
  378. @example
  379. aeval=val(ch)/2:c=same
  380. @end example
  381. @item
  382. Invert phase of the second channel:
  383. @example
  384. eval=val(0)|-val(1)
  385. @end example
  386. @end itemize
  387. @section afade
  388. Apply fade-in/out effect to input audio.
  389. A description of the accepted parameters follows.
  390. @table @option
  391. @item type, t
  392. Specify the effect type, can be either @code{in} for fade-in, or
  393. @code{out} for a fade-out effect. Default is @code{in}.
  394. @item start_sample, ss
  395. Specify the number of the start sample for starting to apply the fade
  396. effect. Default is 0.
  397. @item nb_samples, ns
  398. Specify the number of samples for which the fade effect has to last. At
  399. the end of the fade-in effect the output audio will have the same
  400. volume as the input audio, at the end of the fade-out transition
  401. the output audio will be silence. Default is 44100.
  402. @item start_time, st
  403. Specify time for starting to apply the fade effect. Default is 0.
  404. The accepted syntax is:
  405. @example
  406. [-]HH[:MM[:SS[.m...]]]
  407. [-]S+[.m...]
  408. @end example
  409. See also the function @code{av_parse_time()}.
  410. If set this option is used instead of @var{start_sample} one.
  411. @item duration, d
  412. Specify the duration for which the fade effect has to last. Default is 0.
  413. The accepted syntax is:
  414. @example
  415. [-]HH[:MM[:SS[.m...]]]
  416. [-]S+[.m...]
  417. @end example
  418. See also the function @code{av_parse_time()}.
  419. At the end of the fade-in effect the output audio will have the same
  420. volume as the input audio, at the end of the fade-out transition
  421. the output audio will be silence.
  422. If set this option is used instead of @var{nb_samples} one.
  423. @item curve
  424. Set curve for fade transition.
  425. It accepts the following values:
  426. @table @option
  427. @item tri
  428. select triangular, linear slope (default)
  429. @item qsin
  430. select quarter of sine wave
  431. @item hsin
  432. select half of sine wave
  433. @item esin
  434. select exponential sine wave
  435. @item log
  436. select logarithmic
  437. @item par
  438. select inverted parabola
  439. @item qua
  440. select quadratic
  441. @item cub
  442. select cubic
  443. @item squ
  444. select square root
  445. @item cbr
  446. select cubic root
  447. @end table
  448. @end table
  449. @subsection Examples
  450. @itemize
  451. @item
  452. Fade in first 15 seconds of audio:
  453. @example
  454. afade=t=in:ss=0:d=15
  455. @end example
  456. @item
  457. Fade out last 25 seconds of a 900 seconds audio:
  458. @example
  459. afade=t=out:st=875:d=25
  460. @end example
  461. @end itemize
  462. @anchor{aformat}
  463. @section aformat
  464. Set output format constraints for the input audio. The framework will
  465. negotiate the most appropriate format to minimize conversions.
  466. It accepts the following parameters:
  467. @table @option
  468. @item sample_fmts
  469. A '|'-separated list of requested sample formats.
  470. @item sample_rates
  471. A '|'-separated list of requested sample rates.
  472. @item channel_layouts
  473. A '|'-separated list of requested channel layouts.
  474. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  475. for the required syntax.
  476. @end table
  477. If a parameter is omitted, all values are allowed.
  478. Force the output to either unsigned 8-bit or signed 16-bit stereo
  479. @example
  480. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  481. @end example
  482. @section allpass
  483. Apply a two-pole all-pass filter with central frequency (in Hz)
  484. @var{frequency}, and filter-width @var{width}.
  485. An all-pass filter changes the audio's frequency to phase relationship
  486. without changing its frequency to amplitude relationship.
  487. The filter accepts the following options:
  488. @table @option
  489. @item frequency, f
  490. Set frequency in Hz.
  491. @item width_type
  492. Set method to specify band-width of filter.
  493. @table @option
  494. @item h
  495. Hz
  496. @item q
  497. Q-Factor
  498. @item o
  499. octave
  500. @item s
  501. slope
  502. @end table
  503. @item width, w
  504. Specify the band-width of a filter in width_type units.
  505. @end table
  506. @section amerge
  507. Merge two or more audio streams into a single multi-channel stream.
  508. The filter accepts the following options:
  509. @table @option
  510. @item inputs
  511. Set the number of inputs. Default is 2.
  512. @end table
  513. If the channel layouts of the inputs are disjoint, and therefore compatible,
  514. the channel layout of the output will be set accordingly and the channels
  515. will be reordered as necessary. If the channel layouts of the inputs are not
  516. disjoint, the output will have all the channels of the first input then all
  517. the channels of the second input, in that order, and the channel layout of
  518. the output will be the default value corresponding to the total number of
  519. channels.
  520. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  521. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  522. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  523. first input, b1 is the first channel of the second input).
  524. On the other hand, if both input are in stereo, the output channels will be
  525. in the default order: a1, a2, b1, b2, and the channel layout will be
  526. arbitrarily set to 4.0, which may or may not be the expected value.
  527. All inputs must have the same sample rate, and format.
  528. If inputs do not have the same duration, the output will stop with the
  529. shortest.
  530. @subsection Examples
  531. @itemize
  532. @item
  533. Merge two mono files into a stereo stream:
  534. @example
  535. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  536. @end example
  537. @item
  538. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  539. @example
  540. 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
  541. @end example
  542. @end itemize
  543. @section amix
  544. Mixes multiple audio inputs into a single output.
  545. Note that this filter only supports float samples (the @var{amerge}
  546. and @var{pan} audio filters support many formats). If the @var{amix}
  547. input has integer samples then @ref{aresample} will be automatically
  548. inserted to perform the conversion to float samples.
  549. For example
  550. @example
  551. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  552. @end example
  553. will mix 3 input audio streams to a single output with the same duration as the
  554. first input and a dropout transition time of 3 seconds.
  555. It accepts the following parameters:
  556. @table @option
  557. @item inputs
  558. The number of inputs. If unspecified, it defaults to 2.
  559. @item duration
  560. How to determine the end-of-stream.
  561. @table @option
  562. @item longest
  563. The duration of the longest input. (default)
  564. @item shortest
  565. The duration of the shortest input.
  566. @item first
  567. The duration of the first input.
  568. @end table
  569. @item dropout_transition
  570. The transition time, in seconds, for volume renormalization when an input
  571. stream ends. The default value is 2 seconds.
  572. @end table
  573. @section anull
  574. Pass the audio source unchanged to the output.
  575. @section apad
  576. Pad the end of an audio stream with silence.
  577. This can be used together with @command{ffmpeg} @option{-shortest} to
  578. extend audio streams to the same length as the video stream.
  579. A description of the accepted options follows.
  580. @table @option
  581. @item packet_size
  582. Set silence packet size. Default value is 4096.
  583. @item pad_len
  584. Set the number of samples of silence to add to the end. After the
  585. value is reached, the stream is terminated. This option is mutually
  586. exclusive with @option{whole_len}.
  587. @item whole_len
  588. Set the minimum total number of samples in the output audio stream. If
  589. the value is longer than the input audio length, silence is added to
  590. the end, until the value is reached. This option is mutually exclusive
  591. with @option{pad_len}.
  592. @end table
  593. If neither the @option{pad_len} nor the @option{whole_len} option is
  594. set, the filter will add silence to the end of the input stream
  595. indefinitely.
  596. @subsection Examples
  597. @itemize
  598. @item
  599. Add 1024 samples of silence to the end of the input:
  600. @example
  601. apad=pad_len=1024
  602. @end example
  603. @item
  604. Make sure the audio output will contain at least 10000 samples, pad
  605. the input with silence if required:
  606. @example
  607. apad=whole_len=10000
  608. @end example
  609. @item
  610. Use @command{ffmpeg} to pad the audio input with silence, so that the
  611. video stream will always result the shortest and will be converted
  612. until the end in the output file when using the @option{shortest}
  613. option:
  614. @example
  615. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  616. @end example
  617. @end itemize
  618. @section aphaser
  619. Add a phasing effect to the input audio.
  620. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  621. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  622. A description of the accepted parameters follows.
  623. @table @option
  624. @item in_gain
  625. Set input gain. Default is 0.4.
  626. @item out_gain
  627. Set output gain. Default is 0.74
  628. @item delay
  629. Set delay in milliseconds. Default is 3.0.
  630. @item decay
  631. Set decay. Default is 0.4.
  632. @item speed
  633. Set modulation speed in Hz. Default is 0.5.
  634. @item type
  635. Set modulation type. Default is triangular.
  636. It accepts the following values:
  637. @table @samp
  638. @item triangular, t
  639. @item sinusoidal, s
  640. @end table
  641. @end table
  642. @anchor{aresample}
  643. @section aresample
  644. Resample the input audio to the specified parameters, using the
  645. libswresample library. If none are specified then the filter will
  646. automatically convert between its input and output.
  647. This filter is also able to stretch/squeeze the audio data to make it match
  648. the timestamps or to inject silence / cut out audio to make it match the
  649. timestamps, do a combination of both or do neither.
  650. The filter accepts the syntax
  651. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  652. expresses a sample rate and @var{resampler_options} is a list of
  653. @var{key}=@var{value} pairs, separated by ":". See the
  654. ffmpeg-resampler manual for the complete list of supported options.
  655. @subsection Examples
  656. @itemize
  657. @item
  658. Resample the input audio to 44100Hz:
  659. @example
  660. aresample=44100
  661. @end example
  662. @item
  663. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  664. samples per second compensation:
  665. @example
  666. aresample=async=1000
  667. @end example
  668. @end itemize
  669. @section asetnsamples
  670. Set the number of samples per each output audio frame.
  671. The last output packet may contain a different number of samples, as
  672. the filter will flush all the remaining samples when the input audio
  673. signal its end.
  674. The filter accepts the following options:
  675. @table @option
  676. @item nb_out_samples, n
  677. Set the number of frames per each output audio frame. The number is
  678. intended as the number of samples @emph{per each channel}.
  679. Default value is 1024.
  680. @item pad, p
  681. If set to 1, the filter will pad the last audio frame with zeroes, so
  682. that the last frame will contain the same number of samples as the
  683. previous ones. Default value is 1.
  684. @end table
  685. For example, to set the number of per-frame samples to 1234 and
  686. disable padding for the last frame, use:
  687. @example
  688. asetnsamples=n=1234:p=0
  689. @end example
  690. @section asetrate
  691. Set the sample rate without altering the PCM data.
  692. This will result in a change of speed and pitch.
  693. The filter accepts the following options:
  694. @table @option
  695. @item sample_rate, r
  696. Set the output sample rate. Default is 44100 Hz.
  697. @end table
  698. @section ashowinfo
  699. Show a line containing various information for each input audio frame.
  700. The input audio is not modified.
  701. The shown line contains a sequence of key/value pairs of the form
  702. @var{key}:@var{value}.
  703. The following values are shown in the output:
  704. @table @option
  705. @item n
  706. The (sequential) number of the input frame, starting from 0.
  707. @item pts
  708. The presentation timestamp of the input frame, in time base units; the time base
  709. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  710. @item pts_time
  711. The presentation timestamp of the input frame in seconds.
  712. @item pos
  713. position of the frame in the input stream, -1 if this information in
  714. unavailable and/or meaningless (for example in case of synthetic audio)
  715. @item fmt
  716. The sample format.
  717. @item chlayout
  718. The channel layout.
  719. @item rate
  720. The sample rate for the audio frame.
  721. @item nb_samples
  722. The number of samples (per channel) in the frame.
  723. @item checksum
  724. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  725. audio, the data is treated as if all the planes were concatenated.
  726. @item plane_checksums
  727. A list of Adler-32 checksums for each data plane.
  728. @end table
  729. @section astats
  730. Display time domain statistical information about the audio channels.
  731. Statistics are calculated and displayed for each audio channel and,
  732. where applicable, an overall figure is also given.
  733. It accepts the following option:
  734. @table @option
  735. @item length
  736. Short window length in seconds, used for peak and trough RMS measurement.
  737. Default is @code{0.05} (50 miliseconds). Allowed range is @code{[0.1 - 10]}.
  738. @end table
  739. A description of each shown parameter follows:
  740. @table @option
  741. @item DC offset
  742. Mean amplitude displacement from zero.
  743. @item Min level
  744. Minimal sample level.
  745. @item Max level
  746. Maximal sample level.
  747. @item Peak level dB
  748. @item RMS level dB
  749. Standard peak and RMS level measured in dBFS.
  750. @item RMS peak dB
  751. @item RMS trough dB
  752. Peak and trough values for RMS level measured over a short window.
  753. @item Crest factor
  754. Standard ratio of peak to RMS level (note: not in dB).
  755. @item Flat factor
  756. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  757. (i.e. either @var{Min level} or @var{Max level}).
  758. @item Peak count
  759. Number of occasions (not the number of samples) that the signal attained either
  760. @var{Min level} or @var{Max level}.
  761. @end table
  762. @section astreamsync
  763. Forward two audio streams and control the order the buffers are forwarded.
  764. The filter accepts the following options:
  765. @table @option
  766. @item expr, e
  767. Set the expression deciding which stream should be
  768. forwarded next: if the result is negative, the first stream is forwarded; if
  769. the result is positive or zero, the second stream is forwarded. It can use
  770. the following variables:
  771. @table @var
  772. @item b1 b2
  773. number of buffers forwarded so far on each stream
  774. @item s1 s2
  775. number of samples forwarded so far on each stream
  776. @item t1 t2
  777. current timestamp of each stream
  778. @end table
  779. The default value is @code{t1-t2}, which means to always forward the stream
  780. that has a smaller timestamp.
  781. @end table
  782. @subsection Examples
  783. Stress-test @code{amerge} by randomly sending buffers on the wrong
  784. input, while avoiding too much of a desynchronization:
  785. @example
  786. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  787. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  788. [a2] [b2] amerge
  789. @end example
  790. @section asyncts
  791. Synchronize audio data with timestamps by squeezing/stretching it and/or
  792. dropping samples/adding silence when needed.
  793. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  794. It accepts the following parameters:
  795. @table @option
  796. @item compensate
  797. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  798. by default. When disabled, time gaps are covered with silence.
  799. @item min_delta
  800. The minimum difference between timestamps and audio data (in seconds) to trigger
  801. adding/dropping samples. The default value is 0.1. If you get an imperfect
  802. sync with this filter, try setting this parameter to 0.
  803. @item max_comp
  804. The maximum compensation in samples per second. Only relevant with compensate=1.
  805. The default value is 500.
  806. @item first_pts
  807. Assume that the first PTS should be this value. The time base is 1 / sample
  808. rate. This allows for padding/trimming at the start of the stream. By default,
  809. no assumption is made about the first frame's expected PTS, so no padding or
  810. trimming is done. For example, this could be set to 0 to pad the beginning with
  811. silence if an audio stream starts after the video stream or to trim any samples
  812. with a negative PTS due to encoder delay.
  813. @end table
  814. @section atempo
  815. Adjust audio tempo.
  816. The filter accepts exactly one parameter, the audio tempo. If not
  817. specified then the filter will assume nominal 1.0 tempo. Tempo must
  818. be in the [0.5, 2.0] range.
  819. @subsection Examples
  820. @itemize
  821. @item
  822. Slow down audio to 80% tempo:
  823. @example
  824. atempo=0.8
  825. @end example
  826. @item
  827. To speed up audio to 125% tempo:
  828. @example
  829. atempo=1.25
  830. @end example
  831. @end itemize
  832. @section atrim
  833. Trim the input so that the output contains one continuous subpart of the input.
  834. It accepts the following parameters:
  835. @table @option
  836. @item start
  837. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  838. sample with the timestamp @var{start} will be the first sample in the output.
  839. @item end
  840. Specify time of the first audio sample that will be dropped, i.e. the
  841. audio sample immediately preceding the one with the timestamp @var{end} will be
  842. the last sample in the output.
  843. @item start_pts
  844. Same as @var{start}, except this option sets the start timestamp in samples
  845. instead of seconds.
  846. @item end_pts
  847. Same as @var{end}, except this option sets the end timestamp in samples instead
  848. of seconds.
  849. @item duration
  850. The maximum duration of the output in seconds.
  851. @item start_sample
  852. The number of the first sample that should be output.
  853. @item end_sample
  854. The number of the first sample that should be dropped.
  855. @end table
  856. @option{start}, @option{end}, @option{duration} are expressed as time
  857. duration specifications, check the "Time duration" section in the
  858. ffmpeg-utils manual.
  859. Note that the first two sets of the start/end options and the @option{duration}
  860. option look at the frame timestamp, while the _sample options simply count the
  861. samples that pass through the filter. So start/end_pts and start/end_sample will
  862. give different results when the timestamps are wrong, inexact or do not start at
  863. zero. Also note that this filter does not modify the timestamps. If you wish
  864. to have the output timestamps start at zero, insert the asetpts filter after the
  865. atrim filter.
  866. If multiple start or end options are set, this filter tries to be greedy and
  867. keep all samples that match at least one of the specified constraints. To keep
  868. only the part that matches all the constraints at once, chain multiple atrim
  869. filters.
  870. The defaults are such that all the input is kept. So it is possible to set e.g.
  871. just the end values to keep everything before the specified time.
  872. Examples:
  873. @itemize
  874. @item
  875. Drop everything except the second minute of input:
  876. @example
  877. ffmpeg -i INPUT -af atrim=60:120
  878. @end example
  879. @item
  880. Keep only the first 1000 samples:
  881. @example
  882. ffmpeg -i INPUT -af atrim=end_sample=1000
  883. @end example
  884. @end itemize
  885. @section bandpass
  886. Apply a two-pole Butterworth band-pass filter with central
  887. frequency @var{frequency}, and (3dB-point) band-width width.
  888. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  889. instead of the default: constant 0dB peak gain.
  890. The filter roll off at 6dB per octave (20dB per decade).
  891. The filter accepts the following options:
  892. @table @option
  893. @item frequency, f
  894. Set the filter's central frequency. Default is @code{3000}.
  895. @item csg
  896. Constant skirt gain if set to 1. Defaults to 0.
  897. @item width_type
  898. Set method to specify band-width of filter.
  899. @table @option
  900. @item h
  901. Hz
  902. @item q
  903. Q-Factor
  904. @item o
  905. octave
  906. @item s
  907. slope
  908. @end table
  909. @item width, w
  910. Specify the band-width of a filter in width_type units.
  911. @end table
  912. @section bandreject
  913. Apply a two-pole Butterworth band-reject filter with central
  914. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  915. The filter roll off at 6dB per octave (20dB per decade).
  916. The filter accepts the following options:
  917. @table @option
  918. @item frequency, f
  919. Set the filter's central frequency. Default is @code{3000}.
  920. @item width_type
  921. Set method to specify band-width of filter.
  922. @table @option
  923. @item h
  924. Hz
  925. @item q
  926. Q-Factor
  927. @item o
  928. octave
  929. @item s
  930. slope
  931. @end table
  932. @item width, w
  933. Specify the band-width of a filter in width_type units.
  934. @end table
  935. @section bass
  936. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  937. shelving filter with a response similar to that of a standard
  938. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  939. The filter accepts the following options:
  940. @table @option
  941. @item gain, g
  942. Give the gain at 0 Hz. Its useful range is about -20
  943. (for a large cut) to +20 (for a large boost).
  944. Beware of clipping when using a positive gain.
  945. @item frequency, f
  946. Set the filter's central frequency and so can be used
  947. to extend or reduce the frequency range to be boosted or cut.
  948. The default value is @code{100} Hz.
  949. @item width_type
  950. Set method to specify band-width of filter.
  951. @table @option
  952. @item h
  953. Hz
  954. @item q
  955. Q-Factor
  956. @item o
  957. octave
  958. @item s
  959. slope
  960. @end table
  961. @item width, w
  962. Determine how steep is the filter's shelf transition.
  963. @end table
  964. @section biquad
  965. Apply a biquad IIR filter with the given coefficients.
  966. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  967. are the numerator and denominator coefficients respectively.
  968. @section bs2b
  969. Bauer stereo to binaural transformation, which improves headphone listening of
  970. stereo audio records.
  971. It accepts the following parameters:
  972. @table @option
  973. @item profile
  974. Pre-defined crossfeed level.
  975. @table @option
  976. @item default
  977. Default level (fcut=700, feed=50).
  978. @item cmoy
  979. Chu Moy circuit (fcut=700, feed=60).
  980. @item jmeier
  981. Jan Meier circuit (fcut=650, feed=95).
  982. @end table
  983. @item fcut
  984. Cut frequency (in Hz).
  985. @item feed
  986. Feed level (in Hz).
  987. @end table
  988. @section channelmap
  989. Remap input channels to new locations.
  990. It accepts the following parameters:
  991. @table @option
  992. @item channel_layout
  993. The channel layout of the output stream.
  994. @item map
  995. Map channels from input to output. The argument is a '|'-separated list of
  996. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  997. @var{in_channel} form. @var{in_channel} can be either the name of the input
  998. channel (e.g. FL for front left) or its index in the input channel layout.
  999. @var{out_channel} is the name of the output channel or its index in the output
  1000. channel layout. If @var{out_channel} is not given then it is implicitly an
  1001. index, starting with zero and increasing by one for each mapping.
  1002. @end table
  1003. If no mapping is present, the filter will implicitly map input channels to
  1004. output channels, preserving indices.
  1005. For example, assuming a 5.1+downmix input MOV file,
  1006. @example
  1007. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1008. @end example
  1009. will create an output WAV file tagged as stereo from the downmix channels of
  1010. the input.
  1011. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1012. @example
  1013. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
  1014. @end example
  1015. @section channelsplit
  1016. Split each channel from an input audio stream into a separate output stream.
  1017. It accepts the following parameters:
  1018. @table @option
  1019. @item channel_layout
  1020. The channel layout of the input stream. The default is "stereo".
  1021. @end table
  1022. For example, assuming a stereo input MP3 file,
  1023. @example
  1024. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1025. @end example
  1026. will create an output Matroska file with two audio streams, one containing only
  1027. the left channel and the other the right channel.
  1028. Split a 5.1 WAV file into per-channel files:
  1029. @example
  1030. ffmpeg -i in.wav -filter_complex
  1031. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1032. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1033. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1034. side_right.wav
  1035. @end example
  1036. @section compand
  1037. Compress or expand the audio's dynamic range.
  1038. It accepts the following parameters:
  1039. @table @option
  1040. @item attacks
  1041. @item decays
  1042. A list of times in seconds for each channel over which the instantaneous level
  1043. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1044. increase of volume and @var{decays} refers to decrease of volume. For most
  1045. situations, the attack time (response to the audio getting louder) should be
  1046. shorter than the decay time, because the human ear is more sensitive to sudden
  1047. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1048. a typical value for decay is 0.8 seconds.
  1049. @item points
  1050. A list of points for the transfer function, specified in dB relative to the
  1051. maximum possible signal amplitude. Each key points list must be defined using
  1052. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1053. @code{x0/y0 x1/y1 x2/y2 ....}
  1054. The input values must be in strictly increasing order but the transfer function
  1055. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1056. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1057. function are @code{-70/-70|-60/-20}.
  1058. @item soft-knee
  1059. Set the curve radius in dB for all joints. It defaults to 0.01.
  1060. @item gain
  1061. Set the additional gain in dB to be applied at all points on the transfer
  1062. function. This allows for easy adjustment of the overall gain.
  1063. It defaults to 0.
  1064. @item volume
  1065. Set an initial volume, in dB, to be assumed for each channel when filtering
  1066. starts. This permits the user to supply a nominal level initially, so that, for
  1067. example, a very large gain is not applied to initial signal levels before the
  1068. companding has begun to operate. A typical value for audio which is initially
  1069. quiet is -90 dB. It defaults to 0.
  1070. @item delay
  1071. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1072. delayed before being fed to the volume adjuster. Specifying a delay
  1073. approximately equal to the attack/decay times allows the filter to effectively
  1074. operate in predictive rather than reactive mode. It defaults to 0.
  1075. @end table
  1076. @subsection Examples
  1077. @itemize
  1078. @item
  1079. Make music with both quiet and loud passages suitable for listening to in a
  1080. noisy environment:
  1081. @example
  1082. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1083. @end example
  1084. @item
  1085. A noise gate for when the noise is at a lower level than the signal:
  1086. @example
  1087. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1088. @end example
  1089. @item
  1090. Here is another noise gate, this time for when the noise is at a higher level
  1091. than the signal (making it, in some ways, similar to squelch):
  1092. @example
  1093. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1094. @end example
  1095. @end itemize
  1096. @section earwax
  1097. Make audio easier to listen to on headphones.
  1098. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1099. so that when listened to on headphones the stereo image is moved from
  1100. inside your head (standard for headphones) to outside and in front of
  1101. the listener (standard for speakers).
  1102. Ported from SoX.
  1103. @section equalizer
  1104. Apply a two-pole peaking equalisation (EQ) filter. With this
  1105. filter, the signal-level at and around a selected frequency can
  1106. be increased or decreased, whilst (unlike bandpass and bandreject
  1107. filters) that at all other frequencies is unchanged.
  1108. In order to produce complex equalisation curves, this filter can
  1109. be given several times, each with a different central frequency.
  1110. The filter accepts the following options:
  1111. @table @option
  1112. @item frequency, f
  1113. Set the filter's central frequency in Hz.
  1114. @item width_type
  1115. Set method to specify band-width of filter.
  1116. @table @option
  1117. @item h
  1118. Hz
  1119. @item q
  1120. Q-Factor
  1121. @item o
  1122. octave
  1123. @item s
  1124. slope
  1125. @end table
  1126. @item width, w
  1127. Specify the band-width of a filter in width_type units.
  1128. @item gain, g
  1129. Set the required gain or attenuation in dB.
  1130. Beware of clipping when using a positive gain.
  1131. @end table
  1132. @subsection Examples
  1133. @itemize
  1134. @item
  1135. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1136. @example
  1137. equalizer=f=1000:width_type=h:width=200:g=-10
  1138. @end example
  1139. @item
  1140. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1141. @example
  1142. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1143. @end example
  1144. @end itemize
  1145. @section flanger
  1146. Apply a flanging effect to the audio.
  1147. The filter accepts the following options:
  1148. @table @option
  1149. @item delay
  1150. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1151. @item depth
  1152. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1153. @item regen
  1154. Set percentage regeneneration (delayed signal feedback). Range from -95 to 95.
  1155. Default value is 0.
  1156. @item width
  1157. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1158. Default valu is 71.
  1159. @item speed
  1160. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1161. @item shape
  1162. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1163. Default value is @var{sinusoidal}.
  1164. @item phase
  1165. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1166. Default value is 25.
  1167. @item interp
  1168. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1169. Default is @var{linear}.
  1170. @end table
  1171. @section highpass
  1172. Apply a high-pass filter with 3dB point frequency.
  1173. The filter can be either single-pole, or double-pole (the default).
  1174. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1175. The filter accepts the following options:
  1176. @table @option
  1177. @item frequency, f
  1178. Set frequency in Hz. Default is 3000.
  1179. @item poles, p
  1180. Set number of poles. Default is 2.
  1181. @item width_type
  1182. Set method to specify band-width of filter.
  1183. @table @option
  1184. @item h
  1185. Hz
  1186. @item q
  1187. Q-Factor
  1188. @item o
  1189. octave
  1190. @item s
  1191. slope
  1192. @end table
  1193. @item width, w
  1194. Specify the band-width of a filter in width_type units.
  1195. Applies only to double-pole filter.
  1196. The default is 0.707q and gives a Butterworth response.
  1197. @end table
  1198. @section join
  1199. Join multiple input streams into one multi-channel stream.
  1200. It accepts the following parameters:
  1201. @table @option
  1202. @item inputs
  1203. The number of input streams. It defaults to 2.
  1204. @item channel_layout
  1205. The desired output channel layout. It defaults to stereo.
  1206. @item map
  1207. Map channels from inputs to output. The argument is a '|'-separated list of
  1208. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1209. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1210. can be either the name of the input channel (e.g. FL for front left) or its
  1211. index in the specified input stream. @var{out_channel} is the name of the output
  1212. channel.
  1213. @end table
  1214. The filter will attempt to guess the mappings when they are not specified
  1215. explicitly. It does so by first trying to find an unused matching input channel
  1216. and if that fails it picks the first unused input channel.
  1217. Join 3 inputs (with properly set channel layouts):
  1218. @example
  1219. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1220. @end example
  1221. Build a 5.1 output from 6 single-channel streams:
  1222. @example
  1223. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1224. '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'
  1225. out
  1226. @end example
  1227. @section ladspa
  1228. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1229. To enable compilation of this filter you need to configure FFmpeg with
  1230. @code{--enable-ladspa}.
  1231. @table @option
  1232. @item file, f
  1233. Specifies the name of LADSPA plugin library to load. If the environment
  1234. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1235. each one of the directories specified by the colon separated list in
  1236. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1237. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1238. @file{/usr/lib/ladspa/}.
  1239. @item plugin, p
  1240. Specifies the plugin within the library. Some libraries contain only
  1241. one plugin, but others contain many of them. If this is not set filter
  1242. will list all available plugins within the specified library.
  1243. @item controls, c
  1244. Set the '|' separated list of controls which are zero or more floating point
  1245. values that determine the behavior of the loaded plugin (for example delay,
  1246. threshold or gain).
  1247. Controls need to be defined using the following syntax:
  1248. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1249. @var{valuei} is the value set on the @var{i}-th control.
  1250. If @option{controls} is set to @code{help}, all available controls and
  1251. their valid ranges are printed.
  1252. @item sample_rate, s
  1253. Specify the sample rate, default to 44100. Only used if plugin have
  1254. zero inputs.
  1255. @item nb_samples, n
  1256. Set the number of samples per channel per each output frame, default
  1257. is 1024. Only used if plugin have zero inputs.
  1258. @item duration, d
  1259. Set the minimum duration of the sourced audio. See the function
  1260. @code{av_parse_time()} for the accepted format, also check the "Time duration"
  1261. section in the ffmpeg-utils manual.
  1262. Note that the resulting duration may be greater than the specified duration,
  1263. as the generated audio is always cut at the end of a complete frame.
  1264. If not specified, or the expressed duration is negative, the audio is
  1265. supposed to be generated forever.
  1266. Only used if plugin have zero inputs.
  1267. @end table
  1268. @subsection Examples
  1269. @itemize
  1270. @item
  1271. List all available plugins within amp (LADSPA example plugin) library:
  1272. @example
  1273. ladspa=file=amp
  1274. @end example
  1275. @item
  1276. List all available controls and their valid ranges for @code{vcf_notch}
  1277. plugin from @code{VCF} library:
  1278. @example
  1279. ladspa=f=vcf:p=vcf_notch:c=help
  1280. @end example
  1281. @item
  1282. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1283. plugin library:
  1284. @example
  1285. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1286. @end example
  1287. @item
  1288. Add reverberation to the audio using TAP-plugins
  1289. (Tom's Audio Processing plugins):
  1290. @example
  1291. ladspa=file=tap_reverb:tap_reverb
  1292. @end example
  1293. @item
  1294. Generate white noise, with 0.2 amplitude:
  1295. @example
  1296. ladspa=file=cmt:noise_source_white:c=c0=.2
  1297. @end example
  1298. @item
  1299. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1300. @code{C* Audio Plugin Suite} (CAPS) library:
  1301. @example
  1302. ladspa=file=caps:Click:c=c1=20'
  1303. @end example
  1304. @item
  1305. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1306. @example
  1307. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1308. @end example
  1309. @end itemize
  1310. @subsection Commands
  1311. This filter supports the following commands:
  1312. @table @option
  1313. @item cN
  1314. Modify the @var{N}-th control value.
  1315. If the specified value is not valid, it is ignored and prior one is kept.
  1316. @end table
  1317. @section lowpass
  1318. Apply a low-pass filter with 3dB point frequency.
  1319. The filter can be either single-pole or double-pole (the default).
  1320. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1321. The filter accepts the following options:
  1322. @table @option
  1323. @item frequency, f
  1324. Set frequency in Hz. Default is 500.
  1325. @item poles, p
  1326. Set number of poles. Default is 2.
  1327. @item width_type
  1328. Set method to specify band-width of filter.
  1329. @table @option
  1330. @item h
  1331. Hz
  1332. @item q
  1333. Q-Factor
  1334. @item o
  1335. octave
  1336. @item s
  1337. slope
  1338. @end table
  1339. @item width, w
  1340. Specify the band-width of a filter in width_type units.
  1341. Applies only to double-pole filter.
  1342. The default is 0.707q and gives a Butterworth response.
  1343. @end table
  1344. @section pan
  1345. Mix channels with specific gain levels. The filter accepts the output
  1346. channel layout followed by a set of channels definitions.
  1347. This filter is also designed to remap efficiently the channels of an audio
  1348. stream.
  1349. The filter accepts parameters of the form:
  1350. "@var{l}:@var{outdef}:@var{outdef}:..."
  1351. @table @option
  1352. @item l
  1353. output channel layout or number of channels
  1354. @item outdef
  1355. output channel specification, of the form:
  1356. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1357. @item out_name
  1358. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1359. number (c0, c1, etc.)
  1360. @item gain
  1361. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1362. @item in_name
  1363. input channel to use, see out_name for details; it is not possible to mix
  1364. named and numbered input channels
  1365. @end table
  1366. If the `=' in a channel specification is replaced by `<', then the gains for
  1367. that specification will be renormalized so that the total is 1, thus
  1368. avoiding clipping noise.
  1369. @subsection Mixing examples
  1370. For example, if you want to down-mix from stereo to mono, but with a bigger
  1371. factor for the left channel:
  1372. @example
  1373. pan=1:c0=0.9*c0+0.1*c1
  1374. @end example
  1375. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1376. 7-channels surround:
  1377. @example
  1378. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1379. @end example
  1380. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1381. that should be preferred (see "-ac" option) unless you have very specific
  1382. needs.
  1383. @subsection Remapping examples
  1384. The channel remapping will be effective if, and only if:
  1385. @itemize
  1386. @item gain coefficients are zeroes or ones,
  1387. @item only one input per channel output,
  1388. @end itemize
  1389. If all these conditions are satisfied, the filter will notify the user ("Pure
  1390. channel mapping detected"), and use an optimized and lossless method to do the
  1391. remapping.
  1392. For example, if you have a 5.1 source and want a stereo audio stream by
  1393. dropping the extra channels:
  1394. @example
  1395. pan="stereo: c0=FL : c1=FR"
  1396. @end example
  1397. Given the same source, you can also switch front left and front right channels
  1398. and keep the input channel layout:
  1399. @example
  1400. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  1401. @end example
  1402. If the input is a stereo audio stream, you can mute the front left channel (and
  1403. still keep the stereo channel layout) with:
  1404. @example
  1405. pan="stereo:c1=c1"
  1406. @end example
  1407. Still with a stereo audio stream input, you can copy the right channel in both
  1408. front left and right:
  1409. @example
  1410. pan="stereo: c0=FR : c1=FR"
  1411. @end example
  1412. @section replaygain
  1413. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1414. outputs it unchanged.
  1415. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1416. @section resample
  1417. Convert the audio sample format, sample rate and channel layout. It is
  1418. not meant to be used directly.
  1419. @section silencedetect
  1420. Detect silence in an audio stream.
  1421. This filter logs a message when it detects that the input audio volume is less
  1422. or equal to a noise tolerance value for a duration greater or equal to the
  1423. minimum detected noise duration.
  1424. The printed times and duration are expressed in seconds.
  1425. The filter accepts the following options:
  1426. @table @option
  1427. @item duration, d
  1428. Set silence duration until notification (default is 2 seconds).
  1429. @item noise, n
  1430. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1431. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1432. @end table
  1433. @subsection Examples
  1434. @itemize
  1435. @item
  1436. Detect 5 seconds of silence with -50dB noise tolerance:
  1437. @example
  1438. silencedetect=n=-50dB:d=5
  1439. @end example
  1440. @item
  1441. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1442. tolerance in @file{silence.mp3}:
  1443. @example
  1444. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1445. @end example
  1446. @end itemize
  1447. @section treble
  1448. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1449. shelving filter with a response similar to that of a standard
  1450. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1451. The filter accepts the following options:
  1452. @table @option
  1453. @item gain, g
  1454. Give the gain at whichever is the lower of ~22 kHz and the
  1455. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1456. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1457. @item frequency, f
  1458. Set the filter's central frequency and so can be used
  1459. to extend or reduce the frequency range to be boosted or cut.
  1460. The default value is @code{3000} Hz.
  1461. @item width_type
  1462. Set method to specify band-width of filter.
  1463. @table @option
  1464. @item h
  1465. Hz
  1466. @item q
  1467. Q-Factor
  1468. @item o
  1469. octave
  1470. @item s
  1471. slope
  1472. @end table
  1473. @item width, w
  1474. Determine how steep is the filter's shelf transition.
  1475. @end table
  1476. @section volume
  1477. Adjust the input audio volume.
  1478. It accepts the following parameters:
  1479. @table @option
  1480. @item volume
  1481. Set audio volume expression.
  1482. Output values are clipped to the maximum value.
  1483. The output audio volume is given by the relation:
  1484. @example
  1485. @var{output_volume} = @var{volume} * @var{input_volume}
  1486. @end example
  1487. The default value for @var{volume} is "1.0".
  1488. @item precision
  1489. This parameter represents the mathematical precision.
  1490. It determines which input sample formats will be allowed, which affects the
  1491. precision of the volume scaling.
  1492. @table @option
  1493. @item fixed
  1494. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1495. @item float
  1496. 32-bit floating-point; this limits input sample format to FLT. (default)
  1497. @item double
  1498. 64-bit floating-point; this limits input sample format to DBL.
  1499. @end table
  1500. @item replaygain
  1501. Choose the behaviour on encountering ReplayGain side data in input frames.
  1502. @table @option
  1503. @item drop
  1504. Remove ReplayGain side data, ignoring its contents (the default).
  1505. @item ignore
  1506. Ignore ReplayGain side data, but leave it in the frame.
  1507. @item track
  1508. Prefer the track gain, if present.
  1509. @item album
  1510. Prefer the album gain, if present.
  1511. @end table
  1512. @item replaygain_preamp
  1513. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1514. Default value for @var{replaygain_preamp} is 0.0.
  1515. @item eval
  1516. Set when the volume expression is evaluated.
  1517. It accepts the following values:
  1518. @table @samp
  1519. @item once
  1520. only evaluate expression once during the filter initialization, or
  1521. when the @samp{volume} command is sent
  1522. @item frame
  1523. evaluate expression for each incoming frame
  1524. @end table
  1525. Default value is @samp{once}.
  1526. @end table
  1527. The volume expression can contain the following parameters.
  1528. @table @option
  1529. @item n
  1530. frame number (starting at zero)
  1531. @item nb_channels
  1532. number of channels
  1533. @item nb_consumed_samples
  1534. number of samples consumed by the filter
  1535. @item nb_samples
  1536. number of samples in the current frame
  1537. @item pos
  1538. original frame position in the file
  1539. @item pts
  1540. frame PTS
  1541. @item sample_rate
  1542. sample rate
  1543. @item startpts
  1544. PTS at start of stream
  1545. @item startt
  1546. time at start of stream
  1547. @item t
  1548. frame time
  1549. @item tb
  1550. timestamp timebase
  1551. @item volume
  1552. last set volume value
  1553. @end table
  1554. Note that when @option{eval} is set to @samp{once} only the
  1555. @var{sample_rate} and @var{tb} variables are available, all other
  1556. variables will evaluate to NAN.
  1557. @subsection Commands
  1558. This filter supports the following commands:
  1559. @table @option
  1560. @item volume
  1561. Modify the volume expression.
  1562. The command accepts the same syntax of the corresponding option.
  1563. If the specified expression is not valid, it is kept at its current
  1564. value.
  1565. @item replaygain_noclip
  1566. Prevent clipping by limiting the gain applied.
  1567. Default value for @var{replaygain_noclip} is 1.
  1568. @end table
  1569. @subsection Examples
  1570. @itemize
  1571. @item
  1572. Halve the input audio volume:
  1573. @example
  1574. volume=volume=0.5
  1575. volume=volume=1/2
  1576. volume=volume=-6.0206dB
  1577. @end example
  1578. In all the above example the named key for @option{volume} can be
  1579. omitted, for example like in:
  1580. @example
  1581. volume=0.5
  1582. @end example
  1583. @item
  1584. Increase input audio power by 6 decibels using fixed-point precision:
  1585. @example
  1586. volume=volume=6dB:precision=fixed
  1587. @end example
  1588. @item
  1589. Fade volume after time 10 with an annihilation period of 5 seconds:
  1590. @example
  1591. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  1592. @end example
  1593. @end itemize
  1594. @section volumedetect
  1595. Detect the volume of the input video.
  1596. The filter has no parameters. The input is not modified. Statistics about
  1597. the volume will be printed in the log when the input stream end is reached.
  1598. In particular it will show the mean volume (root mean square), maximum
  1599. volume (on a per-sample basis), and the beginning of a histogram of the
  1600. registered volume values (from the maximum value to a cumulated 1/1000 of
  1601. the samples).
  1602. All volumes are in decibels relative to the maximum PCM value.
  1603. @subsection Examples
  1604. Here is an excerpt of the output:
  1605. @example
  1606. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1607. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1608. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1609. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1610. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1611. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  1612. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  1613. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  1614. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  1615. @end example
  1616. It means that:
  1617. @itemize
  1618. @item
  1619. The mean square energy is approximately -27 dB, or 10^-2.7.
  1620. @item
  1621. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  1622. @item
  1623. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  1624. @end itemize
  1625. In other words, raising the volume by +4 dB does not cause any clipping,
  1626. raising it by +5 dB causes clipping for 6 samples, etc.
  1627. @c man end AUDIO FILTERS
  1628. @chapter Audio Sources
  1629. @c man begin AUDIO SOURCES
  1630. Below is a description of the currently available audio sources.
  1631. @section abuffer
  1632. Buffer audio frames, and make them available to the filter chain.
  1633. This source is mainly intended for a programmatic use, in particular
  1634. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  1635. It accepts the following parameters:
  1636. @table @option
  1637. @item time_base
  1638. The timebase which will be used for timestamps of submitted frames. It must be
  1639. either a floating-point number or in @var{numerator}/@var{denominator} form.
  1640. @item sample_rate
  1641. The sample rate of the incoming audio buffers.
  1642. @item sample_fmt
  1643. The sample format of the incoming audio buffers.
  1644. Either a sample format name or its corresponging integer representation from
  1645. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  1646. @item channel_layout
  1647. The channel layout of the incoming audio buffers.
  1648. Either a channel layout name from channel_layout_map in
  1649. @file{libavutil/channel_layout.c} or its corresponding integer representation
  1650. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  1651. @item channels
  1652. The number of channels of the incoming audio buffers.
  1653. If both @var{channels} and @var{channel_layout} are specified, then they
  1654. must be consistent.
  1655. @end table
  1656. @subsection Examples
  1657. @example
  1658. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  1659. @end example
  1660. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  1661. Since the sample format with name "s16p" corresponds to the number
  1662. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  1663. equivalent to:
  1664. @example
  1665. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  1666. @end example
  1667. @section aevalsrc
  1668. Generate an audio signal specified by an expression.
  1669. This source accepts in input one or more expressions (one for each
  1670. channel), which are evaluated and used to generate a corresponding
  1671. audio signal.
  1672. This source accepts the following options:
  1673. @table @option
  1674. @item exprs
  1675. Set the '|'-separated expressions list for each separate channel. In case the
  1676. @option{channel_layout} option is not specified, the selected channel layout
  1677. depends on the number of provided expressions. Otherwise the last
  1678. specified expression is applied to the remaining output channels.
  1679. @item channel_layout, c
  1680. Set the channel layout. The number of channels in the specified layout
  1681. must be equal to the number of specified expressions.
  1682. @item duration, d
  1683. Set the minimum duration of the sourced audio. See the function
  1684. @code{av_parse_time()} for the accepted format.
  1685. Note that the resulting duration may be greater than the specified
  1686. duration, as the generated audio is always cut at the end of a
  1687. complete frame.
  1688. If not specified, or the expressed duration is negative, the audio is
  1689. supposed to be generated forever.
  1690. @item nb_samples, n
  1691. Set the number of samples per channel per each output frame,
  1692. default to 1024.
  1693. @item sample_rate, s
  1694. Specify the sample rate, default to 44100.
  1695. @end table
  1696. Each expression in @var{exprs} can contain the following constants:
  1697. @table @option
  1698. @item n
  1699. number of the evaluated sample, starting from 0
  1700. @item t
  1701. time of the evaluated sample expressed in seconds, starting from 0
  1702. @item s
  1703. sample rate
  1704. @end table
  1705. @subsection Examples
  1706. @itemize
  1707. @item
  1708. Generate silence:
  1709. @example
  1710. aevalsrc=0
  1711. @end example
  1712. @item
  1713. Generate a sin signal with frequency of 440 Hz, set sample rate to
  1714. 8000 Hz:
  1715. @example
  1716. aevalsrc="sin(440*2*PI*t):s=8000"
  1717. @end example
  1718. @item
  1719. Generate a two channels signal, specify the channel layout (Front
  1720. Center + Back Center) explicitly:
  1721. @example
  1722. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  1723. @end example
  1724. @item
  1725. Generate white noise:
  1726. @example
  1727. aevalsrc="-2+random(0)"
  1728. @end example
  1729. @item
  1730. Generate an amplitude modulated signal:
  1731. @example
  1732. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  1733. @end example
  1734. @item
  1735. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  1736. @example
  1737. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  1738. @end example
  1739. @end itemize
  1740. @section anullsrc
  1741. The null audio source, return unprocessed audio frames. It is mainly useful
  1742. as a template and to be employed in analysis / debugging tools, or as
  1743. the source for filters which ignore the input data (for example the sox
  1744. synth filter).
  1745. This source accepts the following options:
  1746. @table @option
  1747. @item channel_layout, cl
  1748. Specifies the channel layout, and can be either an integer or a string
  1749. representing a channel layout. The default value of @var{channel_layout}
  1750. is "stereo".
  1751. Check the channel_layout_map definition in
  1752. @file{libavutil/channel_layout.c} for the mapping between strings and
  1753. channel layout values.
  1754. @item sample_rate, r
  1755. Specifies the sample rate, and defaults to 44100.
  1756. @item nb_samples, n
  1757. Set the number of samples per requested frames.
  1758. @end table
  1759. @subsection Examples
  1760. @itemize
  1761. @item
  1762. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  1763. @example
  1764. anullsrc=r=48000:cl=4
  1765. @end example
  1766. @item
  1767. Do the same operation with a more obvious syntax:
  1768. @example
  1769. anullsrc=r=48000:cl=mono
  1770. @end example
  1771. @end itemize
  1772. All the parameters need to be explicitly defined.
  1773. @section flite
  1774. Synthesize a voice utterance using the libflite library.
  1775. To enable compilation of this filter you need to configure FFmpeg with
  1776. @code{--enable-libflite}.
  1777. Note that the flite library is not thread-safe.
  1778. The filter accepts the following options:
  1779. @table @option
  1780. @item list_voices
  1781. If set to 1, list the names of the available voices and exit
  1782. immediately. Default value is 0.
  1783. @item nb_samples, n
  1784. Set the maximum number of samples per frame. Default value is 512.
  1785. @item textfile
  1786. Set the filename containing the text to speak.
  1787. @item text
  1788. Set the text to speak.
  1789. @item voice, v
  1790. Set the voice to use for the speech synthesis. Default value is
  1791. @code{kal}. See also the @var{list_voices} option.
  1792. @end table
  1793. @subsection Examples
  1794. @itemize
  1795. @item
  1796. Read from file @file{speech.txt}, and synthetize the text using the
  1797. standard flite voice:
  1798. @example
  1799. flite=textfile=speech.txt
  1800. @end example
  1801. @item
  1802. Read the specified text selecting the @code{slt} voice:
  1803. @example
  1804. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1805. @end example
  1806. @item
  1807. Input text to ffmpeg:
  1808. @example
  1809. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1810. @end example
  1811. @item
  1812. Make @file{ffplay} speak the specified text, using @code{flite} and
  1813. the @code{lavfi} device:
  1814. @example
  1815. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  1816. @end example
  1817. @end itemize
  1818. For more information about libflite, check:
  1819. @url{http://www.speech.cs.cmu.edu/flite/}
  1820. @section sine
  1821. Generate an audio signal made of a sine wave with amplitude 1/8.
  1822. The audio signal is bit-exact.
  1823. The filter accepts the following options:
  1824. @table @option
  1825. @item frequency, f
  1826. Set the carrier frequency. Default is 440 Hz.
  1827. @item beep_factor, b
  1828. Enable a periodic beep every second with frequency @var{beep_factor} times
  1829. the carrier frequency. Default is 0, meaning the beep is disabled.
  1830. @item sample_rate, r
  1831. Specify the sample rate, default is 44100.
  1832. @item duration, d
  1833. Specify the duration of the generated audio stream.
  1834. @item samples_per_frame
  1835. Set the number of samples per output frame, default is 1024.
  1836. @end table
  1837. @subsection Examples
  1838. @itemize
  1839. @item
  1840. Generate a simple 440 Hz sine wave:
  1841. @example
  1842. sine
  1843. @end example
  1844. @item
  1845. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  1846. @example
  1847. sine=220:4:d=5
  1848. sine=f=220:b=4:d=5
  1849. sine=frequency=220:beep_factor=4:duration=5
  1850. @end example
  1851. @end itemize
  1852. @c man end AUDIO SOURCES
  1853. @chapter Audio Sinks
  1854. @c man begin AUDIO SINKS
  1855. Below is a description of the currently available audio sinks.
  1856. @section abuffersink
  1857. Buffer audio frames, and make them available to the end of filter chain.
  1858. This sink is mainly intended for programmatic use, in particular
  1859. through the interface defined in @file{libavfilter/buffersink.h}
  1860. or the options system.
  1861. It accepts a pointer to an AVABufferSinkContext structure, which
  1862. defines the incoming buffers' formats, to be passed as the opaque
  1863. parameter to @code{avfilter_init_filter} for initialization.
  1864. @section anullsink
  1865. Null audio sink; do absolutely nothing with the input audio. It is
  1866. mainly useful as a template and for use in analysis / debugging
  1867. tools.
  1868. @c man end AUDIO SINKS
  1869. @chapter Video Filters
  1870. @c man begin VIDEO FILTERS
  1871. When you configure your FFmpeg build, you can disable any of the
  1872. existing filters using @code{--disable-filters}.
  1873. The configure output will show the video filters included in your
  1874. build.
  1875. Below is a description of the currently available video filters.
  1876. @section alphaextract
  1877. Extract the alpha component from the input as a grayscale video. This
  1878. is especially useful with the @var{alphamerge} filter.
  1879. @section alphamerge
  1880. Add or replace the alpha component of the primary input with the
  1881. grayscale value of a second input. This is intended for use with
  1882. @var{alphaextract} to allow the transmission or storage of frame
  1883. sequences that have alpha in a format that doesn't support an alpha
  1884. channel.
  1885. For example, to reconstruct full frames from a normal YUV-encoded video
  1886. and a separate video created with @var{alphaextract}, you might use:
  1887. @example
  1888. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  1889. @end example
  1890. Since this filter is designed for reconstruction, it operates on frame
  1891. sequences without considering timestamps, and terminates when either
  1892. input reaches end of stream. This will cause problems if your encoding
  1893. pipeline drops frames. If you're trying to apply an image as an
  1894. overlay to a video stream, consider the @var{overlay} filter instead.
  1895. @section ass
  1896. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  1897. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  1898. Substation Alpha) subtitles files.
  1899. @section bbox
  1900. Compute the bounding box for the non-black pixels in the input frame
  1901. luminance plane.
  1902. This filter computes the bounding box containing all the pixels with a
  1903. luminance value greater than the minimum allowed value.
  1904. The parameters describing the bounding box are printed on the filter
  1905. log.
  1906. The filter accepts the following option:
  1907. @table @option
  1908. @item min_val
  1909. Set the minimal luminance value. Default is @code{16}.
  1910. @end table
  1911. @section blackdetect
  1912. Detect video intervals that are (almost) completely black. Can be
  1913. useful to detect chapter transitions, commercials, or invalid
  1914. recordings. Output lines contains the time for the start, end and
  1915. duration of the detected black interval expressed in seconds.
  1916. In order to display the output lines, you need to set the loglevel at
  1917. least to the AV_LOG_INFO value.
  1918. The filter accepts the following options:
  1919. @table @option
  1920. @item black_min_duration, d
  1921. Set the minimum detected black duration expressed in seconds. It must
  1922. be a non-negative floating point number.
  1923. Default value is 2.0.
  1924. @item picture_black_ratio_th, pic_th
  1925. Set the threshold for considering a picture "black".
  1926. Express the minimum value for the ratio:
  1927. @example
  1928. @var{nb_black_pixels} / @var{nb_pixels}
  1929. @end example
  1930. for which a picture is considered black.
  1931. Default value is 0.98.
  1932. @item pixel_black_th, pix_th
  1933. Set the threshold for considering a pixel "black".
  1934. The threshold expresses the maximum pixel luminance value for which a
  1935. pixel is considered "black". The provided value is scaled according to
  1936. the following equation:
  1937. @example
  1938. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1939. @end example
  1940. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1941. the input video format, the range is [0-255] for YUV full-range
  1942. formats and [16-235] for YUV non full-range formats.
  1943. Default value is 0.10.
  1944. @end table
  1945. The following example sets the maximum pixel threshold to the minimum
  1946. value, and detects only black intervals of 2 or more seconds:
  1947. @example
  1948. blackdetect=d=2:pix_th=0.00
  1949. @end example
  1950. @section blackframe
  1951. Detect frames that are (almost) completely black. Can be useful to
  1952. detect chapter transitions or commercials. Output lines consist of
  1953. the frame number of the detected frame, the percentage of blackness,
  1954. the position in the file if known or -1 and the timestamp in seconds.
  1955. In order to display the output lines, you need to set the loglevel at
  1956. least to the AV_LOG_INFO value.
  1957. It accepts the following parameters:
  1958. @table @option
  1959. @item amount
  1960. The percentage of the pixels that have to be below the threshold; it defaults to
  1961. @code{98}.
  1962. @item threshold, thresh
  1963. The threshold below which a pixel value is considered black; it defaults to
  1964. @code{32}.
  1965. @end table
  1966. @section blend
  1967. Blend two video frames into each other.
  1968. It takes two input streams and outputs one stream, the first input is the
  1969. "top" layer and second input is "bottom" layer.
  1970. Output terminates when shortest input terminates.
  1971. A description of the accepted options follows.
  1972. @table @option
  1973. @item c0_mode
  1974. @item c1_mode
  1975. @item c2_mode
  1976. @item c3_mode
  1977. @item all_mode
  1978. Set blend mode for specific pixel component or all pixel components in case
  1979. of @var{all_mode}. Default value is @code{normal}.
  1980. Available values for component modes are:
  1981. @table @samp
  1982. @item addition
  1983. @item and
  1984. @item average
  1985. @item burn
  1986. @item darken
  1987. @item difference
  1988. @item divide
  1989. @item dodge
  1990. @item exclusion
  1991. @item hardlight
  1992. @item lighten
  1993. @item multiply
  1994. @item negation
  1995. @item normal
  1996. @item or
  1997. @item overlay
  1998. @item phoenix
  1999. @item pinlight
  2000. @item reflect
  2001. @item screen
  2002. @item softlight
  2003. @item subtract
  2004. @item vividlight
  2005. @item xor
  2006. @end table
  2007. @item c0_opacity
  2008. @item c1_opacity
  2009. @item c2_opacity
  2010. @item c3_opacity
  2011. @item all_opacity
  2012. Set blend opacity for specific pixel component or all pixel components in case
  2013. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2014. @item c0_expr
  2015. @item c1_expr
  2016. @item c2_expr
  2017. @item c3_expr
  2018. @item all_expr
  2019. Set blend expression for specific pixel component or all pixel components in case
  2020. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2021. The expressions can use the following variables:
  2022. @table @option
  2023. @item N
  2024. The sequential number of the filtered frame, starting from @code{0}.
  2025. @item X
  2026. @item Y
  2027. the coordinates of the current sample
  2028. @item W
  2029. @item H
  2030. the width and height of currently filtered plane
  2031. @item SW
  2032. @item SH
  2033. Width and height scale depending on the currently filtered plane. It is the
  2034. ratio between the corresponding luma plane number of pixels and the current
  2035. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2036. @code{0.5,0.5} for chroma planes.
  2037. @item T
  2038. Time of the current frame, expressed in seconds.
  2039. @item TOP, A
  2040. Value of pixel component at current location for first video frame (top layer).
  2041. @item BOTTOM, B
  2042. Value of pixel component at current location for second video frame (bottom layer).
  2043. @end table
  2044. @item shortest
  2045. Force termination when the shortest input terminates. Default is @code{0}.
  2046. @item repeatlast
  2047. Continue applying the last bottom frame after the end of the stream. A value of
  2048. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2049. Default is @code{1}.
  2050. @end table
  2051. @subsection Examples
  2052. @itemize
  2053. @item
  2054. Apply transition from bottom layer to top layer in first 10 seconds:
  2055. @example
  2056. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2057. @end example
  2058. @item
  2059. Apply 1x1 checkerboard effect:
  2060. @example
  2061. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2062. @end example
  2063. @item
  2064. Apply uncover left effect:
  2065. @example
  2066. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2067. @end example
  2068. @item
  2069. Apply uncover down effect:
  2070. @example
  2071. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2072. @end example
  2073. @item
  2074. Apply uncover up-left effect:
  2075. @example
  2076. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2077. @end example
  2078. @end itemize
  2079. @section boxblur
  2080. Apply a boxblur algorithm to the input video.
  2081. It accepts the following parameters:
  2082. @table @option
  2083. @item luma_radius, lr
  2084. @item luma_power, lp
  2085. @item chroma_radius, cr
  2086. @item chroma_power, cp
  2087. @item alpha_radius, ar
  2088. @item alpha_power, ap
  2089. @end table
  2090. A description of the accepted options follows.
  2091. @table @option
  2092. @item luma_radius, lr
  2093. @item chroma_radius, cr
  2094. @item alpha_radius, ar
  2095. Set an expression for the box radius in pixels used for blurring the
  2096. corresponding input plane.
  2097. The radius value must be a non-negative number, and must not be
  2098. greater than the value of the expression @code{min(w,h)/2} for the
  2099. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2100. planes.
  2101. Default value for @option{luma_radius} is "2". If not specified,
  2102. @option{chroma_radius} and @option{alpha_radius} default to the
  2103. corresponding value set for @option{luma_radius}.
  2104. The expressions can contain the following constants:
  2105. @table @option
  2106. @item w
  2107. @item h
  2108. The input width and height in pixels.
  2109. @item cw
  2110. @item ch
  2111. The input chroma image width and height in pixels.
  2112. @item hsub
  2113. @item vsub
  2114. The horizontal and vertical chroma subsample values. For example, for the
  2115. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2116. @end table
  2117. @item luma_power, lp
  2118. @item chroma_power, cp
  2119. @item alpha_power, ap
  2120. Specify how many times the boxblur filter is applied to the
  2121. corresponding plane.
  2122. Default value for @option{luma_power} is 2. If not specified,
  2123. @option{chroma_power} and @option{alpha_power} default to the
  2124. corresponding value set for @option{luma_power}.
  2125. A value of 0 will disable the effect.
  2126. @end table
  2127. @subsection Examples
  2128. @itemize
  2129. @item
  2130. Apply a boxblur filter with the luma, chroma, and alpha radii
  2131. set to 2:
  2132. @example
  2133. boxblur=luma_radius=2:luma_power=1
  2134. boxblur=2:1
  2135. @end example
  2136. @item
  2137. Set the luma radius to 2, and alpha and chroma radius to 0:
  2138. @example
  2139. boxblur=2:1:cr=0:ar=0
  2140. @end example
  2141. @item
  2142. Set the luma and chroma radii to a fraction of the video dimension:
  2143. @example
  2144. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2145. @end example
  2146. @end itemize
  2147. @section codecview
  2148. Visualize information exported by some codecs.
  2149. Some codecs can export information through frames using side-data or other
  2150. means. For example, some MPEG based codecs export motion vectors through the
  2151. @var{export_mvs} flag in the codec @option{flags2} option.
  2152. The filter accepts the following option:
  2153. @table @option
  2154. @item mv
  2155. Set motion vectors to visualize.
  2156. Available flags for @var{mv} are:
  2157. @table @samp
  2158. @item pf
  2159. forward predicted MVs of P-frames
  2160. @item bf
  2161. forward predicted MVs of B-frames
  2162. @item bb
  2163. backward predicted MVs of B-frames
  2164. @end table
  2165. @end table
  2166. @subsection Examples
  2167. @itemize
  2168. @item
  2169. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2170. @example
  2171. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2172. @end example
  2173. @end itemize
  2174. @section colorbalance
  2175. Modify intensity of primary colors (red, green and blue) of input frames.
  2176. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2177. regions for the red-cyan, green-magenta or blue-yellow balance.
  2178. A positive adjustment value shifts the balance towards the primary color, a negative
  2179. value towards the complementary color.
  2180. The filter accepts the following options:
  2181. @table @option
  2182. @item rs
  2183. @item gs
  2184. @item bs
  2185. Adjust red, green and blue shadows (darkest pixels).
  2186. @item rm
  2187. @item gm
  2188. @item bm
  2189. Adjust red, green and blue midtones (medium pixels).
  2190. @item rh
  2191. @item gh
  2192. @item bh
  2193. Adjust red, green and blue highlights (brightest pixels).
  2194. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2195. @end table
  2196. @subsection Examples
  2197. @itemize
  2198. @item
  2199. Add red color cast to shadows:
  2200. @example
  2201. colorbalance=rs=.3
  2202. @end example
  2203. @end itemize
  2204. @section colorchannelmixer
  2205. Adjust video input frames by re-mixing color channels.
  2206. This filter modifies a color channel by adding the values associated to
  2207. the other channels of the same pixels. For example if the value to
  2208. modify is red, the output value will be:
  2209. @example
  2210. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2211. @end example
  2212. The filter accepts the following options:
  2213. @table @option
  2214. @item rr
  2215. @item rg
  2216. @item rb
  2217. @item ra
  2218. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2219. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2220. @item gr
  2221. @item gg
  2222. @item gb
  2223. @item ga
  2224. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2225. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2226. @item br
  2227. @item bg
  2228. @item bb
  2229. @item ba
  2230. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2231. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2232. @item ar
  2233. @item ag
  2234. @item ab
  2235. @item aa
  2236. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2237. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2238. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2239. @end table
  2240. @subsection Examples
  2241. @itemize
  2242. @item
  2243. Convert source to grayscale:
  2244. @example
  2245. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2246. @end example
  2247. @item
  2248. Simulate sepia tones:
  2249. @example
  2250. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2251. @end example
  2252. @end itemize
  2253. @section colormatrix
  2254. Convert color matrix.
  2255. The filter accepts the following options:
  2256. @table @option
  2257. @item src
  2258. @item dst
  2259. Specify the source and destination color matrix. Both values must be
  2260. specified.
  2261. The accepted values are:
  2262. @table @samp
  2263. @item bt709
  2264. BT.709
  2265. @item bt601
  2266. BT.601
  2267. @item smpte240m
  2268. SMPTE-240M
  2269. @item fcc
  2270. FCC
  2271. @end table
  2272. @end table
  2273. For example to convert from BT.601 to SMPTE-240M, use the command:
  2274. @example
  2275. colormatrix=bt601:smpte240m
  2276. @end example
  2277. @section copy
  2278. Copy the input source unchanged to the output. This is mainly useful for
  2279. testing purposes.
  2280. @section crop
  2281. Crop the input video to given dimensions.
  2282. It accepts the following parameters:
  2283. @table @option
  2284. @item w, out_w
  2285. The width of the output video. It defaults to @code{iw}.
  2286. This expression is evaluated only once during the filter
  2287. configuration.
  2288. @item h, out_h
  2289. The height of the output video. It defaults to @code{ih}.
  2290. This expression is evaluated only once during the filter
  2291. configuration.
  2292. @item x
  2293. The horizontal position, in the input video, of the left edge of the output
  2294. video. It defaults to @code{(in_w-out_w)/2}.
  2295. This expression is evaluated per-frame.
  2296. @item y
  2297. The vertical position, in the input video, of the top edge of the output video.
  2298. It defaults to @code{(in_h-out_h)/2}.
  2299. This expression is evaluated per-frame.
  2300. @item keep_aspect
  2301. If set to 1 will force the output display aspect ratio
  2302. to be the same of the input, by changing the output sample aspect
  2303. ratio. It defaults to 0.
  2304. @end table
  2305. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2306. expressions containing the following constants:
  2307. @table @option
  2308. @item x
  2309. @item y
  2310. The computed values for @var{x} and @var{y}. They are evaluated for
  2311. each new frame.
  2312. @item in_w
  2313. @item in_h
  2314. The input width and height.
  2315. @item iw
  2316. @item ih
  2317. These are the same as @var{in_w} and @var{in_h}.
  2318. @item out_w
  2319. @item out_h
  2320. The output (cropped) width and height.
  2321. @item ow
  2322. @item oh
  2323. These are the same as @var{out_w} and @var{out_h}.
  2324. @item a
  2325. same as @var{iw} / @var{ih}
  2326. @item sar
  2327. input sample aspect ratio
  2328. @item dar
  2329. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2330. @item hsub
  2331. @item vsub
  2332. horizontal and vertical chroma subsample values. For example for the
  2333. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2334. @item n
  2335. The number of the input frame, starting from 0.
  2336. @item pos
  2337. the position in the file of the input frame, NAN if unknown
  2338. @item t
  2339. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2340. @end table
  2341. The expression for @var{out_w} may depend on the value of @var{out_h},
  2342. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2343. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2344. evaluated after @var{out_w} and @var{out_h}.
  2345. The @var{x} and @var{y} parameters specify the expressions for the
  2346. position of the top-left corner of the output (non-cropped) area. They
  2347. are evaluated for each frame. If the evaluated value is not valid, it
  2348. is approximated to the nearest valid value.
  2349. The expression for @var{x} may depend on @var{y}, and the expression
  2350. for @var{y} may depend on @var{x}.
  2351. @subsection Examples
  2352. @itemize
  2353. @item
  2354. Crop area with size 100x100 at position (12,34).
  2355. @example
  2356. crop=100:100:12:34
  2357. @end example
  2358. Using named options, the example above becomes:
  2359. @example
  2360. crop=w=100:h=100:x=12:y=34
  2361. @end example
  2362. @item
  2363. Crop the central input area with size 100x100:
  2364. @example
  2365. crop=100:100
  2366. @end example
  2367. @item
  2368. Crop the central input area with size 2/3 of the input video:
  2369. @example
  2370. crop=2/3*in_w:2/3*in_h
  2371. @end example
  2372. @item
  2373. Crop the input video central square:
  2374. @example
  2375. crop=out_w=in_h
  2376. crop=in_h
  2377. @end example
  2378. @item
  2379. Delimit the rectangle with the top-left corner placed at position
  2380. 100:100 and the right-bottom corner corresponding to the right-bottom
  2381. corner of the input image.
  2382. @example
  2383. crop=in_w-100:in_h-100:100:100
  2384. @end example
  2385. @item
  2386. Crop 10 pixels from the left and right borders, and 20 pixels from
  2387. the top and bottom borders
  2388. @example
  2389. crop=in_w-2*10:in_h-2*20
  2390. @end example
  2391. @item
  2392. Keep only the bottom right quarter of the input image:
  2393. @example
  2394. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2395. @end example
  2396. @item
  2397. Crop height for getting Greek harmony:
  2398. @example
  2399. crop=in_w:1/PHI*in_w
  2400. @end example
  2401. @item
  2402. Appply trembling effect:
  2403. @example
  2404. 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)
  2405. @end example
  2406. @item
  2407. Apply erratic camera effect depending on timestamp:
  2408. @example
  2409. 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)"
  2410. @end example
  2411. @item
  2412. Set x depending on the value of y:
  2413. @example
  2414. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2415. @end example
  2416. @end itemize
  2417. @section cropdetect
  2418. Auto-detect the crop size.
  2419. It calculates the necessary cropping parameters and prints the
  2420. recommended parameters via the logging system. The detected dimensions
  2421. correspond to the non-black area of the input video.
  2422. It accepts the following parameters:
  2423. @table @option
  2424. @item limit
  2425. Set higher black value threshold, which can be optionally specified
  2426. from nothing (0) to everything (255). An intensity value greater
  2427. to the set value is considered non-black. It defaults to 24.
  2428. @item round
  2429. The value which the width/height should be divisible by. It defaults to
  2430. 16. The offset is automatically adjusted to center the video. Use 2 to
  2431. get only even dimensions (needed for 4:2:2 video). 16 is best when
  2432. encoding to most video codecs.
  2433. @item reset_count, reset
  2434. Set the counter that determines after how many frames cropdetect will
  2435. reset the previously detected largest video area and start over to
  2436. detect the current optimal crop area. Default value is 0.
  2437. This can be useful when channel logos distort the video area. 0
  2438. indicates 'never reset', and returns the largest area encountered during
  2439. playback.
  2440. @end table
  2441. @anchor{curves}
  2442. @section curves
  2443. Apply color adjustments using curves.
  2444. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  2445. component (red, green and blue) has its values defined by @var{N} key points
  2446. tied from each other using a smooth curve. The x-axis represents the pixel
  2447. values from the input frame, and the y-axis the new pixel values to be set for
  2448. the output frame.
  2449. By default, a component curve is defined by the two points @var{(0;0)} and
  2450. @var{(1;1)}. This creates a straight line where each original pixel value is
  2451. "adjusted" to its own value, which means no change to the image.
  2452. The filter allows you to redefine these two points and add some more. A new
  2453. curve (using a natural cubic spline interpolation) will be define to pass
  2454. smoothly through all these new coordinates. The new defined points needs to be
  2455. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  2456. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  2457. the vector spaces, the values will be clipped accordingly.
  2458. If there is no key point defined in @code{x=0}, the filter will automatically
  2459. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  2460. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  2461. The filter accepts the following options:
  2462. @table @option
  2463. @item preset
  2464. Select one of the available color presets. This option can be used in addition
  2465. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  2466. options takes priority on the preset values.
  2467. Available presets are:
  2468. @table @samp
  2469. @item none
  2470. @item color_negative
  2471. @item cross_process
  2472. @item darker
  2473. @item increase_contrast
  2474. @item lighter
  2475. @item linear_contrast
  2476. @item medium_contrast
  2477. @item negative
  2478. @item strong_contrast
  2479. @item vintage
  2480. @end table
  2481. Default is @code{none}.
  2482. @item master, m
  2483. Set the master key points. These points will define a second pass mapping. It
  2484. is sometimes called a "luminance" or "value" mapping. It can be used with
  2485. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  2486. post-processing LUT.
  2487. @item red, r
  2488. Set the key points for the red component.
  2489. @item green, g
  2490. Set the key points for the green component.
  2491. @item blue, b
  2492. Set the key points for the blue component.
  2493. @item all
  2494. Set the key points for all components (not including master).
  2495. Can be used in addition to the other key points component
  2496. options. In this case, the unset component(s) will fallback on this
  2497. @option{all} setting.
  2498. @item psfile
  2499. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  2500. @end table
  2501. To avoid some filtergraph syntax conflicts, each key points list need to be
  2502. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  2503. @subsection Examples
  2504. @itemize
  2505. @item
  2506. Increase slightly the middle level of blue:
  2507. @example
  2508. curves=blue='0.5/0.58'
  2509. @end example
  2510. @item
  2511. Vintage effect:
  2512. @example
  2513. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  2514. @end example
  2515. Here we obtain the following coordinates for each components:
  2516. @table @var
  2517. @item red
  2518. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  2519. @item green
  2520. @code{(0;0) (0.50;0.48) (1;1)}
  2521. @item blue
  2522. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  2523. @end table
  2524. @item
  2525. The previous example can also be achieved with the associated built-in preset:
  2526. @example
  2527. curves=preset=vintage
  2528. @end example
  2529. @item
  2530. Or simply:
  2531. @example
  2532. curves=vintage
  2533. @end example
  2534. @item
  2535. Use a Photoshop preset and redefine the points of the green component:
  2536. @example
  2537. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  2538. @end example
  2539. @end itemize
  2540. @section dctdnoiz
  2541. Denoise frames using 2D DCT (frequency domain filtering).
  2542. This filter is not designed for real time.
  2543. The filter accepts the following options:
  2544. @table @option
  2545. @item sigma, s
  2546. Set the noise sigma constant.
  2547. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  2548. coefficient (absolute value) below this threshold with be dropped.
  2549. If you need a more advanced filtering, see @option{expr}.
  2550. Default is @code{0}.
  2551. @item overlap
  2552. Set number overlapping pixels for each block. Since the filter can be slow, you
  2553. may want to reduce this value, at the cost of a less effective filter and the
  2554. risk of various artefacts.
  2555. If the overlapping value doesn't allow to process the whole input width or
  2556. height, a warning will be displayed and according borders won't be denoised.
  2557. Default value is @var{blocksize}-1, which is the best possible setting.
  2558. @item expr, e
  2559. Set the coefficient factor expression.
  2560. For each coefficient of a DCT block, this expression will be evaluated as a
  2561. multiplier value for the coefficient.
  2562. If this is option is set, the @option{sigma} option will be ignored.
  2563. The absolute value of the coefficient can be accessed through the @var{c}
  2564. variable.
  2565. @item n
  2566. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  2567. @var{blocksize}, which is the width and height of the processed blocks.
  2568. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  2569. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  2570. on the speed processing. Also, a larger block size does not necessarily means a
  2571. better de-noising.
  2572. @end table
  2573. @subsection Examples
  2574. Apply a denoise with a @option{sigma} of @code{4.5}:
  2575. @example
  2576. dctdnoiz=4.5
  2577. @end example
  2578. The same operation can be achieved using the expression system:
  2579. @example
  2580. dctdnoiz=e='gte(c, 4.5*3)'
  2581. @end example
  2582. Violent denoise using a block size of @code{16x16}:
  2583. @example
  2584. dctdnoiz=15:n=4
  2585. @end example
  2586. @anchor{decimate}
  2587. @section decimate
  2588. Drop duplicated frames at regular intervals.
  2589. The filter accepts the following options:
  2590. @table @option
  2591. @item cycle
  2592. Set the number of frames from which one will be dropped. Setting this to
  2593. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  2594. Default is @code{5}.
  2595. @item dupthresh
  2596. Set the threshold for duplicate detection. If the difference metric for a frame
  2597. is less than or equal to this value, then it is declared as duplicate. Default
  2598. is @code{1.1}
  2599. @item scthresh
  2600. Set scene change threshold. Default is @code{15}.
  2601. @item blockx
  2602. @item blocky
  2603. Set the size of the x and y-axis blocks used during metric calculations.
  2604. Larger blocks give better noise suppression, but also give worse detection of
  2605. small movements. Must be a power of two. Default is @code{32}.
  2606. @item ppsrc
  2607. Mark main input as a pre-processed input and activate clean source input
  2608. stream. This allows the input to be pre-processed with various filters to help
  2609. the metrics calculation while keeping the frame selection lossless. When set to
  2610. @code{1}, the first stream is for the pre-processed input, and the second
  2611. stream is the clean source from where the kept frames are chosen. Default is
  2612. @code{0}.
  2613. @item chroma
  2614. Set whether or not chroma is considered in the metric calculations. Default is
  2615. @code{1}.
  2616. @end table
  2617. @section dejudder
  2618. Remove judder produced by partially interlaced telecined content.
  2619. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  2620. source was partially telecined content then the output of @code{pullup,dejudder}
  2621. will have a variable frame rate. May change the recorded frame rate of the
  2622. container. Aside from that change, this filter will not affect constant frame
  2623. rate video.
  2624. The option available in this filter is:
  2625. @table @option
  2626. @item cycle
  2627. Specify the length of the window over which the judder repeats.
  2628. Accepts any integer greater than 1. Useful values are:
  2629. @table @samp
  2630. @item 4
  2631. If the original was telecined from 24 to 30 fps (Film to NTSC).
  2632. @item 5
  2633. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  2634. @item 20
  2635. If a mixture of the two.
  2636. @end table
  2637. The default is @samp{4}.
  2638. @end table
  2639. @section delogo
  2640. Suppress a TV station logo by a simple interpolation of the surrounding
  2641. pixels. Just set a rectangle covering the logo and watch it disappear
  2642. (and sometimes something even uglier appear - your mileage may vary).
  2643. It accepts the following parameters:
  2644. @table @option
  2645. @item x
  2646. @item y
  2647. Specify the top left corner coordinates of the logo. They must be
  2648. specified.
  2649. @item w
  2650. @item h
  2651. Specify the width and height of the logo to clear. They must be
  2652. specified.
  2653. @item band, t
  2654. Specify the thickness of the fuzzy edge of the rectangle (added to
  2655. @var{w} and @var{h}). The default value is 4.
  2656. @item show
  2657. When set to 1, a green rectangle is drawn on the screen to simplify
  2658. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  2659. The default value is 0.
  2660. The rectangle is drawn on the outermost pixels which will be (partly)
  2661. replaced with interpolated values. The values of the next pixels
  2662. immediately outside this rectangle in each direction will be used to
  2663. compute the interpolated pixel values inside the rectangle.
  2664. @end table
  2665. @subsection Examples
  2666. @itemize
  2667. @item
  2668. Set a rectangle covering the area with top left corner coordinates 0,0
  2669. and size 100x77, and a band of size 10:
  2670. @example
  2671. delogo=x=0:y=0:w=100:h=77:band=10
  2672. @end example
  2673. @end itemize
  2674. @section deshake
  2675. Attempt to fix small changes in horizontal and/or vertical shift. This
  2676. filter helps remove camera shake from hand-holding a camera, bumping a
  2677. tripod, moving on a vehicle, etc.
  2678. The filter accepts the following options:
  2679. @table @option
  2680. @item x
  2681. @item y
  2682. @item w
  2683. @item h
  2684. Specify a rectangular area where to limit the search for motion
  2685. vectors.
  2686. If desired the search for motion vectors can be limited to a
  2687. rectangular area of the frame defined by its top left corner, width
  2688. and height. These parameters have the same meaning as the drawbox
  2689. filter which can be used to visualise the position of the bounding
  2690. box.
  2691. This is useful when simultaneous movement of subjects within the frame
  2692. might be confused for camera motion by the motion vector search.
  2693. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  2694. then the full frame is used. This allows later options to be set
  2695. without specifying the bounding box for the motion vector search.
  2696. Default - search the whole frame.
  2697. @item rx
  2698. @item ry
  2699. Specify the maximum extent of movement in x and y directions in the
  2700. range 0-64 pixels. Default 16.
  2701. @item edge
  2702. Specify how to generate pixels to fill blanks at the edge of the
  2703. frame. Available values are:
  2704. @table @samp
  2705. @item blank, 0
  2706. Fill zeroes at blank locations
  2707. @item original, 1
  2708. Original image at blank locations
  2709. @item clamp, 2
  2710. Extruded edge value at blank locations
  2711. @item mirror, 3
  2712. Mirrored edge at blank locations
  2713. @end table
  2714. Default value is @samp{mirror}.
  2715. @item blocksize
  2716. Specify the blocksize to use for motion search. Range 4-128 pixels,
  2717. default 8.
  2718. @item contrast
  2719. Specify the contrast threshold for blocks. Only blocks with more than
  2720. the specified contrast (difference between darkest and lightest
  2721. pixels) will be considered. Range 1-255, default 125.
  2722. @item search
  2723. Specify the search strategy. Available values are:
  2724. @table @samp
  2725. @item exhaustive, 0
  2726. Set exhaustive search
  2727. @item less, 1
  2728. Set less exhaustive search.
  2729. @end table
  2730. Default value is @samp{exhaustive}.
  2731. @item filename
  2732. If set then a detailed log of the motion search is written to the
  2733. specified file.
  2734. @item opencl
  2735. If set to 1, specify using OpenCL capabilities, only available if
  2736. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  2737. @end table
  2738. @section drawbox
  2739. Draw a colored box on the input image.
  2740. It accepts the following parameters:
  2741. @table @option
  2742. @item x
  2743. @item y
  2744. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  2745. @item width, w
  2746. @item height, h
  2747. The expressions which specify the width and height of the box; if 0 they are interpreted as
  2748. the input width and height. It defaults to 0.
  2749. @item color, c
  2750. Specify the color of the box to write. For the general syntax of this option,
  2751. check the "Color" section in the ffmpeg-utils manual. If the special
  2752. value @code{invert} is used, the box edge color is the same as the
  2753. video with inverted luma.
  2754. @item thickness, t
  2755. The expression which sets the thickness of the box edge. Default value is @code{3}.
  2756. See below for the list of accepted constants.
  2757. @end table
  2758. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  2759. following constants:
  2760. @table @option
  2761. @item dar
  2762. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  2763. @item hsub
  2764. @item vsub
  2765. horizontal and vertical chroma subsample values. For example for the
  2766. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2767. @item in_h, ih
  2768. @item in_w, iw
  2769. The input width and height.
  2770. @item sar
  2771. The input sample aspect ratio.
  2772. @item x
  2773. @item y
  2774. The x and y offset coordinates where the box is drawn.
  2775. @item w
  2776. @item h
  2777. The width and height of the drawn box.
  2778. @item t
  2779. The thickness of the drawn box.
  2780. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  2781. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  2782. @end table
  2783. @subsection Examples
  2784. @itemize
  2785. @item
  2786. Draw a black box around the edge of the input image:
  2787. @example
  2788. drawbox
  2789. @end example
  2790. @item
  2791. Draw a box with color red and an opacity of 50%:
  2792. @example
  2793. drawbox=10:20:200:60:red@@0.5
  2794. @end example
  2795. The previous example can be specified as:
  2796. @example
  2797. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  2798. @end example
  2799. @item
  2800. Fill the box with pink color:
  2801. @example
  2802. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  2803. @end example
  2804. @item
  2805. Draw a 2-pixel red 2.40:1 mask:
  2806. @example
  2807. 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
  2808. @end example
  2809. @end itemize
  2810. @section drawgrid
  2811. Draw a grid on the input image.
  2812. It accepts the following parameters:
  2813. @table @option
  2814. @item x
  2815. @item y
  2816. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  2817. @item width, w
  2818. @item height, h
  2819. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  2820. input width and height, respectively, minus @code{thickness}, so image gets
  2821. framed. Default to 0.
  2822. @item color, c
  2823. Specify the color of the grid. For the general syntax of this option,
  2824. check the "Color" section in the ffmpeg-utils manual. If the special
  2825. value @code{invert} is used, the grid color is the same as the
  2826. video with inverted luma.
  2827. @item thickness, t
  2828. The expression which sets the thickness of the grid line. Default value is @code{1}.
  2829. See below for the list of accepted constants.
  2830. @end table
  2831. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  2832. following constants:
  2833. @table @option
  2834. @item dar
  2835. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  2836. @item hsub
  2837. @item vsub
  2838. horizontal and vertical chroma subsample values. For example for the
  2839. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2840. @item in_h, ih
  2841. @item in_w, iw
  2842. The input grid cell width and height.
  2843. @item sar
  2844. The input sample aspect ratio.
  2845. @item x
  2846. @item y
  2847. The x and y coordinates of some point of grid intersection (meant to configure offset).
  2848. @item w
  2849. @item h
  2850. The width and height of the drawn cell.
  2851. @item t
  2852. The thickness of the drawn cell.
  2853. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  2854. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  2855. @end table
  2856. @subsection Examples
  2857. @itemize
  2858. @item
  2859. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  2860. @example
  2861. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  2862. @end example
  2863. @item
  2864. Draw a white 3x3 grid with an opacity of 50%:
  2865. @example
  2866. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  2867. @end example
  2868. @end itemize
  2869. @anchor{drawtext}
  2870. @section drawtext
  2871. Draw a text string or text from a specified file on top of a video, using the
  2872. libfreetype library.
  2873. To enable compilation of this filter, you need to configure FFmpeg with
  2874. @code{--enable-libfreetype}.
  2875. To enable default font fallback and the @var{font} option you need to
  2876. configure FFmpeg with @code{--enable-libfontconfig}.
  2877. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  2878. @code{--enable-libfribidi}.
  2879. @subsection Syntax
  2880. It accepts the following parameters:
  2881. @table @option
  2882. @item box
  2883. Used to draw a box around text using the background color.
  2884. The value must be either 1 (enable) or 0 (disable).
  2885. The default value of @var{box} is 0.
  2886. @item boxcolor
  2887. The color to be used for drawing box around text. For the syntax of this
  2888. option, check the "Color" section in the ffmpeg-utils manual.
  2889. The default value of @var{boxcolor} is "white".
  2890. @item borderw
  2891. Set the width of the border to be drawn around the text using @var{bordercolor}.
  2892. The default value of @var{borderw} is 0.
  2893. @item bordercolor
  2894. Set the color to be used for drawing border around text. For the syntax of this
  2895. option, check the "Color" section in the ffmpeg-utils manual.
  2896. The default value of @var{bordercolor} is "black".
  2897. @item expansion
  2898. Select how the @var{text} is expanded. Can be either @code{none},
  2899. @code{strftime} (deprecated) or
  2900. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  2901. below for details.
  2902. @item fix_bounds
  2903. If true, check and fix text coords to avoid clipping.
  2904. @item fontcolor
  2905. The color to be used for drawing fonts. For the syntax of this option, check
  2906. the "Color" section in the ffmpeg-utils manual.
  2907. The default value of @var{fontcolor} is "black".
  2908. @item fontcolor_expr
  2909. String which is expanded the same way as @var{text} to obtain dynamic
  2910. @var{fontcolor} value. By default this option has empty value and is not
  2911. processed. When this option is set, it overrides @var{fontcolor} option.
  2912. @item font
  2913. The font family to be used for drawing text. By default Sans.
  2914. @item fontfile
  2915. The font file to be used for drawing text. The path must be included.
  2916. This parameter is mandatory if the fontconfig support is disabled.
  2917. @item fontsize
  2918. The font size to be used for drawing text.
  2919. The default value of @var{fontsize} is 16.
  2920. @item text_shaping
  2921. If set to 1, attempt to shape the text (for example, reverse the order of
  2922. right-to-left text and join Arabic characters) before drawing it.
  2923. Otherwise, just draw the text exactly as given.
  2924. By default 1 (if supported).
  2925. @item ft_load_flags
  2926. The flags to be used for loading the fonts.
  2927. The flags map the corresponding flags supported by libfreetype, and are
  2928. a combination of the following values:
  2929. @table @var
  2930. @item default
  2931. @item no_scale
  2932. @item no_hinting
  2933. @item render
  2934. @item no_bitmap
  2935. @item vertical_layout
  2936. @item force_autohint
  2937. @item crop_bitmap
  2938. @item pedantic
  2939. @item ignore_global_advance_width
  2940. @item no_recurse
  2941. @item ignore_transform
  2942. @item monochrome
  2943. @item linear_design
  2944. @item no_autohint
  2945. @end table
  2946. Default value is "default".
  2947. For more information consult the documentation for the FT_LOAD_*
  2948. libfreetype flags.
  2949. @item shadowcolor
  2950. The color to be used for drawing a shadow behind the drawn text. For the
  2951. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  2952. The default value of @var{shadowcolor} is "black".
  2953. @item shadowx
  2954. @item shadowy
  2955. The x and y offsets for the text shadow position with respect to the
  2956. position of the text. They can be either positive or negative
  2957. values. The default value for both is "0".
  2958. @item start_number
  2959. The starting frame number for the n/frame_num variable. The default value
  2960. is "0".
  2961. @item tabsize
  2962. The size in number of spaces to use for rendering the tab.
  2963. Default value is 4.
  2964. @item timecode
  2965. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  2966. format. It can be used with or without text parameter. @var{timecode_rate}
  2967. option must be specified.
  2968. @item timecode_rate, rate, r
  2969. Set the timecode frame rate (timecode only).
  2970. @item text
  2971. The text string to be drawn. The text must be a sequence of UTF-8
  2972. encoded characters.
  2973. This parameter is mandatory if no file is specified with the parameter
  2974. @var{textfile}.
  2975. @item textfile
  2976. A text file containing text to be drawn. The text must be a sequence
  2977. of UTF-8 encoded characters.
  2978. This parameter is mandatory if no text string is specified with the
  2979. parameter @var{text}.
  2980. If both @var{text} and @var{textfile} are specified, an error is thrown.
  2981. @item reload
  2982. If set to 1, the @var{textfile} will be reloaded before each frame.
  2983. Be sure to update it atomically, or it may be read partially, or even fail.
  2984. @item x
  2985. @item y
  2986. The expressions which specify the offsets where text will be drawn
  2987. within the video frame. They are relative to the top/left border of the
  2988. output image.
  2989. The default value of @var{x} and @var{y} is "0".
  2990. See below for the list of accepted constants and functions.
  2991. @end table
  2992. The parameters for @var{x} and @var{y} are expressions containing the
  2993. following constants and functions:
  2994. @table @option
  2995. @item dar
  2996. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  2997. @item hsub
  2998. @item vsub
  2999. horizontal and vertical chroma subsample values. For example for the
  3000. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3001. @item line_h, lh
  3002. the height of each text line
  3003. @item main_h, h, H
  3004. the input height
  3005. @item main_w, w, W
  3006. the input width
  3007. @item max_glyph_a, ascent
  3008. the maximum distance from the baseline to the highest/upper grid
  3009. coordinate used to place a glyph outline point, for all the rendered
  3010. glyphs.
  3011. It is a positive value, due to the grid's orientation with the Y axis
  3012. upwards.
  3013. @item max_glyph_d, descent
  3014. the maximum distance from the baseline to the lowest grid coordinate
  3015. used to place a glyph outline point, for all the rendered glyphs.
  3016. This is a negative value, due to the grid's orientation, with the Y axis
  3017. upwards.
  3018. @item max_glyph_h
  3019. maximum glyph height, that is the maximum height for all the glyphs
  3020. contained in the rendered text, it is equivalent to @var{ascent} -
  3021. @var{descent}.
  3022. @item max_glyph_w
  3023. maximum glyph width, that is the maximum width for all the glyphs
  3024. contained in the rendered text
  3025. @item n
  3026. the number of input frame, starting from 0
  3027. @item rand(min, max)
  3028. return a random number included between @var{min} and @var{max}
  3029. @item sar
  3030. The input sample aspect ratio.
  3031. @item t
  3032. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3033. @item text_h, th
  3034. the height of the rendered text
  3035. @item text_w, tw
  3036. the width of the rendered text
  3037. @item x
  3038. @item y
  3039. the x and y offset coordinates where the text is drawn.
  3040. These parameters allow the @var{x} and @var{y} expressions to refer
  3041. each other, so you can for example specify @code{y=x/dar}.
  3042. @end table
  3043. @anchor{drawtext_expansion}
  3044. @subsection Text expansion
  3045. If @option{expansion} is set to @code{strftime},
  3046. the filter recognizes strftime() sequences in the provided text and
  3047. expands them accordingly. Check the documentation of strftime(). This
  3048. feature is deprecated.
  3049. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3050. If @option{expansion} is set to @code{normal} (which is the default),
  3051. the following expansion mechanism is used.
  3052. The backslash character '\', followed by any character, always expands to
  3053. the second character.
  3054. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3055. braces is a function name, possibly followed by arguments separated by ':'.
  3056. If the arguments contain special characters or delimiters (':' or '@}'),
  3057. they should be escaped.
  3058. Note that they probably must also be escaped as the value for the
  3059. @option{text} option in the filter argument string and as the filter
  3060. argument in the filtergraph description, and possibly also for the shell,
  3061. that makes up to four levels of escaping; using a text file avoids these
  3062. problems.
  3063. The following functions are available:
  3064. @table @command
  3065. @item expr, e
  3066. The expression evaluation result.
  3067. It must take one argument specifying the expression to be evaluated,
  3068. which accepts the same constants and functions as the @var{x} and
  3069. @var{y} values. Note that not all constants should be used, for
  3070. example the text size is not known when evaluating the expression, so
  3071. the constants @var{text_w} and @var{text_h} will have an undefined
  3072. value.
  3073. @item expr_int_format, eif
  3074. Evaluate the expression's value and output as formatted integer.
  3075. First argument is expression to be evaluated, same as for @var{expr} function.
  3076. Second argument specifies output format. Allowed values are 'x', 'X', 'd' and
  3077. 'u', they are treated exactly as in printf function.
  3078. Third parameter is optional and sets the number of positions taken by output.
  3079. Effectively this allows to add padding with zeros from the left.
  3080. @item gmtime
  3081. The time at which the filter is running, expressed in UTC.
  3082. It can accept an argument: a strftime() format string.
  3083. @item localtime
  3084. The time at which the filter is running, expressed in the local time zone.
  3085. It can accept an argument: a strftime() format string.
  3086. @item metadata
  3087. Frame metadata. It must take one argument specifying metadata key.
  3088. @item n, frame_num
  3089. The frame number, starting from 0.
  3090. @item pict_type
  3091. A 1 character description of the current picture type.
  3092. @item pts
  3093. The timestamp of the current frame.
  3094. It can take up to two arguments.
  3095. The first argument is the format of the timestamp; it defaults to @code{flt}
  3096. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3097. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3098. The second argument is an offset added to the timestamp.
  3099. @end table
  3100. @subsection Examples
  3101. @itemize
  3102. @item
  3103. Draw "Test Text" with font FreeSerif, using the default values for the
  3104. optional parameters.
  3105. @example
  3106. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3107. @end example
  3108. @item
  3109. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3110. and y=50 (counting from the top-left corner of the screen), text is
  3111. yellow with a red box around it. Both the text and the box have an
  3112. opacity of 20%.
  3113. @example
  3114. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3115. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3116. @end example
  3117. Note that the double quotes are not necessary if spaces are not used
  3118. within the parameter list.
  3119. @item
  3120. Show the text at the center of the video frame:
  3121. @example
  3122. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3123. @end example
  3124. @item
  3125. Show a text line sliding from right to left in the last row of the video
  3126. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3127. with no newlines.
  3128. @example
  3129. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3130. @end example
  3131. @item
  3132. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3133. @example
  3134. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3135. @end example
  3136. @item
  3137. Draw a single green letter "g", at the center of the input video.
  3138. The glyph baseline is placed at half screen height.
  3139. @example
  3140. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3141. @end example
  3142. @item
  3143. Show text for 1 second every 3 seconds:
  3144. @example
  3145. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3146. @end example
  3147. @item
  3148. Use fontconfig to set the font. Note that the colons need to be escaped.
  3149. @example
  3150. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3151. @end example
  3152. @item
  3153. Print the date of a real-time encoding (see strftime(3)):
  3154. @example
  3155. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  3156. @end example
  3157. @item
  3158. Show text fading in and out (appearing/disappearing):
  3159. @example
  3160. #!/bin/sh
  3161. DS=1.0 # display start
  3162. DE=10.0 # display end
  3163. FID=1.5 # fade in duration
  3164. FOD=5 # fade out duration
  3165. 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 @}"
  3166. @end example
  3167. @end itemize
  3168. For more information about libfreetype, check:
  3169. @url{http://www.freetype.org/}.
  3170. For more information about fontconfig, check:
  3171. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3172. For more information about libfribidi, check:
  3173. @url{http://fribidi.org/}.
  3174. @section edgedetect
  3175. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3176. The filter accepts the following options:
  3177. @table @option
  3178. @item low
  3179. @item high
  3180. Set low and high threshold values used by the Canny thresholding
  3181. algorithm.
  3182. The high threshold selects the "strong" edge pixels, which are then
  3183. connected through 8-connectivity with the "weak" edge pixels selected
  3184. by the low threshold.
  3185. @var{low} and @var{high} threshold values must be chosen in the range
  3186. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3187. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3188. is @code{50/255}.
  3189. @item mode
  3190. Define the drawing mode.
  3191. @table @samp
  3192. @item wires
  3193. Draw white/gray wires on black background.
  3194. @item colormix
  3195. Mix the colors to create a paint/cartoon effect.
  3196. @end table
  3197. Default value is @var{wires}.
  3198. @end table
  3199. @subsection Examples
  3200. @itemize
  3201. @item
  3202. Standard edge detection with custom values for the hysteresis thresholding:
  3203. @example
  3204. edgedetect=low=0.1:high=0.4
  3205. @end example
  3206. @item
  3207. Painting effect without thresholding:
  3208. @example
  3209. edgedetect=mode=colormix:high=0
  3210. @end example
  3211. @end itemize
  3212. @section extractplanes
  3213. Extract color channel components from input video stream into
  3214. separate grayscale video streams.
  3215. The filter accepts the following option:
  3216. @table @option
  3217. @item planes
  3218. Set plane(s) to extract.
  3219. Available values for planes are:
  3220. @table @samp
  3221. @item y
  3222. @item u
  3223. @item v
  3224. @item a
  3225. @item r
  3226. @item g
  3227. @item b
  3228. @end table
  3229. Choosing planes not available in the input will result in an error.
  3230. That means you cannot select @code{r}, @code{g}, @code{b} planes
  3231. with @code{y}, @code{u}, @code{v} planes at same time.
  3232. @end table
  3233. @subsection Examples
  3234. @itemize
  3235. @item
  3236. Extract luma, u and v color channel component from input video frame
  3237. into 3 grayscale outputs:
  3238. @example
  3239. 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
  3240. @end example
  3241. @end itemize
  3242. @section elbg
  3243. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  3244. For each input image, the filter will compute the optimal mapping from
  3245. the input to the output given the codebook length, that is the number
  3246. of distinct output colors.
  3247. This filter accepts the following options.
  3248. @table @option
  3249. @item codebook_length, l
  3250. Set codebook length. The value must be a positive integer, and
  3251. represents the number of distinct output colors. Default value is 256.
  3252. @item nb_steps, n
  3253. Set the maximum number of iterations to apply for computing the optimal
  3254. mapping. The higher the value the better the result and the higher the
  3255. computation time. Default value is 1.
  3256. @item seed, s
  3257. Set a random seed, must be an integer included between 0 and
  3258. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  3259. will try to use a good random seed on a best effort basis.
  3260. @end table
  3261. @section fade
  3262. Apply a fade-in/out effect to the input video.
  3263. It accepts the following parameters:
  3264. @table @option
  3265. @item type, t
  3266. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  3267. effect.
  3268. Default is @code{in}.
  3269. @item start_frame, s
  3270. Specify the number of the frame to start applying the fade
  3271. effect at. Default is 0.
  3272. @item nb_frames, n
  3273. The number of frames that the fade effect lasts. At the end of the
  3274. fade-in effect, the output video will have the same intensity as the input video.
  3275. At the end of the fade-out transition, the output video will be filled with the
  3276. selected @option{color}.
  3277. Default is 25.
  3278. @item alpha
  3279. If set to 1, fade only alpha channel, if one exists on the input.
  3280. Default value is 0.
  3281. @item start_time, st
  3282. Specify the timestamp (in seconds) of the frame to start to apply the fade
  3283. effect. If both start_frame and start_time are specified, the fade will start at
  3284. whichever comes last. Default is 0.
  3285. @item duration, d
  3286. The number of seconds for which the fade effect has to last. At the end of the
  3287. fade-in effect the output video will have the same intensity as the input video,
  3288. at the end of the fade-out transition the output video will be filled with the
  3289. selected @option{color}.
  3290. If both duration and nb_frames are specified, duration is used. Default is 0.
  3291. @item color, c
  3292. Specify the color of the fade. Default is "black".
  3293. @end table
  3294. @subsection Examples
  3295. @itemize
  3296. @item
  3297. Fade in the first 30 frames of video:
  3298. @example
  3299. fade=in:0:30
  3300. @end example
  3301. The command above is equivalent to:
  3302. @example
  3303. fade=t=in:s=0:n=30
  3304. @end example
  3305. @item
  3306. Fade out the last 45 frames of a 200-frame video:
  3307. @example
  3308. fade=out:155:45
  3309. fade=type=out:start_frame=155:nb_frames=45
  3310. @end example
  3311. @item
  3312. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  3313. @example
  3314. fade=in:0:25, fade=out:975:25
  3315. @end example
  3316. @item
  3317. Make the first 5 frames yellow, then fade in from frame 5-24:
  3318. @example
  3319. fade=in:5:20:color=yellow
  3320. @end example
  3321. @item
  3322. Fade in alpha over first 25 frames of video:
  3323. @example
  3324. fade=in:0:25:alpha=1
  3325. @end example
  3326. @item
  3327. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  3328. @example
  3329. fade=t=in:st=5.5:d=0.5
  3330. @end example
  3331. @end itemize
  3332. @section field
  3333. Extract a single field from an interlaced image using stride
  3334. arithmetic to avoid wasting CPU time. The output frames are marked as
  3335. non-interlaced.
  3336. The filter accepts the following options:
  3337. @table @option
  3338. @item type
  3339. Specify whether to extract the top (if the value is @code{0} or
  3340. @code{top}) or the bottom field (if the value is @code{1} or
  3341. @code{bottom}).
  3342. @end table
  3343. @section fieldmatch
  3344. Field matching filter for inverse telecine. It is meant to reconstruct the
  3345. progressive frames from a telecined stream. The filter does not drop duplicated
  3346. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  3347. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  3348. The separation of the field matching and the decimation is notably motivated by
  3349. the possibility of inserting a de-interlacing filter fallback between the two.
  3350. If the source has mixed telecined and real interlaced content,
  3351. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  3352. But these remaining combed frames will be marked as interlaced, and thus can be
  3353. de-interlaced by a later filter such as @ref{yadif} before decimation.
  3354. In addition to the various configuration options, @code{fieldmatch} can take an
  3355. optional second stream, activated through the @option{ppsrc} option. If
  3356. enabled, the frames reconstruction will be based on the fields and frames from
  3357. this second stream. This allows the first input to be pre-processed in order to
  3358. help the various algorithms of the filter, while keeping the output lossless
  3359. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  3360. or brightness/contrast adjustments can help.
  3361. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  3362. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  3363. which @code{fieldmatch} is based on. While the semantic and usage are very
  3364. close, some behaviour and options names can differ.
  3365. The filter accepts the following options:
  3366. @table @option
  3367. @item order
  3368. Specify the assumed field order of the input stream. Available values are:
  3369. @table @samp
  3370. @item auto
  3371. Auto detect parity (use FFmpeg's internal parity value).
  3372. @item bff
  3373. Assume bottom field first.
  3374. @item tff
  3375. Assume top field first.
  3376. @end table
  3377. Note that it is sometimes recommended not to trust the parity announced by the
  3378. stream.
  3379. Default value is @var{auto}.
  3380. @item mode
  3381. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  3382. sense that it won't risk creating jerkiness due to duplicate frames when
  3383. possible, but if there are bad edits or blended fields it will end up
  3384. outputting combed frames when a good match might actually exist. On the other
  3385. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  3386. but will almost always find a good frame if there is one. The other values are
  3387. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  3388. jerkiness and creating duplicate frames versus finding good matches in sections
  3389. with bad edits, orphaned fields, blended fields, etc.
  3390. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  3391. Available values are:
  3392. @table @samp
  3393. @item pc
  3394. 2-way matching (p/c)
  3395. @item pc_n
  3396. 2-way matching, and trying 3rd match if still combed (p/c + n)
  3397. @item pc_u
  3398. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  3399. @item pc_n_ub
  3400. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  3401. still combed (p/c + n + u/b)
  3402. @item pcn
  3403. 3-way matching (p/c/n)
  3404. @item pcn_ub
  3405. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  3406. detected as combed (p/c/n + u/b)
  3407. @end table
  3408. The parenthesis at the end indicate the matches that would be used for that
  3409. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  3410. @var{top}).
  3411. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  3412. the slowest.
  3413. Default value is @var{pc_n}.
  3414. @item ppsrc
  3415. Mark the main input stream as a pre-processed input, and enable the secondary
  3416. input stream as the clean source to pick the fields from. See the filter
  3417. introduction for more details. It is similar to the @option{clip2} feature from
  3418. VFM/TFM.
  3419. Default value is @code{0} (disabled).
  3420. @item field
  3421. Set the field to match from. It is recommended to set this to the same value as
  3422. @option{order} unless you experience matching failures with that setting. In
  3423. certain circumstances changing the field that is used to match from can have a
  3424. large impact on matching performance. Available values are:
  3425. @table @samp
  3426. @item auto
  3427. Automatic (same value as @option{order}).
  3428. @item bottom
  3429. Match from the bottom field.
  3430. @item top
  3431. Match from the top field.
  3432. @end table
  3433. Default value is @var{auto}.
  3434. @item mchroma
  3435. Set whether or not chroma is included during the match comparisons. In most
  3436. cases it is recommended to leave this enabled. You should set this to @code{0}
  3437. only if your clip has bad chroma problems such as heavy rainbowing or other
  3438. artifacts. Setting this to @code{0} could also be used to speed things up at
  3439. the cost of some accuracy.
  3440. Default value is @code{1}.
  3441. @item y0
  3442. @item y1
  3443. These define an exclusion band which excludes the lines between @option{y0} and
  3444. @option{y1} from being included in the field matching decision. An exclusion
  3445. band can be used to ignore subtitles, a logo, or other things that may
  3446. interfere with the matching. @option{y0} sets the starting scan line and
  3447. @option{y1} sets the ending line; all lines in between @option{y0} and
  3448. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  3449. @option{y0} and @option{y1} to the same value will disable the feature.
  3450. @option{y0} and @option{y1} defaults to @code{0}.
  3451. @item scthresh
  3452. Set the scene change detection threshold as a percentage of maximum change on
  3453. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  3454. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  3455. @option{scthresh} is @code{[0.0, 100.0]}.
  3456. Default value is @code{12.0}.
  3457. @item combmatch
  3458. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  3459. account the combed scores of matches when deciding what match to use as the
  3460. final match. Available values are:
  3461. @table @samp
  3462. @item none
  3463. No final matching based on combed scores.
  3464. @item sc
  3465. Combed scores are only used when a scene change is detected.
  3466. @item full
  3467. Use combed scores all the time.
  3468. @end table
  3469. Default is @var{sc}.
  3470. @item combdbg
  3471. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  3472. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  3473. Available values are:
  3474. @table @samp
  3475. @item none
  3476. No forced calculation.
  3477. @item pcn
  3478. Force p/c/n calculations.
  3479. @item pcnub
  3480. Force p/c/n/u/b calculations.
  3481. @end table
  3482. Default value is @var{none}.
  3483. @item cthresh
  3484. This is the area combing threshold used for combed frame detection. This
  3485. essentially controls how "strong" or "visible" combing must be to be detected.
  3486. Larger values mean combing must be more visible and smaller values mean combing
  3487. can be less visible or strong and still be detected. Valid settings are from
  3488. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3489. be detected as combed). This is basically a pixel difference value. A good
  3490. range is @code{[8, 12]}.
  3491. Default value is @code{9}.
  3492. @item chroma
  3493. Sets whether or not chroma is considered in the combed frame decision. Only
  3494. disable this if your source has chroma problems (rainbowing, etc.) that are
  3495. causing problems for the combed frame detection with chroma enabled. Actually,
  3496. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3497. where there is chroma only combing in the source.
  3498. Default value is @code{0}.
  3499. @item blockx
  3500. @item blocky
  3501. Respectively set the x-axis and y-axis size of the window used during combed
  3502. frame detection. This has to do with the size of the area in which
  3503. @option{combpel} pixels are required to be detected as combed for a frame to be
  3504. declared combed. See the @option{combpel} parameter description for more info.
  3505. Possible values are any number that is a power of 2 starting at 4 and going up
  3506. to 512.
  3507. Default value is @code{16}.
  3508. @item combpel
  3509. The number of combed pixels inside any of the @option{blocky} by
  3510. @option{blockx} size blocks on the frame for the frame to be detected as
  3511. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3512. setting controls "how much" combing there must be in any localized area (a
  3513. window defined by the @option{blockx} and @option{blocky} settings) on the
  3514. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3515. which point no frames will ever be detected as combed). This setting is known
  3516. as @option{MI} in TFM/VFM vocabulary.
  3517. Default value is @code{80}.
  3518. @end table
  3519. @anchor{p/c/n/u/b meaning}
  3520. @subsection p/c/n/u/b meaning
  3521. @subsubsection p/c/n
  3522. We assume the following telecined stream:
  3523. @example
  3524. Top fields: 1 2 2 3 4
  3525. Bottom fields: 1 2 3 4 4
  3526. @end example
  3527. The numbers correspond to the progressive frame the fields relate to. Here, the
  3528. first two frames are progressive, the 3rd and 4th are combed, and so on.
  3529. When @code{fieldmatch} is configured to run a matching from bottom
  3530. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  3531. @example
  3532. Input stream:
  3533. T 1 2 2 3 4
  3534. B 1 2 3 4 4 <-- matching reference
  3535. Matches: c c n n c
  3536. Output stream:
  3537. T 1 2 3 4 4
  3538. B 1 2 3 4 4
  3539. @end example
  3540. As a result of the field matching, we can see that some frames get duplicated.
  3541. To perform a complete inverse telecine, you need to rely on a decimation filter
  3542. after this operation. See for instance the @ref{decimate} filter.
  3543. The same operation now matching from top fields (@option{field}=@var{top})
  3544. looks like this:
  3545. @example
  3546. Input stream:
  3547. T 1 2 2 3 4 <-- matching reference
  3548. B 1 2 3 4 4
  3549. Matches: c c p p c
  3550. Output stream:
  3551. T 1 2 2 3 4
  3552. B 1 2 2 3 4
  3553. @end example
  3554. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  3555. basically, they refer to the frame and field of the opposite parity:
  3556. @itemize
  3557. @item @var{p} matches the field of the opposite parity in the previous frame
  3558. @item @var{c} matches the field of the opposite parity in the current frame
  3559. @item @var{n} matches the field of the opposite parity in the next frame
  3560. @end itemize
  3561. @subsubsection u/b
  3562. The @var{u} and @var{b} matching are a bit special in the sense that they match
  3563. from the opposite parity flag. In the following examples, we assume that we are
  3564. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  3565. 'x' is placed above and below each matched fields.
  3566. With bottom matching (@option{field}=@var{bottom}):
  3567. @example
  3568. Match: c p n b u
  3569. x x x x x
  3570. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3571. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3572. x x x x x
  3573. Output frames:
  3574. 2 1 2 2 2
  3575. 2 2 2 1 3
  3576. @end example
  3577. With top matching (@option{field}=@var{top}):
  3578. @example
  3579. Match: c p n b u
  3580. x x x x x
  3581. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3582. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3583. x x x x x
  3584. Output frames:
  3585. 2 2 2 1 2
  3586. 2 1 3 2 2
  3587. @end example
  3588. @subsection Examples
  3589. Simple IVTC of a top field first telecined stream:
  3590. @example
  3591. fieldmatch=order=tff:combmatch=none, decimate
  3592. @end example
  3593. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  3594. @example
  3595. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  3596. @end example
  3597. @section fieldorder
  3598. Transform the field order of the input video.
  3599. It accepts the following parameters:
  3600. @table @option
  3601. @item order
  3602. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  3603. for bottom field first.
  3604. @end table
  3605. The default value is @samp{tff}.
  3606. The transformation is done by shifting the picture content up or down
  3607. by one line, and filling the remaining line with appropriate picture content.
  3608. This method is consistent with most broadcast field order converters.
  3609. If the input video is not flagged as being interlaced, or it is already
  3610. flagged as being of the required output field order, then this filter does
  3611. not alter the incoming video.
  3612. It is very useful when converting to or from PAL DV material,
  3613. which is bottom field first.
  3614. For example:
  3615. @example
  3616. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  3617. @end example
  3618. @section fifo
  3619. Buffer input images and send them when they are requested.
  3620. It is mainly useful when auto-inserted by the libavfilter
  3621. framework.
  3622. It does not take parameters.
  3623. @anchor{format}
  3624. @section format
  3625. Convert the input video to one of the specified pixel formats.
  3626. Libavfilter will try to pick one that is suitable as input to
  3627. the next filter.
  3628. It accepts the following parameters:
  3629. @table @option
  3630. @item pix_fmts
  3631. A '|'-separated list of pixel format names, such as
  3632. "pix_fmts=yuv420p|monow|rgb24".
  3633. @end table
  3634. @subsection Examples
  3635. @itemize
  3636. @item
  3637. Convert the input video to the @var{yuv420p} format
  3638. @example
  3639. format=pix_fmts=yuv420p
  3640. @end example
  3641. Convert the input video to any of the formats in the list
  3642. @example
  3643. format=pix_fmts=yuv420p|yuv444p|yuv410p
  3644. @end example
  3645. @end itemize
  3646. @anchor{fps}
  3647. @section fps
  3648. Convert the video to specified constant frame rate by duplicating or dropping
  3649. frames as necessary.
  3650. It accepts the following parameters:
  3651. @table @option
  3652. @item fps
  3653. The desired output frame rate. The default is @code{25}.
  3654. @item round
  3655. Rounding method.
  3656. Possible values are:
  3657. @table @option
  3658. @item zero
  3659. zero round towards 0
  3660. @item inf
  3661. round away from 0
  3662. @item down
  3663. round towards -infinity
  3664. @item up
  3665. round towards +infinity
  3666. @item near
  3667. round to nearest
  3668. @end table
  3669. The default is @code{near}.
  3670. @item start_time
  3671. Assume the first PTS should be the given value, in seconds. This allows for
  3672. padding/trimming at the start of stream. By default, no assumption is made
  3673. about the first frame's expected PTS, so no padding or trimming is done.
  3674. For example, this could be set to 0 to pad the beginning with duplicates of
  3675. the first frame if a video stream starts after the audio stream or to trim any
  3676. frames with a negative PTS.
  3677. @end table
  3678. Alternatively, the options can be specified as a flat string:
  3679. @var{fps}[:@var{round}].
  3680. See also the @ref{setpts} filter.
  3681. @subsection Examples
  3682. @itemize
  3683. @item
  3684. A typical usage in order to set the fps to 25:
  3685. @example
  3686. fps=fps=25
  3687. @end example
  3688. @item
  3689. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  3690. @example
  3691. fps=fps=film:round=near
  3692. @end example
  3693. @end itemize
  3694. @section framepack
  3695. Pack two different video streams into a stereoscopic video, setting proper
  3696. metadata on supported codecs. The two views should have the same size and
  3697. framerate and processing will stop when the shorter video ends. Please note
  3698. that you may conveniently adjust view properties with the @ref{scale} and
  3699. @ref{fps} filters.
  3700. It accepts the following parameters:
  3701. @table @option
  3702. @item format
  3703. The desired packing format. Supported values are:
  3704. @table @option
  3705. @item sbs
  3706. The views are next to each other (default).
  3707. @item tab
  3708. The views are on top of each other.
  3709. @item lines
  3710. The views are packed by line.
  3711. @item columns
  3712. The views are packed by column.
  3713. @item frameseq
  3714. The views are temporally interleaved.
  3715. @end table
  3716. @end table
  3717. Some examples:
  3718. @example
  3719. # Convert left and right views into a frame-sequential video
  3720. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  3721. # Convert views into a side-by-side video with the same output resolution as the input
  3722. 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
  3723. @end example
  3724. @section framestep
  3725. Select one frame every N-th frame.
  3726. This filter accepts the following option:
  3727. @table @option
  3728. @item step
  3729. Select frame after every @code{step} frames.
  3730. Allowed values are positive integers higher than 0. Default value is @code{1}.
  3731. @end table
  3732. @anchor{frei0r}
  3733. @section frei0r
  3734. Apply a frei0r effect to the input video.
  3735. To enable the compilation of this filter, you need to install the frei0r
  3736. header and configure FFmpeg with @code{--enable-frei0r}.
  3737. It accepts the following parameters:
  3738. @table @option
  3739. @item filter_name
  3740. The name of the frei0r effect to load. If the environment variable
  3741. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  3742. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  3743. Otherwise, the standard frei0r paths are searched, in this order:
  3744. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  3745. @file{/usr/lib/frei0r-1/}.
  3746. @item filter_params
  3747. A '|'-separated list of parameters to pass to the frei0r effect.
  3748. @end table
  3749. A frei0r effect parameter can be a boolean (its value is either
  3750. "y" or "n"), a double, a color (specified as
  3751. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  3752. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  3753. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  3754. @var{X} and @var{Y} are floating point numbers) and/or a string.
  3755. The number and types of parameters depend on the loaded effect. If an
  3756. effect parameter is not specified, the default value is set.
  3757. @subsection Examples
  3758. @itemize
  3759. @item
  3760. Apply the distort0r effect, setting the first two double parameters:
  3761. @example
  3762. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  3763. @end example
  3764. @item
  3765. Apply the colordistance effect, taking a color as the first parameter:
  3766. @example
  3767. frei0r=colordistance:0.2/0.3/0.4
  3768. frei0r=colordistance:violet
  3769. frei0r=colordistance:0x112233
  3770. @end example
  3771. @item
  3772. Apply the perspective effect, specifying the top left and top right image
  3773. positions:
  3774. @example
  3775. frei0r=perspective:0.2/0.2|0.8/0.2
  3776. @end example
  3777. @end itemize
  3778. For more information, see
  3779. @url{http://frei0r.dyne.org}
  3780. @section geq
  3781. The filter accepts the following options:
  3782. @table @option
  3783. @item lum_expr, lum
  3784. Set the luminance expression.
  3785. @item cb_expr, cb
  3786. Set the chrominance blue expression.
  3787. @item cr_expr, cr
  3788. Set the chrominance red expression.
  3789. @item alpha_expr, a
  3790. Set the alpha expression.
  3791. @item red_expr, r
  3792. Set the red expression.
  3793. @item green_expr, g
  3794. Set the green expression.
  3795. @item blue_expr, b
  3796. Set the blue expression.
  3797. @end table
  3798. The colorspace is selected according to the specified options. If one
  3799. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  3800. options is specified, the filter will automatically select a YCbCr
  3801. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  3802. @option{blue_expr} options is specified, it will select an RGB
  3803. colorspace.
  3804. If one of the chrominance expression is not defined, it falls back on the other
  3805. one. If no alpha expression is specified it will evaluate to opaque value.
  3806. If none of chrominance expressions are specified, they will evaluate
  3807. to the luminance expression.
  3808. The expressions can use the following variables and functions:
  3809. @table @option
  3810. @item N
  3811. The sequential number of the filtered frame, starting from @code{0}.
  3812. @item X
  3813. @item Y
  3814. The coordinates of the current sample.
  3815. @item W
  3816. @item H
  3817. The width and height of the image.
  3818. @item SW
  3819. @item SH
  3820. Width and height scale depending on the currently filtered plane. It is the
  3821. ratio between the corresponding luma plane number of pixels and the current
  3822. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3823. @code{0.5,0.5} for chroma planes.
  3824. @item T
  3825. Time of the current frame, expressed in seconds.
  3826. @item p(x, y)
  3827. Return the value of the pixel at location (@var{x},@var{y}) of the current
  3828. plane.
  3829. @item lum(x, y)
  3830. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  3831. plane.
  3832. @item cb(x, y)
  3833. Return the value of the pixel at location (@var{x},@var{y}) of the
  3834. blue-difference chroma plane. Return 0 if there is no such plane.
  3835. @item cr(x, y)
  3836. Return the value of the pixel at location (@var{x},@var{y}) of the
  3837. red-difference chroma plane. Return 0 if there is no such plane.
  3838. @item r(x, y)
  3839. @item g(x, y)
  3840. @item b(x, y)
  3841. Return the value of the pixel at location (@var{x},@var{y}) of the
  3842. red/green/blue component. Return 0 if there is no such component.
  3843. @item alpha(x, y)
  3844. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  3845. plane. Return 0 if there is no such plane.
  3846. @end table
  3847. For functions, if @var{x} and @var{y} are outside the area, the value will be
  3848. automatically clipped to the closer edge.
  3849. @subsection Examples
  3850. @itemize
  3851. @item
  3852. Flip the image horizontally:
  3853. @example
  3854. geq=p(W-X\,Y)
  3855. @end example
  3856. @item
  3857. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  3858. wavelength of 100 pixels:
  3859. @example
  3860. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  3861. @end example
  3862. @item
  3863. Generate a fancy enigmatic moving light:
  3864. @example
  3865. 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
  3866. @end example
  3867. @item
  3868. Generate a quick emboss effect:
  3869. @example
  3870. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  3871. @end example
  3872. @item
  3873. Modify RGB components depending on pixel position:
  3874. @example
  3875. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  3876. @end example
  3877. @end itemize
  3878. @section gradfun
  3879. Fix the banding artifacts that are sometimes introduced into nearly flat
  3880. regions by truncation to 8bit color depth.
  3881. Interpolate the gradients that should go where the bands are, and
  3882. dither them.
  3883. It is designed for playback only. Do not use it prior to
  3884. lossy compression, because compression tends to lose the dither and
  3885. bring back the bands.
  3886. It accepts the following parameters:
  3887. @table @option
  3888. @item strength
  3889. The maximum amount by which the filter will change any one pixel. This is also
  3890. the threshold for detecting nearly flat regions. Acceptable values range from
  3891. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  3892. valid range.
  3893. @item radius
  3894. The neighborhood to fit the gradient to. A larger radius makes for smoother
  3895. gradients, but also prevents the filter from modifying the pixels near detailed
  3896. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  3897. values will be clipped to the valid range.
  3898. @end table
  3899. Alternatively, the options can be specified as a flat string:
  3900. @var{strength}[:@var{radius}]
  3901. @subsection Examples
  3902. @itemize
  3903. @item
  3904. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  3905. @example
  3906. gradfun=3.5:8
  3907. @end example
  3908. @item
  3909. Specify radius, omitting the strength (which will fall-back to the default
  3910. value):
  3911. @example
  3912. gradfun=radius=8
  3913. @end example
  3914. @end itemize
  3915. @anchor{haldclut}
  3916. @section haldclut
  3917. Apply a Hald CLUT to a video stream.
  3918. First input is the video stream to process, and second one is the Hald CLUT.
  3919. The Hald CLUT input can be a simple picture or a complete video stream.
  3920. The filter accepts the following options:
  3921. @table @option
  3922. @item shortest
  3923. Force termination when the shortest input terminates. Default is @code{0}.
  3924. @item repeatlast
  3925. Continue applying the last CLUT after the end of the stream. A value of
  3926. @code{0} disable the filter after the last frame of the CLUT is reached.
  3927. Default is @code{1}.
  3928. @end table
  3929. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  3930. filters share the same internals).
  3931. More information about the Hald CLUT can be found on Eskil Steenberg's website
  3932. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  3933. @subsection Workflow examples
  3934. @subsubsection Hald CLUT video stream
  3935. Generate an identity Hald CLUT stream altered with various effects:
  3936. @example
  3937. 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
  3938. @end example
  3939. Note: make sure you use a lossless codec.
  3940. Then use it with @code{haldclut} to apply it on some random stream:
  3941. @example
  3942. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  3943. @end example
  3944. The Hald CLUT will be applied to the 10 first seconds (duration of
  3945. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  3946. to the remaining frames of the @code{mandelbrot} stream.
  3947. @subsubsection Hald CLUT with preview
  3948. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  3949. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  3950. biggest possible square starting at the top left of the picture. The remaining
  3951. padding pixels (bottom or right) will be ignored. This area can be used to add
  3952. a preview of the Hald CLUT.
  3953. Typically, the following generated Hald CLUT will be supported by the
  3954. @code{haldclut} filter:
  3955. @example
  3956. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  3957. pad=iw+320 [padded_clut];
  3958. smptebars=s=320x256, split [a][b];
  3959. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  3960. [main][b] overlay=W-320" -frames:v 1 clut.png
  3961. @end example
  3962. It contains the original and a preview of the effect of the CLUT: SMPTE color
  3963. bars are displayed on the right-top, and below the same color bars processed by
  3964. the color changes.
  3965. Then, the effect of this Hald CLUT can be visualized with:
  3966. @example
  3967. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  3968. @end example
  3969. @section hflip
  3970. Flip the input video horizontally.
  3971. For example, to horizontally flip the input video with @command{ffmpeg}:
  3972. @example
  3973. ffmpeg -i in.avi -vf "hflip" out.avi
  3974. @end example
  3975. @section histeq
  3976. This filter applies a global color histogram equalization on a
  3977. per-frame basis.
  3978. It can be used to correct video that has a compressed range of pixel
  3979. intensities. The filter redistributes the pixel intensities to
  3980. equalize their distribution across the intensity range. It may be
  3981. viewed as an "automatically adjusting contrast filter". This filter is
  3982. useful only for correcting degraded or poorly captured source
  3983. video.
  3984. The filter accepts the following options:
  3985. @table @option
  3986. @item strength
  3987. Determine the amount of equalization to be applied. As the strength
  3988. is reduced, the distribution of pixel intensities more-and-more
  3989. approaches that of the input frame. The value must be a float number
  3990. in the range [0,1] and defaults to 0.200.
  3991. @item intensity
  3992. Set the maximum intensity that can generated and scale the output
  3993. values appropriately. The strength should be set as desired and then
  3994. the intensity can be limited if needed to avoid washing-out. The value
  3995. must be a float number in the range [0,1] and defaults to 0.210.
  3996. @item antibanding
  3997. Set the antibanding level. If enabled the filter will randomly vary
  3998. the luminance of output pixels by a small amount to avoid banding of
  3999. the histogram. Possible values are @code{none}, @code{weak} or
  4000. @code{strong}. It defaults to @code{none}.
  4001. @end table
  4002. @section histogram
  4003. Compute and draw a color distribution histogram for the input video.
  4004. The computed histogram is a representation of the color component
  4005. distribution in an image.
  4006. The filter accepts the following options:
  4007. @table @option
  4008. @item mode
  4009. Set histogram mode.
  4010. It accepts the following values:
  4011. @table @samp
  4012. @item levels
  4013. Standard histogram that displays the color components distribution in an
  4014. image. Displays color graph for each color component. Shows distribution of
  4015. the Y, U, V, A or R, G, B components, depending on input format, in the
  4016. current frame. Below each graph a color component scale meter is shown.
  4017. @item color
  4018. Displays chroma values (U/V color placement) in a two dimensional
  4019. graph (which is called a vectorscope). The brighter a pixel in the
  4020. vectorscope, the more pixels of the input frame correspond to that pixel
  4021. (i.e., more pixels have this chroma value). The V component is displayed on
  4022. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  4023. side being V = 255. The U component is displayed on the vertical (Y) axis,
  4024. with the top representing U = 0 and the bottom representing U = 255.
  4025. The position of a white pixel in the graph corresponds to the chroma value of
  4026. a pixel of the input clip. The graph can therefore be used to read the hue
  4027. (color flavor) and the saturation (the dominance of the hue in the color). As
  4028. the hue of a color changes, it moves around the square. At the center of the
  4029. square the saturation is zero, which means that the corresponding pixel has no
  4030. color. If the amount of a specific color is increased (while leaving the other
  4031. colors unchanged) the saturation increases, and the indicator moves towards
  4032. the edge of the square.
  4033. @item color2
  4034. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  4035. are displayed.
  4036. @item waveform
  4037. Per row/column color component graph. In row mode, the graph on the left side
  4038. represents color component value 0 and the right side represents value = 255.
  4039. In column mode, the top side represents color component value = 0 and bottom
  4040. side represents value = 255.
  4041. @end table
  4042. Default value is @code{levels}.
  4043. @item level_height
  4044. Set height of level in @code{levels}. Default value is @code{200}.
  4045. Allowed range is [50, 2048].
  4046. @item scale_height
  4047. Set height of color scale in @code{levels}. Default value is @code{12}.
  4048. Allowed range is [0, 40].
  4049. @item step
  4050. Set step for @code{waveform} mode. Smaller values are useful to find out how
  4051. many values of the same luminance are distributed across input rows/columns.
  4052. Default value is @code{10}. Allowed range is [1, 255].
  4053. @item waveform_mode
  4054. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  4055. Default is @code{row}.
  4056. @item waveform_mirror
  4057. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  4058. means mirrored. In mirrored mode, higher values will be represented on the left
  4059. side for @code{row} mode and at the top for @code{column} mode. Default is
  4060. @code{0} (unmirrored).
  4061. @item display_mode
  4062. Set display mode for @code{waveform} and @code{levels}.
  4063. It accepts the following values:
  4064. @table @samp
  4065. @item parade
  4066. Display separate graph for the color components side by side in
  4067. @code{row} waveform mode or one below the other in @code{column} waveform mode
  4068. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  4069. per color component graphs are placed below each other.
  4070. Using this display mode in @code{waveform} histogram mode makes it easy to
  4071. spot color casts in the highlights and shadows of an image, by comparing the
  4072. contours of the top and the bottom graphs of each waveform. Since whites,
  4073. grays, and blacks are characterized by exactly equal amounts of red, green,
  4074. and blue, neutral areas of the picture should display three waveforms of
  4075. roughly equal width/height. If not, the correction is easy to perform by
  4076. making level adjustments the three waveforms.
  4077. @item overlay
  4078. Presents information identical to that in the @code{parade}, except
  4079. that the graphs representing color components are superimposed directly
  4080. over one another.
  4081. This display mode in @code{waveform} histogram mode makes it easier to spot
  4082. relative differences or similarities in overlapping areas of the color
  4083. components that are supposed to be identical, such as neutral whites, grays,
  4084. or blacks.
  4085. @end table
  4086. Default is @code{parade}.
  4087. @item levels_mode
  4088. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  4089. Default is @code{linear}.
  4090. @end table
  4091. @subsection Examples
  4092. @itemize
  4093. @item
  4094. Calculate and draw histogram:
  4095. @example
  4096. ffplay -i input -vf histogram
  4097. @end example
  4098. @end itemize
  4099. @anchor{hqdn3d}
  4100. @section hqdn3d
  4101. This is a high precision/quality 3d denoise filter. It aims to reduce
  4102. image noise, producing smooth images and making still images really
  4103. still. It should enhance compressibility.
  4104. It accepts the following optional parameters:
  4105. @table @option
  4106. @item luma_spatial
  4107. A non-negative floating point number which specifies spatial luma strength.
  4108. It defaults to 4.0.
  4109. @item chroma_spatial
  4110. A non-negative floating point number which specifies spatial chroma strength.
  4111. It defaults to 3.0*@var{luma_spatial}/4.0.
  4112. @item luma_tmp
  4113. A floating point number which specifies luma temporal strength. It defaults to
  4114. 6.0*@var{luma_spatial}/4.0.
  4115. @item chroma_tmp
  4116. A floating point number which specifies chroma temporal strength. It defaults to
  4117. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  4118. @end table
  4119. @section hqx
  4120. Apply a high-quality magnification filter designed for pixel art. This filter
  4121. was originally created by Maxim Stepin.
  4122. It accepts the following option:
  4123. @table @option
  4124. @item n
  4125. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  4126. @code{hq3x} and @code{4} for @code{hq4x}.
  4127. Default is @code{3}.
  4128. @end table
  4129. @section hue
  4130. Modify the hue and/or the saturation of the input.
  4131. It accepts the following parameters:
  4132. @table @option
  4133. @item h
  4134. Specify the hue angle as a number of degrees. It accepts an expression,
  4135. and defaults to "0".
  4136. @item s
  4137. Specify the saturation in the [-10,10] range. It accepts an expression and
  4138. defaults to "1".
  4139. @item H
  4140. Specify the hue angle as a number of radians. It accepts an
  4141. expression, and defaults to "0".
  4142. @item b
  4143. Specify the brightness in the [-10,10] range. It accepts an expression and
  4144. defaults to "0".
  4145. @end table
  4146. @option{h} and @option{H} are mutually exclusive, and can't be
  4147. specified at the same time.
  4148. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  4149. expressions containing the following constants:
  4150. @table @option
  4151. @item n
  4152. frame count of the input frame starting from 0
  4153. @item pts
  4154. presentation timestamp of the input frame expressed in time base units
  4155. @item r
  4156. frame rate of the input video, NAN if the input frame rate is unknown
  4157. @item t
  4158. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4159. @item tb
  4160. time base of the input video
  4161. @end table
  4162. @subsection Examples
  4163. @itemize
  4164. @item
  4165. Set the hue to 90 degrees and the saturation to 1.0:
  4166. @example
  4167. hue=h=90:s=1
  4168. @end example
  4169. @item
  4170. Same command but expressing the hue in radians:
  4171. @example
  4172. hue=H=PI/2:s=1
  4173. @end example
  4174. @item
  4175. Rotate hue and make the saturation swing between 0
  4176. and 2 over a period of 1 second:
  4177. @example
  4178. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  4179. @end example
  4180. @item
  4181. Apply a 3 seconds saturation fade-in effect starting at 0:
  4182. @example
  4183. hue="s=min(t/3\,1)"
  4184. @end example
  4185. The general fade-in expression can be written as:
  4186. @example
  4187. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  4188. @end example
  4189. @item
  4190. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  4191. @example
  4192. hue="s=max(0\, min(1\, (8-t)/3))"
  4193. @end example
  4194. The general fade-out expression can be written as:
  4195. @example
  4196. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  4197. @end example
  4198. @end itemize
  4199. @subsection Commands
  4200. This filter supports the following commands:
  4201. @table @option
  4202. @item b
  4203. @item s
  4204. @item h
  4205. @item H
  4206. Modify the hue and/or the saturation and/or brightness of the input video.
  4207. The command accepts the same syntax of the corresponding option.
  4208. If the specified expression is not valid, it is kept at its current
  4209. value.
  4210. @end table
  4211. @section idet
  4212. Detect video interlacing type.
  4213. This filter tries to detect if the input is interlaced or progressive,
  4214. top or bottom field first.
  4215. The filter accepts the following options:
  4216. @table @option
  4217. @item intl_thres
  4218. Set interlacing threshold.
  4219. @item prog_thres
  4220. Set progressive threshold.
  4221. @end table
  4222. @section il
  4223. Deinterleave or interleave fields.
  4224. This filter allows one to process interlaced images fields without
  4225. deinterlacing them. Deinterleaving splits the input frame into 2
  4226. fields (so called half pictures). Odd lines are moved to the top
  4227. half of the output image, even lines to the bottom half.
  4228. You can process (filter) them independently and then re-interleave them.
  4229. The filter accepts the following options:
  4230. @table @option
  4231. @item luma_mode, l
  4232. @item chroma_mode, c
  4233. @item alpha_mode, a
  4234. Available values for @var{luma_mode}, @var{chroma_mode} and
  4235. @var{alpha_mode} are:
  4236. @table @samp
  4237. @item none
  4238. Do nothing.
  4239. @item deinterleave, d
  4240. Deinterleave fields, placing one above the other.
  4241. @item interleave, i
  4242. Interleave fields. Reverse the effect of deinterleaving.
  4243. @end table
  4244. Default value is @code{none}.
  4245. @item luma_swap, ls
  4246. @item chroma_swap, cs
  4247. @item alpha_swap, as
  4248. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  4249. @end table
  4250. @section interlace
  4251. Simple interlacing filter from progressive contents. This interleaves upper (or
  4252. lower) lines from odd frames with lower (or upper) lines from even frames,
  4253. halving the frame rate and preserving image height.
  4254. @example
  4255. Original Original New Frame
  4256. Frame 'j' Frame 'j+1' (tff)
  4257. ========== =========== ==================
  4258. Line 0 --------------------> Frame 'j' Line 0
  4259. Line 1 Line 1 ----> Frame 'j+1' Line 1
  4260. Line 2 ---------------------> Frame 'j' Line 2
  4261. Line 3 Line 3 ----> Frame 'j+1' Line 3
  4262. ... ... ...
  4263. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  4264. @end example
  4265. It accepts the following optional parameters:
  4266. @table @option
  4267. @item scan
  4268. This determines whether the interlaced frame is taken from the even
  4269. (tff - default) or odd (bff) lines of the progressive frame.
  4270. @item lowpass
  4271. Enable (default) or disable the vertical lowpass filter to avoid twitter
  4272. interlacing and reduce moire patterns.
  4273. @end table
  4274. @section kerndeint
  4275. Deinterlace input video by applying Donald Graft's adaptive kernel
  4276. deinterling. Work on interlaced parts of a video to produce
  4277. progressive frames.
  4278. The description of the accepted parameters follows.
  4279. @table @option
  4280. @item thresh
  4281. Set the threshold which affects the filter's tolerance when
  4282. determining if a pixel line must be processed. It must be an integer
  4283. in the range [0,255] and defaults to 10. A value of 0 will result in
  4284. applying the process on every pixels.
  4285. @item map
  4286. Paint pixels exceeding the threshold value to white if set to 1.
  4287. Default is 0.
  4288. @item order
  4289. Set the fields order. Swap fields if set to 1, leave fields alone if
  4290. 0. Default is 0.
  4291. @item sharp
  4292. Enable additional sharpening if set to 1. Default is 0.
  4293. @item twoway
  4294. Enable twoway sharpening if set to 1. Default is 0.
  4295. @end table
  4296. @subsection Examples
  4297. @itemize
  4298. @item
  4299. Apply default values:
  4300. @example
  4301. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  4302. @end example
  4303. @item
  4304. Enable additional sharpening:
  4305. @example
  4306. kerndeint=sharp=1
  4307. @end example
  4308. @item
  4309. Paint processed pixels in white:
  4310. @example
  4311. kerndeint=map=1
  4312. @end example
  4313. @end itemize
  4314. @section lenscorrection
  4315. Correct radial lens distortion
  4316. This filter can be used to correct for radial distortion as can result from the use
  4317. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  4318. one can use tools available for example as part of opencv or simply trial-and-error.
  4319. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  4320. and extract the k1 and k2 coefficients from the resulting matrix.
  4321. Note that effectively the same filter is available in the open-source tools Krita and
  4322. Digikam from the KDE project.
  4323. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  4324. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  4325. brightness distribution, so you may want to use both filters together in certain
  4326. cases, though you will have to take care of ordering, i.e. whether vignetting should
  4327. be applied before or after lens correction.
  4328. @subsection Options
  4329. The filter accepts the following options:
  4330. @table @option
  4331. @item cx
  4332. Relative x-coordinate of the focal point of the image, and thereby the center of the
  4333. distrortion. This value has a range [0,1] and is expressed as fractions of the image
  4334. width.
  4335. @item cy
  4336. Relative y-coordinate of the focal point of the image, and thereby the center of the
  4337. distrortion. This value has a range [0,1] and is expressed as fractions of the image
  4338. height.
  4339. @item k1
  4340. Coefficient of the quadratic correction term. 0.5 means no correction.
  4341. @item k2
  4342. Coefficient of the double quadratic correction term. 0.5 means no correction.
  4343. @end table
  4344. The formula that generates the correction is:
  4345. @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)
  4346. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  4347. distances from the focal point in the source and target images, respectively.
  4348. @anchor{lut3d}
  4349. @section lut3d
  4350. Apply a 3D LUT to an input video.
  4351. The filter accepts the following options:
  4352. @table @option
  4353. @item file
  4354. Set the 3D LUT file name.
  4355. Currently supported formats:
  4356. @table @samp
  4357. @item 3dl
  4358. AfterEffects
  4359. @item cube
  4360. Iridas
  4361. @item dat
  4362. DaVinci
  4363. @item m3d
  4364. Pandora
  4365. @end table
  4366. @item interp
  4367. Select interpolation mode.
  4368. Available values are:
  4369. @table @samp
  4370. @item nearest
  4371. Use values from the nearest defined point.
  4372. @item trilinear
  4373. Interpolate values using the 8 points defining a cube.
  4374. @item tetrahedral
  4375. Interpolate values using a tetrahedron.
  4376. @end table
  4377. @end table
  4378. @section lut, lutrgb, lutyuv
  4379. Compute a look-up table for binding each pixel component input value
  4380. to an output value, and apply it to the input video.
  4381. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  4382. to an RGB input video.
  4383. These filters accept the following parameters:
  4384. @table @option
  4385. @item c0
  4386. set first pixel component expression
  4387. @item c1
  4388. set second pixel component expression
  4389. @item c2
  4390. set third pixel component expression
  4391. @item c3
  4392. set fourth pixel component expression, corresponds to the alpha component
  4393. @item r
  4394. set red component expression
  4395. @item g
  4396. set green component expression
  4397. @item b
  4398. set blue component expression
  4399. @item a
  4400. alpha component expression
  4401. @item y
  4402. set Y/luminance component expression
  4403. @item u
  4404. set U/Cb component expression
  4405. @item v
  4406. set V/Cr component expression
  4407. @end table
  4408. Each of them specifies the expression to use for computing the lookup table for
  4409. the corresponding pixel component values.
  4410. The exact component associated to each of the @var{c*} options depends on the
  4411. format in input.
  4412. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  4413. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  4414. The expressions can contain the following constants and functions:
  4415. @table @option
  4416. @item w
  4417. @item h
  4418. The input width and height.
  4419. @item val
  4420. The input value for the pixel component.
  4421. @item clipval
  4422. The input value, clipped to the @var{minval}-@var{maxval} range.
  4423. @item maxval
  4424. The maximum value for the pixel component.
  4425. @item minval
  4426. The minimum value for the pixel component.
  4427. @item negval
  4428. The negated value for the pixel component value, clipped to the
  4429. @var{minval}-@var{maxval} range; it corresponds to the expression
  4430. "maxval-clipval+minval".
  4431. @item clip(val)
  4432. The computed value in @var{val}, clipped to the
  4433. @var{minval}-@var{maxval} range.
  4434. @item gammaval(gamma)
  4435. The computed gamma correction value of the pixel component value,
  4436. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  4437. expression
  4438. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  4439. @end table
  4440. All expressions default to "val".
  4441. @subsection Examples
  4442. @itemize
  4443. @item
  4444. Negate input video:
  4445. @example
  4446. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  4447. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  4448. @end example
  4449. The above is the same as:
  4450. @example
  4451. lutrgb="r=negval:g=negval:b=negval"
  4452. lutyuv="y=negval:u=negval:v=negval"
  4453. @end example
  4454. @item
  4455. Negate luminance:
  4456. @example
  4457. lutyuv=y=negval
  4458. @end example
  4459. @item
  4460. Remove chroma components, turning the video into a graytone image:
  4461. @example
  4462. lutyuv="u=128:v=128"
  4463. @end example
  4464. @item
  4465. Apply a luma burning effect:
  4466. @example
  4467. lutyuv="y=2*val"
  4468. @end example
  4469. @item
  4470. Remove green and blue components:
  4471. @example
  4472. lutrgb="g=0:b=0"
  4473. @end example
  4474. @item
  4475. Set a constant alpha channel value on input:
  4476. @example
  4477. format=rgba,lutrgb=a="maxval-minval/2"
  4478. @end example
  4479. @item
  4480. Correct luminance gamma by a factor of 0.5:
  4481. @example
  4482. lutyuv=y=gammaval(0.5)
  4483. @end example
  4484. @item
  4485. Discard least significant bits of luma:
  4486. @example
  4487. lutyuv=y='bitand(val, 128+64+32)'
  4488. @end example
  4489. @end itemize
  4490. @section mergeplanes
  4491. Merge color channel components from several video streams.
  4492. The filter accepts up to 4 input streams, and merge selected input
  4493. planes to the output video.
  4494. This filter accepts the following options:
  4495. @table @option
  4496. @item mapping
  4497. Set input to output plane mapping. Default is @code{0}.
  4498. The mappings is specified as a bitmap. It should be specified as a
  4499. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  4500. mapping for the first plane of the output stream. 'A' sets the number of
  4501. the input stream to use (from 0 to 3), and 'a' the plane number of the
  4502. corresponding input to use (from 0 to 3). The rest of the mappings is
  4503. similar, 'Bb' describes the mapping for the output stream second
  4504. plane, 'Cc' describes the mapping for the output stream third plane and
  4505. 'Dd' describes the mapping for the output stream fourth plane.
  4506. @item format
  4507. Set output pixel format. Default is @code{yuva444p}.
  4508. @end table
  4509. @subsection Examples
  4510. @itemize
  4511. @item
  4512. Merge three gray video streams of same width and height into single video stream:
  4513. @example
  4514. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  4515. @end example
  4516. @item
  4517. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  4518. @example
  4519. [a0][a1]mergeplanes=0x00010210:yuva444p
  4520. @end example
  4521. @item
  4522. Swap Y and A plane in yuva444p stream:
  4523. @example
  4524. format=yuva444p,mergeplanes=0x03010200:yuva444p
  4525. @end example
  4526. @item
  4527. Swap U and V plane in yuv420p stream:
  4528. @example
  4529. format=yuv420p,mergeplanes=0x000201:yuv420p
  4530. @end example
  4531. @item
  4532. Cast a rgb24 clip to yuv444p:
  4533. @example
  4534. format=rgb24,mergeplanes=0x000102:yuv444p
  4535. @end example
  4536. @end itemize
  4537. @section mcdeint
  4538. Apply motion-compensation deinterlacing.
  4539. It needs one field per frame as input and must thus be used together
  4540. with yadif=1/3 or equivalent.
  4541. This filter accepts the following options:
  4542. @table @option
  4543. @item mode
  4544. Set the deinterlacing mode.
  4545. It accepts one of the following values:
  4546. @table @samp
  4547. @item fast
  4548. @item medium
  4549. @item slow
  4550. use iterative motion estimation
  4551. @item extra_slow
  4552. like @samp{slow}, but use multiple reference frames.
  4553. @end table
  4554. Default value is @samp{fast}.
  4555. @item parity
  4556. Set the picture field parity assumed for the input video. It must be
  4557. one of the following values:
  4558. @table @samp
  4559. @item 0, tff
  4560. assume top field first
  4561. @item 1, bff
  4562. assume bottom field first
  4563. @end table
  4564. Default value is @samp{bff}.
  4565. @item qp
  4566. Set per-block quantization parameter (QP) used by the internal
  4567. encoder.
  4568. Higher values should result in a smoother motion vector field but less
  4569. optimal individual vectors. Default value is 1.
  4570. @end table
  4571. @section mp
  4572. Apply an MPlayer filter to the input video.
  4573. This filter provides a wrapper around some of the filters of
  4574. MPlayer/MEncoder.
  4575. This wrapper is considered experimental. Some of the wrapped filters
  4576. may not work properly and we may drop support for them, as they will
  4577. be implemented natively into FFmpeg. Thus you should avoid
  4578. depending on them when writing portable scripts.
  4579. The filter accepts the parameters:
  4580. @var{filter_name}[:=]@var{filter_params}
  4581. @var{filter_name} is the name of a supported MPlayer filter,
  4582. @var{filter_params} is a string containing the parameters accepted by
  4583. the named filter.
  4584. The list of the currently supported filters follows:
  4585. @table @var
  4586. @item eq2
  4587. @item eq
  4588. @item fspp
  4589. @item ilpack
  4590. @item pp7
  4591. @item softpulldown
  4592. @item uspp
  4593. @end table
  4594. The parameter syntax and behavior for the listed filters are the same
  4595. of the corresponding MPlayer filters. For detailed instructions check
  4596. the "VIDEO FILTERS" section in the MPlayer manual.
  4597. @subsection Examples
  4598. @itemize
  4599. @item
  4600. Adjust gamma, brightness, contrast:
  4601. @example
  4602. mp=eq2=1.0:2:0.5
  4603. @end example
  4604. @end itemize
  4605. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  4606. @section mpdecimate
  4607. Drop frames that do not differ greatly from the previous frame in
  4608. order to reduce frame rate.
  4609. The main use of this filter is for very-low-bitrate encoding
  4610. (e.g. streaming over dialup modem), but it could in theory be used for
  4611. fixing movies that were inverse-telecined incorrectly.
  4612. A description of the accepted options follows.
  4613. @table @option
  4614. @item max
  4615. Set the maximum number of consecutive frames which can be dropped (if
  4616. positive), or the minimum interval between dropped frames (if
  4617. negative). If the value is 0, the frame is dropped unregarding the
  4618. number of previous sequentially dropped frames.
  4619. Default value is 0.
  4620. @item hi
  4621. @item lo
  4622. @item frac
  4623. Set the dropping threshold values.
  4624. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  4625. represent actual pixel value differences, so a threshold of 64
  4626. corresponds to 1 unit of difference for each pixel, or the same spread
  4627. out differently over the block.
  4628. A frame is a candidate for dropping if no 8x8 blocks differ by more
  4629. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  4630. meaning the whole image) differ by more than a threshold of @option{lo}.
  4631. Default value for @option{hi} is 64*12, default value for @option{lo} is
  4632. 64*5, and default value for @option{frac} is 0.33.
  4633. @end table
  4634. @section negate
  4635. Negate input video.
  4636. It accepts an integer in input; if non-zero it negates the
  4637. alpha component (if available). The default value in input is 0.
  4638. @section noformat
  4639. Force libavfilter not to use any of the specified pixel formats for the
  4640. input to the next filter.
  4641. It accepts the following parameters:
  4642. @table @option
  4643. @item pix_fmts
  4644. A '|'-separated list of pixel format names, such as
  4645. apix_fmts=yuv420p|monow|rgb24".
  4646. @end table
  4647. @subsection Examples
  4648. @itemize
  4649. @item
  4650. Force libavfilter to use a format different from @var{yuv420p} for the
  4651. input to the vflip filter:
  4652. @example
  4653. noformat=pix_fmts=yuv420p,vflip
  4654. @end example
  4655. @item
  4656. Convert the input video to any of the formats not contained in the list:
  4657. @example
  4658. noformat=yuv420p|yuv444p|yuv410p
  4659. @end example
  4660. @end itemize
  4661. @section noise
  4662. Add noise on video input frame.
  4663. The filter accepts the following options:
  4664. @table @option
  4665. @item all_seed
  4666. @item c0_seed
  4667. @item c1_seed
  4668. @item c2_seed
  4669. @item c3_seed
  4670. Set noise seed for specific pixel component or all pixel components in case
  4671. of @var{all_seed}. Default value is @code{123457}.
  4672. @item all_strength, alls
  4673. @item c0_strength, c0s
  4674. @item c1_strength, c1s
  4675. @item c2_strength, c2s
  4676. @item c3_strength, c3s
  4677. Set noise strength for specific pixel component or all pixel components in case
  4678. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  4679. @item all_flags, allf
  4680. @item c0_flags, c0f
  4681. @item c1_flags, c1f
  4682. @item c2_flags, c2f
  4683. @item c3_flags, c3f
  4684. Set pixel component flags or set flags for all components if @var{all_flags}.
  4685. Available values for component flags are:
  4686. @table @samp
  4687. @item a
  4688. averaged temporal noise (smoother)
  4689. @item p
  4690. mix random noise with a (semi)regular pattern
  4691. @item t
  4692. temporal noise (noise pattern changes between frames)
  4693. @item u
  4694. uniform noise (gaussian otherwise)
  4695. @end table
  4696. @end table
  4697. @subsection Examples
  4698. Add temporal and uniform noise to input video:
  4699. @example
  4700. noise=alls=20:allf=t+u
  4701. @end example
  4702. @section null
  4703. Pass the video source unchanged to the output.
  4704. @section ocv
  4705. Apply a video transform using libopencv.
  4706. To enable this filter, install the libopencv library and headers and
  4707. configure FFmpeg with @code{--enable-libopencv}.
  4708. It accepts the following parameters:
  4709. @table @option
  4710. @item filter_name
  4711. The name of the libopencv filter to apply.
  4712. @item filter_params
  4713. The parameters to pass to the libopencv filter. If not specified, the default
  4714. values are assumed.
  4715. @end table
  4716. Refer to the official libopencv documentation for more precise
  4717. information:
  4718. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  4719. Several libopencv filters are supported; see the following subsections.
  4720. @anchor{dilate}
  4721. @subsection dilate
  4722. Dilate an image by using a specific structuring element.
  4723. It corresponds to the libopencv function @code{cvDilate}.
  4724. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  4725. @var{struct_el} represents a structuring element, and has the syntax:
  4726. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  4727. @var{cols} and @var{rows} represent the number of columns and rows of
  4728. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  4729. point, and @var{shape} the shape for the structuring element. @var{shape}
  4730. must be "rect", "cross", "ellipse", or "custom".
  4731. If the value for @var{shape} is "custom", it must be followed by a
  4732. string of the form "=@var{filename}". The file with name
  4733. @var{filename} is assumed to represent a binary image, with each
  4734. printable character corresponding to a bright pixel. When a custom
  4735. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  4736. or columns and rows of the read file are assumed instead.
  4737. The default value for @var{struct_el} is "3x3+0x0/rect".
  4738. @var{nb_iterations} specifies the number of times the transform is
  4739. applied to the image, and defaults to 1.
  4740. Some examples:
  4741. @example
  4742. # Use the default values
  4743. ocv=dilate
  4744. # Dilate using a structuring element with a 5x5 cross, iterating two times
  4745. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  4746. # Read the shape from the file diamond.shape, iterating two times.
  4747. # The file diamond.shape may contain a pattern of characters like this
  4748. # *
  4749. # ***
  4750. # *****
  4751. # ***
  4752. # *
  4753. # The specified columns and rows are ignored
  4754. # but the anchor point coordinates are not
  4755. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  4756. @end example
  4757. @subsection erode
  4758. Erode an image by using a specific structuring element.
  4759. It corresponds to the libopencv function @code{cvErode}.
  4760. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  4761. with the same syntax and semantics as the @ref{dilate} filter.
  4762. @subsection smooth
  4763. Smooth the input video.
  4764. The filter takes the following parameters:
  4765. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  4766. @var{type} is the type of smooth filter to apply, and must be one of
  4767. the following values: "blur", "blur_no_scale", "median", "gaussian",
  4768. or "bilateral". The default value is "gaussian".
  4769. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  4770. depend on the smooth type. @var{param1} and
  4771. @var{param2} accept integer positive values or 0. @var{param3} and
  4772. @var{param4} accept floating point values.
  4773. The default value for @var{param1} is 3. The default value for the
  4774. other parameters is 0.
  4775. These parameters correspond to the parameters assigned to the
  4776. libopencv function @code{cvSmooth}.
  4777. @anchor{overlay}
  4778. @section overlay
  4779. Overlay one video on top of another.
  4780. It takes two inputs and has one output. The first input is the "main"
  4781. video on which the second input is overlayed.
  4782. It accepts the following parameters:
  4783. A description of the accepted options follows.
  4784. @table @option
  4785. @item x
  4786. @item y
  4787. Set the expression for the x and y coordinates of the overlayed video
  4788. on the main video. Default value is "0" for both expressions. In case
  4789. the expression is invalid, it is set to a huge value (meaning that the
  4790. overlay will not be displayed within the output visible area).
  4791. @item eof_action
  4792. The action to take when EOF is encountered on the secondary input; it accepts
  4793. one of the following values:
  4794. @table @option
  4795. @item repeat
  4796. Repeat the last frame (the default).
  4797. @item endall
  4798. End both streams.
  4799. @item pass
  4800. Pass the main input through.
  4801. @end table
  4802. @item eval
  4803. Set when the expressions for @option{x}, and @option{y} are evaluated.
  4804. It accepts the following values:
  4805. @table @samp
  4806. @item init
  4807. only evaluate expressions once during the filter initialization or
  4808. when a command is processed
  4809. @item frame
  4810. evaluate expressions for each incoming frame
  4811. @end table
  4812. Default value is @samp{frame}.
  4813. @item shortest
  4814. If set to 1, force the output to terminate when the shortest input
  4815. terminates. Default value is 0.
  4816. @item format
  4817. Set the format for the output video.
  4818. It accepts the following values:
  4819. @table @samp
  4820. @item yuv420
  4821. force YUV420 output
  4822. @item yuv422
  4823. force YUV422 output
  4824. @item yuv444
  4825. force YUV444 output
  4826. @item rgb
  4827. force RGB output
  4828. @end table
  4829. Default value is @samp{yuv420}.
  4830. @item rgb @emph{(deprecated)}
  4831. If set to 1, force the filter to accept inputs in the RGB
  4832. color space. Default value is 0. This option is deprecated, use
  4833. @option{format} instead.
  4834. @item repeatlast
  4835. If set to 1, force the filter to draw the last overlay frame over the
  4836. main input until the end of the stream. A value of 0 disables this
  4837. behavior. Default value is 1.
  4838. @end table
  4839. The @option{x}, and @option{y} expressions can contain the following
  4840. parameters.
  4841. @table @option
  4842. @item main_w, W
  4843. @item main_h, H
  4844. The main input width and height.
  4845. @item overlay_w, w
  4846. @item overlay_h, h
  4847. The overlay input width and height.
  4848. @item x
  4849. @item y
  4850. The computed values for @var{x} and @var{y}. They are evaluated for
  4851. each new frame.
  4852. @item hsub
  4853. @item vsub
  4854. horizontal and vertical chroma subsample values of the output
  4855. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  4856. @var{vsub} is 1.
  4857. @item n
  4858. the number of input frame, starting from 0
  4859. @item pos
  4860. the position in the file of the input frame, NAN if unknown
  4861. @item t
  4862. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  4863. @end table
  4864. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  4865. when evaluation is done @emph{per frame}, and will evaluate to NAN
  4866. when @option{eval} is set to @samp{init}.
  4867. Be aware that frames are taken from each input video in timestamp
  4868. order, hence, if their initial timestamps differ, it is a good idea
  4869. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  4870. have them begin in the same zero timestamp, as the example for
  4871. the @var{movie} filter does.
  4872. You can chain together more overlays but you should test the
  4873. efficiency of such approach.
  4874. @subsection Commands
  4875. This filter supports the following commands:
  4876. @table @option
  4877. @item x
  4878. @item y
  4879. Modify the x and y of the overlay input.
  4880. The command accepts the same syntax of the corresponding option.
  4881. If the specified expression is not valid, it is kept at its current
  4882. value.
  4883. @end table
  4884. @subsection Examples
  4885. @itemize
  4886. @item
  4887. Draw the overlay at 10 pixels from the bottom right corner of the main
  4888. video:
  4889. @example
  4890. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  4891. @end example
  4892. Using named options the example above becomes:
  4893. @example
  4894. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  4895. @end example
  4896. @item
  4897. Insert a transparent PNG logo in the bottom left corner of the input,
  4898. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  4899. @example
  4900. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  4901. @end example
  4902. @item
  4903. Insert 2 different transparent PNG logos (second logo on bottom
  4904. right corner) using the @command{ffmpeg} tool:
  4905. @example
  4906. 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
  4907. @end example
  4908. @item
  4909. Add a transparent color layer on top of the main video; @code{WxH}
  4910. must specify the size of the main input to the overlay filter:
  4911. @example
  4912. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  4913. @end example
  4914. @item
  4915. Play an original video and a filtered version (here with the deshake
  4916. filter) side by side using the @command{ffplay} tool:
  4917. @example
  4918. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  4919. @end example
  4920. The above command is the same as:
  4921. @example
  4922. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  4923. @end example
  4924. @item
  4925. Make a sliding overlay appearing from the left to the right top part of the
  4926. screen starting since time 2:
  4927. @example
  4928. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  4929. @end example
  4930. @item
  4931. Compose output by putting two input videos side to side:
  4932. @example
  4933. ffmpeg -i left.avi -i right.avi -filter_complex "
  4934. nullsrc=size=200x100 [background];
  4935. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  4936. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  4937. [background][left] overlay=shortest=1 [background+left];
  4938. [background+left][right] overlay=shortest=1:x=100 [left+right]
  4939. "
  4940. @end example
  4941. @item
  4942. Mask 10-20 seconds of a video by applying the delogo filter to a section
  4943. @example
  4944. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  4945. -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]'
  4946. masked.avi
  4947. @end example
  4948. @item
  4949. Chain several overlays in cascade:
  4950. @example
  4951. nullsrc=s=200x200 [bg];
  4952. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  4953. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  4954. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  4955. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  4956. [in3] null, [mid2] overlay=100:100 [out0]
  4957. @end example
  4958. @end itemize
  4959. @section owdenoise
  4960. Apply Overcomplete Wavelet denoiser.
  4961. The filter accepts the following options:
  4962. @table @option
  4963. @item depth
  4964. Set depth.
  4965. Larger depth values will denoise lower frequency components more, but
  4966. slow down filtering.
  4967. Must be an int in the range 8-16, default is @code{8}.
  4968. @item luma_strength, ls
  4969. Set luma strength.
  4970. Must be a double value in the range 0-1000, default is @code{1.0}.
  4971. @item chroma_strength, cs
  4972. Set chroma strength.
  4973. Must be a double value in the range 0-1000, default is @code{1.0}.
  4974. @end table
  4975. @section pad
  4976. Add paddings to the input image, and place the original input at the
  4977. provided @var{x}, @var{y} coordinates.
  4978. It accepts the following parameters:
  4979. @table @option
  4980. @item width, w
  4981. @item height, h
  4982. Specify an expression for the size of the output image with the
  4983. paddings added. If the value for @var{width} or @var{height} is 0, the
  4984. corresponding input size is used for the output.
  4985. The @var{width} expression can reference the value set by the
  4986. @var{height} expression, and vice versa.
  4987. The default value of @var{width} and @var{height} is 0.
  4988. @item x
  4989. @item y
  4990. Specify the offsets to place the input image at within the padded area,
  4991. with respect to the top/left border of the output image.
  4992. The @var{x} expression can reference the value set by the @var{y}
  4993. expression, and vice versa.
  4994. The default value of @var{x} and @var{y} is 0.
  4995. @item color
  4996. Specify the color of the padded area. For the syntax of this option,
  4997. check the "Color" section in the ffmpeg-utils manual.
  4998. The default value of @var{color} is "black".
  4999. @end table
  5000. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  5001. options are expressions containing the following constants:
  5002. @table @option
  5003. @item in_w
  5004. @item in_h
  5005. The input video width and height.
  5006. @item iw
  5007. @item ih
  5008. These are the same as @var{in_w} and @var{in_h}.
  5009. @item out_w
  5010. @item out_h
  5011. The output width and height (the size of the padded area), as
  5012. specified by the @var{width} and @var{height} expressions.
  5013. @item ow
  5014. @item oh
  5015. These are the same as @var{out_w} and @var{out_h}.
  5016. @item x
  5017. @item y
  5018. The x and y offsets as specified by the @var{x} and @var{y}
  5019. expressions, or NAN if not yet specified.
  5020. @item a
  5021. same as @var{iw} / @var{ih}
  5022. @item sar
  5023. input sample aspect ratio
  5024. @item dar
  5025. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  5026. @item hsub
  5027. @item vsub
  5028. The horizontal and vertical chroma subsample values. For example for the
  5029. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5030. @end table
  5031. @subsection Examples
  5032. @itemize
  5033. @item
  5034. Add paddings with the color "violet" to the input video. The output video
  5035. size is 640x480, and the top-left corner of the input video is placed at
  5036. column 0, row 40
  5037. @example
  5038. pad=640:480:0:40:violet
  5039. @end example
  5040. The example above is equivalent to the following command:
  5041. @example
  5042. pad=width=640:height=480:x=0:y=40:color=violet
  5043. @end example
  5044. @item
  5045. Pad the input to get an output with dimensions increased by 3/2,
  5046. and put the input video at the center of the padded area:
  5047. @example
  5048. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  5049. @end example
  5050. @item
  5051. Pad the input to get a squared output with size equal to the maximum
  5052. value between the input width and height, and put the input video at
  5053. the center of the padded area:
  5054. @example
  5055. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  5056. @end example
  5057. @item
  5058. Pad the input to get a final w/h ratio of 16:9:
  5059. @example
  5060. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  5061. @end example
  5062. @item
  5063. In case of anamorphic video, in order to set the output display aspect
  5064. correctly, it is necessary to use @var{sar} in the expression,
  5065. according to the relation:
  5066. @example
  5067. (ih * X / ih) * sar = output_dar
  5068. X = output_dar / sar
  5069. @end example
  5070. Thus the previous example needs to be modified to:
  5071. @example
  5072. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  5073. @end example
  5074. @item
  5075. Double the output size and put the input video in the bottom-right
  5076. corner of the output padded area:
  5077. @example
  5078. pad="2*iw:2*ih:ow-iw:oh-ih"
  5079. @end example
  5080. @end itemize
  5081. @section perspective
  5082. Correct perspective of video not recorded perpendicular to the screen.
  5083. A description of the accepted parameters follows.
  5084. @table @option
  5085. @item x0
  5086. @item y0
  5087. @item x1
  5088. @item y1
  5089. @item x2
  5090. @item y2
  5091. @item x3
  5092. @item y3
  5093. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  5094. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  5095. The expressions can use the following variables:
  5096. @table @option
  5097. @item W
  5098. @item H
  5099. the width and height of video frame.
  5100. @end table
  5101. @item interpolation
  5102. Set interpolation for perspective correction.
  5103. It accepts the following values:
  5104. @table @samp
  5105. @item linear
  5106. @item cubic
  5107. @end table
  5108. Default value is @samp{linear}.
  5109. @end table
  5110. @section phase
  5111. Delay interlaced video by one field time so that the field order changes.
  5112. The intended use is to fix PAL movies that have been captured with the
  5113. opposite field order to the film-to-video transfer.
  5114. A description of the accepted parameters follows.
  5115. @table @option
  5116. @item mode
  5117. Set phase mode.
  5118. It accepts the following values:
  5119. @table @samp
  5120. @item t
  5121. Capture field order top-first, transfer bottom-first.
  5122. Filter will delay the bottom field.
  5123. @item b
  5124. Capture field order bottom-first, transfer top-first.
  5125. Filter will delay the top field.
  5126. @item p
  5127. Capture and transfer with the same field order. This mode only exists
  5128. for the documentation of the other options to refer to, but if you
  5129. actually select it, the filter will faithfully do nothing.
  5130. @item a
  5131. Capture field order determined automatically by field flags, transfer
  5132. opposite.
  5133. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  5134. basis using field flags. If no field information is available,
  5135. then this works just like @samp{u}.
  5136. @item u
  5137. Capture unknown or varying, transfer opposite.
  5138. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  5139. analyzing the images and selecting the alternative that produces best
  5140. match between the fields.
  5141. @item T
  5142. Capture top-first, transfer unknown or varying.
  5143. Filter selects among @samp{t} and @samp{p} using image analysis.
  5144. @item B
  5145. Capture bottom-first, transfer unknown or varying.
  5146. Filter selects among @samp{b} and @samp{p} using image analysis.
  5147. @item A
  5148. Capture determined by field flags, transfer unknown or varying.
  5149. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  5150. image analysis. If no field information is available, then this works just
  5151. like @samp{U}. This is the default mode.
  5152. @item U
  5153. Both capture and transfer unknown or varying.
  5154. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  5155. @end table
  5156. @end table
  5157. @section pixdesctest
  5158. Pixel format descriptor test filter, mainly useful for internal
  5159. testing. The output video should be equal to the input video.
  5160. For example:
  5161. @example
  5162. format=monow, pixdesctest
  5163. @end example
  5164. can be used to test the monowhite pixel format descriptor definition.
  5165. @section pp
  5166. Enable the specified chain of postprocessing subfilters using libpostproc. This
  5167. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  5168. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  5169. Each subfilter and some options have a short and a long name that can be used
  5170. interchangeably, i.e. dr/dering are the same.
  5171. The filters accept the following options:
  5172. @table @option
  5173. @item subfilters
  5174. Set postprocessing subfilters string.
  5175. @end table
  5176. All subfilters share common options to determine their scope:
  5177. @table @option
  5178. @item a/autoq
  5179. Honor the quality commands for this subfilter.
  5180. @item c/chrom
  5181. Do chrominance filtering, too (default).
  5182. @item y/nochrom
  5183. Do luminance filtering only (no chrominance).
  5184. @item n/noluma
  5185. Do chrominance filtering only (no luminance).
  5186. @end table
  5187. These options can be appended after the subfilter name, separated by a '|'.
  5188. Available subfilters are:
  5189. @table @option
  5190. @item hb/hdeblock[|difference[|flatness]]
  5191. Horizontal deblocking filter
  5192. @table @option
  5193. @item difference
  5194. Difference factor where higher values mean more deblocking (default: @code{32}).
  5195. @item flatness
  5196. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5197. @end table
  5198. @item vb/vdeblock[|difference[|flatness]]
  5199. Vertical deblocking filter
  5200. @table @option
  5201. @item difference
  5202. Difference factor where higher values mean more deblocking (default: @code{32}).
  5203. @item flatness
  5204. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5205. @end table
  5206. @item ha/hadeblock[|difference[|flatness]]
  5207. Accurate horizontal deblocking filter
  5208. @table @option
  5209. @item difference
  5210. Difference factor where higher values mean more deblocking (default: @code{32}).
  5211. @item flatness
  5212. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5213. @end table
  5214. @item va/vadeblock[|difference[|flatness]]
  5215. Accurate vertical deblocking filter
  5216. @table @option
  5217. @item difference
  5218. Difference factor where higher values mean more deblocking (default: @code{32}).
  5219. @item flatness
  5220. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5221. @end table
  5222. @end table
  5223. The horizontal and vertical deblocking filters share the difference and
  5224. flatness values so you cannot set different horizontal and vertical
  5225. thresholds.
  5226. @table @option
  5227. @item h1/x1hdeblock
  5228. Experimental horizontal deblocking filter
  5229. @item v1/x1vdeblock
  5230. Experimental vertical deblocking filter
  5231. @item dr/dering
  5232. Deringing filter
  5233. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  5234. @table @option
  5235. @item threshold1
  5236. larger -> stronger filtering
  5237. @item threshold2
  5238. larger -> stronger filtering
  5239. @item threshold3
  5240. larger -> stronger filtering
  5241. @end table
  5242. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  5243. @table @option
  5244. @item f/fullyrange
  5245. Stretch luminance to @code{0-255}.
  5246. @end table
  5247. @item lb/linblenddeint
  5248. Linear blend deinterlacing filter that deinterlaces the given block by
  5249. filtering all lines with a @code{(1 2 1)} filter.
  5250. @item li/linipoldeint
  5251. Linear interpolating deinterlacing filter that deinterlaces the given block by
  5252. linearly interpolating every second line.
  5253. @item ci/cubicipoldeint
  5254. Cubic interpolating deinterlacing filter deinterlaces the given block by
  5255. cubically interpolating every second line.
  5256. @item md/mediandeint
  5257. Median deinterlacing filter that deinterlaces the given block by applying a
  5258. median filter to every second line.
  5259. @item fd/ffmpegdeint
  5260. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  5261. second line with a @code{(-1 4 2 4 -1)} filter.
  5262. @item l5/lowpass5
  5263. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  5264. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  5265. @item fq/forceQuant[|quantizer]
  5266. Overrides the quantizer table from the input with the constant quantizer you
  5267. specify.
  5268. @table @option
  5269. @item quantizer
  5270. Quantizer to use
  5271. @end table
  5272. @item de/default
  5273. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  5274. @item fa/fast
  5275. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  5276. @item ac
  5277. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  5278. @end table
  5279. @subsection Examples
  5280. @itemize
  5281. @item
  5282. Apply horizontal and vertical deblocking, deringing and automatic
  5283. brightness/contrast:
  5284. @example
  5285. pp=hb/vb/dr/al
  5286. @end example
  5287. @item
  5288. Apply default filters without brightness/contrast correction:
  5289. @example
  5290. pp=de/-al
  5291. @end example
  5292. @item
  5293. Apply default filters and temporal denoiser:
  5294. @example
  5295. pp=default/tmpnoise|1|2|3
  5296. @end example
  5297. @item
  5298. Apply deblocking on luminance only, and switch vertical deblocking on or off
  5299. automatically depending on available CPU time:
  5300. @example
  5301. pp=hb|y/vb|a
  5302. @end example
  5303. @end itemize
  5304. @section psnr
  5305. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  5306. Ratio) between two input videos.
  5307. This filter takes in input two input videos, the first input is
  5308. considered the "main" source and is passed unchanged to the
  5309. output. The second input is used as a "reference" video for computing
  5310. the PSNR.
  5311. Both video inputs must have the same resolution and pixel format for
  5312. this filter to work correctly. Also it assumes that both inputs
  5313. have the same number of frames, which are compared one by one.
  5314. The obtained average PSNR is printed through the logging system.
  5315. The filter stores the accumulated MSE (mean squared error) of each
  5316. frame, and at the end of the processing it is averaged across all frames
  5317. equally, and the following formula is applied to obtain the PSNR:
  5318. @example
  5319. PSNR = 10*log10(MAX^2/MSE)
  5320. @end example
  5321. Where MAX is the average of the maximum values of each component of the
  5322. image.
  5323. The description of the accepted parameters follows.
  5324. @table @option
  5325. @item stats_file, f
  5326. If specified the filter will use the named file to save the PSNR of
  5327. each individual frame.
  5328. @end table
  5329. The file printed if @var{stats_file} is selected, contains a sequence of
  5330. key/value pairs of the form @var{key}:@var{value} for each compared
  5331. couple of frames.
  5332. A description of each shown parameter follows:
  5333. @table @option
  5334. @item n
  5335. sequential number of the input frame, starting from 1
  5336. @item mse_avg
  5337. Mean Square Error pixel-by-pixel average difference of the compared
  5338. frames, averaged over all the image components.
  5339. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  5340. Mean Square Error pixel-by-pixel average difference of the compared
  5341. frames for the component specified by the suffix.
  5342. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  5343. Peak Signal to Noise ratio of the compared frames for the component
  5344. specified by the suffix.
  5345. @end table
  5346. For example:
  5347. @example
  5348. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  5349. [main][ref] psnr="stats_file=stats.log" [out]
  5350. @end example
  5351. On this example the input file being processed is compared with the
  5352. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  5353. is stored in @file{stats.log}.
  5354. @anchor{pullup}
  5355. @section pullup
  5356. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  5357. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  5358. content.
  5359. The pullup filter is designed to take advantage of future context in making
  5360. its decisions. This filter is stateless in the sense that it does not lock
  5361. onto a pattern to follow, but it instead looks forward to the following
  5362. fields in order to identify matches and rebuild progressive frames.
  5363. To produce content with an even framerate, insert the fps filter after
  5364. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  5365. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  5366. The filter accepts the following options:
  5367. @table @option
  5368. @item jl
  5369. @item jr
  5370. @item jt
  5371. @item jb
  5372. These options set the amount of "junk" to ignore at the left, right, top, and
  5373. bottom of the image, respectively. Left and right are in units of 8 pixels,
  5374. while top and bottom are in units of 2 lines.
  5375. The default is 8 pixels on each side.
  5376. @item sb
  5377. Set the strict breaks. Setting this option to 1 will reduce the chances of
  5378. filter generating an occasional mismatched frame, but it may also cause an
  5379. excessive number of frames to be dropped during high motion sequences.
  5380. Conversely, setting it to -1 will make filter match fields more easily.
  5381. This may help processing of video where there is slight blurring between
  5382. the fields, but may also cause there to be interlaced frames in the output.
  5383. Default value is @code{0}.
  5384. @item mp
  5385. Set the metric plane to use. It accepts the following values:
  5386. @table @samp
  5387. @item l
  5388. Use luma plane.
  5389. @item u
  5390. Use chroma blue plane.
  5391. @item v
  5392. Use chroma red plane.
  5393. @end table
  5394. This option may be set to use chroma plane instead of the default luma plane
  5395. for doing filter's computations. This may improve accuracy on very clean
  5396. source material, but more likely will decrease accuracy, especially if there
  5397. is chroma noise (rainbow effect) or any grayscale video.
  5398. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  5399. load and make pullup usable in realtime on slow machines.
  5400. @end table
  5401. For best results (without duplicated frames in the output file) it is
  5402. necessary to change the output frame rate. For example, to inverse
  5403. telecine NTSC input:
  5404. @example
  5405. ffmpeg -i input -vf pullup -r 24000/1001 ...
  5406. @end example
  5407. @section removelogo
  5408. Suppress a TV station logo, using an image file to determine which
  5409. pixels comprise the logo. It works by filling in the pixels that
  5410. comprise the logo with neighboring pixels.
  5411. The filter accepts the following options:
  5412. @table @option
  5413. @item filename, f
  5414. Set the filter bitmap file, which can be any image format supported by
  5415. libavformat. The width and height of the image file must match those of the
  5416. video stream being processed.
  5417. @end table
  5418. Pixels in the provided bitmap image with a value of zero are not
  5419. considered part of the logo, non-zero pixels are considered part of
  5420. the logo. If you use white (255) for the logo and black (0) for the
  5421. rest, you will be safe. For making the filter bitmap, it is
  5422. recommended to take a screen capture of a black frame with the logo
  5423. visible, and then using a threshold filter followed by the erode
  5424. filter once or twice.
  5425. If needed, little splotches can be fixed manually. Remember that if
  5426. logo pixels are not covered, the filter quality will be much
  5427. reduced. Marking too many pixels as part of the logo does not hurt as
  5428. much, but it will increase the amount of blurring needed to cover over
  5429. the image and will destroy more information than necessary, and extra
  5430. pixels will slow things down on a large logo.
  5431. @section rotate
  5432. Rotate video by an arbitrary angle expressed in radians.
  5433. The filter accepts the following options:
  5434. A description of the optional parameters follows.
  5435. @table @option
  5436. @item angle, a
  5437. Set an expression for the angle by which to rotate the input video
  5438. clockwise, expressed as a number of radians. A negative value will
  5439. result in a counter-clockwise rotation. By default it is set to "0".
  5440. This expression is evaluated for each frame.
  5441. @item out_w, ow
  5442. Set the output width expression, default value is "iw".
  5443. This expression is evaluated just once during configuration.
  5444. @item out_h, oh
  5445. Set the output height expression, default value is "ih".
  5446. This expression is evaluated just once during configuration.
  5447. @item bilinear
  5448. Enable bilinear interpolation if set to 1, a value of 0 disables
  5449. it. Default value is 1.
  5450. @item fillcolor, c
  5451. Set the color used to fill the output area not covered by the rotated
  5452. image. For the generalsyntax of this option, check the "Color" section in the
  5453. ffmpeg-utils manual. If the special value "none" is selected then no
  5454. background is printed (useful for example if the background is never shown).
  5455. Default value is "black".
  5456. @end table
  5457. The expressions for the angle and the output size can contain the
  5458. following constants and functions:
  5459. @table @option
  5460. @item n
  5461. sequential number of the input frame, starting from 0. It is always NAN
  5462. before the first frame is filtered.
  5463. @item t
  5464. time in seconds of the input frame, it is set to 0 when the filter is
  5465. configured. It is always NAN before the first frame is filtered.
  5466. @item hsub
  5467. @item vsub
  5468. horizontal and vertical chroma subsample values. For example for the
  5469. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5470. @item in_w, iw
  5471. @item in_h, ih
  5472. the input video width and height
  5473. @item out_w, ow
  5474. @item out_h, oh
  5475. the output width and height, that is the size of the padded area as
  5476. specified by the @var{width} and @var{height} expressions
  5477. @item rotw(a)
  5478. @item roth(a)
  5479. the minimal width/height required for completely containing the input
  5480. video rotated by @var{a} radians.
  5481. These are only available when computing the @option{out_w} and
  5482. @option{out_h} expressions.
  5483. @end table
  5484. @subsection Examples
  5485. @itemize
  5486. @item
  5487. Rotate the input by PI/6 radians clockwise:
  5488. @example
  5489. rotate=PI/6
  5490. @end example
  5491. @item
  5492. Rotate the input by PI/6 radians counter-clockwise:
  5493. @example
  5494. rotate=-PI/6
  5495. @end example
  5496. @item
  5497. Rotate the input by 45 degrees clockwise:
  5498. @example
  5499. rotate=45*PI/180
  5500. @end example
  5501. @item
  5502. Apply a constant rotation with period T, starting from an angle of PI/3:
  5503. @example
  5504. rotate=PI/3+2*PI*t/T
  5505. @end example
  5506. @item
  5507. Make the input video rotation oscillating with a period of T
  5508. seconds and an amplitude of A radians:
  5509. @example
  5510. rotate=A*sin(2*PI/T*t)
  5511. @end example
  5512. @item
  5513. Rotate the video, output size is chosen so that the whole rotating
  5514. input video is always completely contained in the output:
  5515. @example
  5516. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  5517. @end example
  5518. @item
  5519. Rotate the video, reduce the output size so that no background is ever
  5520. shown:
  5521. @example
  5522. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  5523. @end example
  5524. @end itemize
  5525. @subsection Commands
  5526. The filter supports the following commands:
  5527. @table @option
  5528. @item a, angle
  5529. Set the angle expression.
  5530. The command accepts the same syntax of the corresponding option.
  5531. If the specified expression is not valid, it is kept at its current
  5532. value.
  5533. @end table
  5534. @section sab
  5535. Apply Shape Adaptive Blur.
  5536. The filter accepts the following options:
  5537. @table @option
  5538. @item luma_radius, lr
  5539. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  5540. value is 1.0. A greater value will result in a more blurred image, and
  5541. in slower processing.
  5542. @item luma_pre_filter_radius, lpfr
  5543. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  5544. value is 1.0.
  5545. @item luma_strength, ls
  5546. Set luma maximum difference between pixels to still be considered, must
  5547. be a value in the 0.1-100.0 range, default value is 1.0.
  5548. @item chroma_radius, cr
  5549. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  5550. greater value will result in a more blurred image, and in slower
  5551. processing.
  5552. @item chroma_pre_filter_radius, cpfr
  5553. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  5554. @item chroma_strength, cs
  5555. Set chroma maximum difference between pixels to still be considered,
  5556. must be a value in the 0.1-100.0 range.
  5557. @end table
  5558. Each chroma option value, if not explicitly specified, is set to the
  5559. corresponding luma option value.
  5560. @anchor{scale}
  5561. @section scale
  5562. Scale (resize) the input video, using the libswscale library.
  5563. The scale filter forces the output display aspect ratio to be the same
  5564. of the input, by changing the output sample aspect ratio.
  5565. If the input image format is different from the format requested by
  5566. the next filter, the scale filter will convert the input to the
  5567. requested format.
  5568. @subsection Options
  5569. The filter accepts the following options, or any of the options
  5570. supported by the libswscale scaler.
  5571. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  5572. the complete list of scaler options.
  5573. @table @option
  5574. @item width, w
  5575. @item height, h
  5576. Set the output video dimension expression. Default value is the input
  5577. dimension.
  5578. If the value is 0, the input width is used for the output.
  5579. If one of the values is -1, the scale filter will use a value that
  5580. maintains the aspect ratio of the input image, calculated from the
  5581. other specified dimension. If both of them are -1, the input size is
  5582. used
  5583. If one of the values is -n with n > 1, the scale filter will also use a value
  5584. that maintains the aspect ratio of the input image, calculated from the other
  5585. specified dimension. After that it will, however, make sure that the calculated
  5586. dimension is divisible by n and adjust the value if necessary.
  5587. See below for the list of accepted constants for use in the dimension
  5588. expression.
  5589. @item interl
  5590. Set the interlacing mode. It accepts the following values:
  5591. @table @samp
  5592. @item 1
  5593. Force interlaced aware scaling.
  5594. @item 0
  5595. Do not apply interlaced scaling.
  5596. @item -1
  5597. Select interlaced aware scaling depending on whether the source frames
  5598. are flagged as interlaced or not.
  5599. @end table
  5600. Default value is @samp{0}.
  5601. @item flags
  5602. Set libswscale scaling flags. See
  5603. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  5604. complete list of values. If not explicitly specified the filter applies
  5605. the default flags.
  5606. @item size, s
  5607. Set the video size. For the syntax of this option, check the "Video size"
  5608. section in the ffmpeg-utils manual.
  5609. @item in_color_matrix
  5610. @item out_color_matrix
  5611. Set in/output YCbCr color space type.
  5612. This allows the autodetected value to be overridden as well as allows forcing
  5613. a specific value used for the output and encoder.
  5614. If not specified, the color space type depends on the pixel format.
  5615. Possible values:
  5616. @table @samp
  5617. @item auto
  5618. Choose automatically.
  5619. @item bt709
  5620. Format conforming to International Telecommunication Union (ITU)
  5621. Recommendation BT.709.
  5622. @item fcc
  5623. Set color space conforming to the United States Federal Communications
  5624. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  5625. @item bt601
  5626. Set color space conforming to:
  5627. @itemize
  5628. @item
  5629. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  5630. @item
  5631. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  5632. @item
  5633. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  5634. @end itemize
  5635. @item smpte240m
  5636. Set color space conforming to SMPTE ST 240:1999.
  5637. @end table
  5638. @item in_range
  5639. @item out_range
  5640. Set in/output YCbCr sample range.
  5641. This allows the autodetected value to be overridden as well as allows forcing
  5642. a specific value used for the output and encoder. If not specified, the
  5643. range depends on the pixel format. Possible values:
  5644. @table @samp
  5645. @item auto
  5646. Choose automatically.
  5647. @item jpeg/full/pc
  5648. Set full range (0-255 in case of 8-bit luma).
  5649. @item mpeg/tv
  5650. Set "MPEG" range (16-235 in case of 8-bit luma).
  5651. @end table
  5652. @item force_original_aspect_ratio
  5653. Enable decreasing or increasing output video width or height if necessary to
  5654. keep the original aspect ratio. Possible values:
  5655. @table @samp
  5656. @item disable
  5657. Scale the video as specified and disable this feature.
  5658. @item decrease
  5659. The output video dimensions will automatically be decreased if needed.
  5660. @item increase
  5661. The output video dimensions will automatically be increased if needed.
  5662. @end table
  5663. One useful instance of this option is that when you know a specific device's
  5664. maximum allowed resolution, you can use this to limit the output video to
  5665. that, while retaining the aspect ratio. For example, device A allows
  5666. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  5667. decrease) and specifying 1280x720 to the command line makes the output
  5668. 1280x533.
  5669. Please note that this is a different thing than specifying -1 for @option{w}
  5670. or @option{h}, you still need to specify the output resolution for this option
  5671. to work.
  5672. @end table
  5673. The values of the @option{w} and @option{h} options are expressions
  5674. containing the following constants:
  5675. @table @var
  5676. @item in_w
  5677. @item in_h
  5678. The input width and height
  5679. @item iw
  5680. @item ih
  5681. These are the same as @var{in_w} and @var{in_h}.
  5682. @item out_w
  5683. @item out_h
  5684. The output (scaled) width and height
  5685. @item ow
  5686. @item oh
  5687. These are the same as @var{out_w} and @var{out_h}
  5688. @item a
  5689. The same as @var{iw} / @var{ih}
  5690. @item sar
  5691. input sample aspect ratio
  5692. @item dar
  5693. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  5694. @item hsub
  5695. @item vsub
  5696. horizontal and vertical input chroma subsample values. For example for the
  5697. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5698. @item ohsub
  5699. @item ovsub
  5700. horizontal and vertical output chroma subsample values. For example for the
  5701. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5702. @end table
  5703. @subsection Examples
  5704. @itemize
  5705. @item
  5706. Scale the input video to a size of 200x100
  5707. @example
  5708. scale=w=200:h=100
  5709. @end example
  5710. This is equivalent to:
  5711. @example
  5712. scale=200:100
  5713. @end example
  5714. or:
  5715. @example
  5716. scale=200x100
  5717. @end example
  5718. @item
  5719. Specify a size abbreviation for the output size:
  5720. @example
  5721. scale=qcif
  5722. @end example
  5723. which can also be written as:
  5724. @example
  5725. scale=size=qcif
  5726. @end example
  5727. @item
  5728. Scale the input to 2x:
  5729. @example
  5730. scale=w=2*iw:h=2*ih
  5731. @end example
  5732. @item
  5733. The above is the same as:
  5734. @example
  5735. scale=2*in_w:2*in_h
  5736. @end example
  5737. @item
  5738. Scale the input to 2x with forced interlaced scaling:
  5739. @example
  5740. scale=2*iw:2*ih:interl=1
  5741. @end example
  5742. @item
  5743. Scale the input to half size:
  5744. @example
  5745. scale=w=iw/2:h=ih/2
  5746. @end example
  5747. @item
  5748. Increase the width, and set the height to the same size:
  5749. @example
  5750. scale=3/2*iw:ow
  5751. @end example
  5752. @item
  5753. Seek Greek harmony:
  5754. @example
  5755. scale=iw:1/PHI*iw
  5756. scale=ih*PHI:ih
  5757. @end example
  5758. @item
  5759. Increase the height, and set the width to 3/2 of the height:
  5760. @example
  5761. scale=w=3/2*oh:h=3/5*ih
  5762. @end example
  5763. @item
  5764. Increase the size, making the size a multiple of the chroma
  5765. subsample values:
  5766. @example
  5767. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  5768. @end example
  5769. @item
  5770. Increase the width to a maximum of 500 pixels,
  5771. keeping the same aspect ratio as the input:
  5772. @example
  5773. scale=w='min(500\, iw*3/2):h=-1'
  5774. @end example
  5775. @end itemize
  5776. @section separatefields
  5777. The @code{separatefields} takes a frame-based video input and splits
  5778. each frame into its components fields, producing a new half height clip
  5779. with twice the frame rate and twice the frame count.
  5780. This filter use field-dominance information in frame to decide which
  5781. of each pair of fields to place first in the output.
  5782. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  5783. @section setdar, setsar
  5784. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  5785. output video.
  5786. This is done by changing the specified Sample (aka Pixel) Aspect
  5787. Ratio, according to the following equation:
  5788. @example
  5789. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  5790. @end example
  5791. Keep in mind that the @code{setdar} filter does not modify the pixel
  5792. dimensions of the video frame. Also, the display aspect ratio set by
  5793. this filter may be changed by later filters in the filterchain,
  5794. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  5795. applied.
  5796. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  5797. the filter output video.
  5798. Note that as a consequence of the application of this filter, the
  5799. output display aspect ratio will change according to the equation
  5800. above.
  5801. Keep in mind that the sample aspect ratio set by the @code{setsar}
  5802. filter may be changed by later filters in the filterchain, e.g. if
  5803. another "setsar" or a "setdar" filter is applied.
  5804. It accepts the following parameters:
  5805. @table @option
  5806. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  5807. Set the aspect ratio used by the filter.
  5808. The parameter can be a floating point number string, an expression, or
  5809. a string of the form @var{num}:@var{den}, where @var{num} and
  5810. @var{den} are the numerator and denominator of the aspect ratio. If
  5811. the parameter is not specified, it is assumed the value "0".
  5812. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  5813. should be escaped.
  5814. @item max
  5815. Set the maximum integer value to use for expressing numerator and
  5816. denominator when reducing the expressed aspect ratio to a rational.
  5817. Default value is @code{100}.
  5818. @end table
  5819. The parameter @var{sar} is an expression containing
  5820. the following constants:
  5821. @table @option
  5822. @item E, PI, PHI
  5823. These are approximated values for the mathematical constants e
  5824. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  5825. @item w, h
  5826. The input width and height.
  5827. @item a
  5828. These are the same as @var{w} / @var{h}.
  5829. @item sar
  5830. The input sample aspect ratio.
  5831. @item dar
  5832. The input display aspect ratio. It is the same as
  5833. (@var{w} / @var{h}) * @var{sar}.
  5834. @item hsub, vsub
  5835. Horizontal and vertical chroma subsample values. For example, for the
  5836. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5837. @end table
  5838. @subsection Examples
  5839. @itemize
  5840. @item
  5841. To change the display aspect ratio to 16:9, specify one of the following:
  5842. @example
  5843. setdar=dar=1.77777
  5844. setdar=dar=16/9
  5845. setdar=dar=1.77777
  5846. @end example
  5847. @item
  5848. To change the sample aspect ratio to 10:11, specify:
  5849. @example
  5850. setsar=sar=10/11
  5851. @end example
  5852. @item
  5853. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  5854. 1000 in the aspect ratio reduction, use the command:
  5855. @example
  5856. setdar=ratio=16/9:max=1000
  5857. @end example
  5858. @end itemize
  5859. @anchor{setfield}
  5860. @section setfield
  5861. Force field for the output video frame.
  5862. The @code{setfield} filter marks the interlace type field for the
  5863. output frames. It does not change the input frame, but only sets the
  5864. corresponding property, which affects how the frame is treated by
  5865. following filters (e.g. @code{fieldorder} or @code{yadif}).
  5866. The filter accepts the following options:
  5867. @table @option
  5868. @item mode
  5869. Available values are:
  5870. @table @samp
  5871. @item auto
  5872. Keep the same field property.
  5873. @item bff
  5874. Mark the frame as bottom-field-first.
  5875. @item tff
  5876. Mark the frame as top-field-first.
  5877. @item prog
  5878. Mark the frame as progressive.
  5879. @end table
  5880. @end table
  5881. @section showinfo
  5882. Show a line containing various information for each input video frame.
  5883. The input video is not modified.
  5884. The shown line contains a sequence of key/value pairs of the form
  5885. @var{key}:@var{value}.
  5886. The following values are shown in the output:
  5887. @table @option
  5888. @item n
  5889. The (sequential) number of the input frame, starting from 0.
  5890. @item pts
  5891. The Presentation TimeStamp of the input frame, expressed as a number of
  5892. time base units. The time base unit depends on the filter input pad.
  5893. @item pts_time
  5894. The Presentation TimeStamp of the input frame, expressed as a number of
  5895. seconds.
  5896. @item pos
  5897. The position of the frame in the input stream, or -1 if this information is
  5898. unavailable and/or meaningless (for example in case of synthetic video).
  5899. @item fmt
  5900. The pixel format name.
  5901. @item sar
  5902. The sample aspect ratio of the input frame, expressed in the form
  5903. @var{num}/@var{den}.
  5904. @item s
  5905. The size of the input frame. For the syntax of this option, check the "Video size"
  5906. section in the ffmpeg-utils manual.
  5907. @item i
  5908. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  5909. for bottom field first).
  5910. @item iskey
  5911. This is 1 if the frame is a key frame, 0 otherwise.
  5912. @item type
  5913. The picture type of the input frame ("I" for an I-frame, "P" for a
  5914. P-frame, "B" for a B-frame, or "?" for an unknown type).
  5915. Also refer to the documentation of the @code{AVPictureType} enum and of
  5916. the @code{av_get_picture_type_char} function defined in
  5917. @file{libavutil/avutil.h}.
  5918. @item checksum
  5919. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  5920. @item plane_checksum
  5921. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  5922. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  5923. @end table
  5924. @section shuffleplanes
  5925. Reorder and/or duplicate video planes.
  5926. It accepts the following parameters:
  5927. @table @option
  5928. @item map0
  5929. The index of the input plane to be used as the first output plane.
  5930. @item map1
  5931. The index of the input plane to be used as the second output plane.
  5932. @item map2
  5933. The index of the input plane to be used as the third output plane.
  5934. @item map3
  5935. The index of the input plane to be used as the fourth output plane.
  5936. @end table
  5937. The first plane has the index 0. The default is to keep the input unchanged.
  5938. Swap the second and third planes of the input:
  5939. @example
  5940. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  5941. @end example
  5942. @section signalstats
  5943. Evaluate various visual metrics that assist in determining issues associated
  5944. with the digitization of analog video media.
  5945. By default the filter will log these metadata values:
  5946. @table @option
  5947. @item YMIN
  5948. Display the minimal Y value contained within the input frame. Expressed in
  5949. range of [0-255].
  5950. @item YLOW
  5951. Display the Y value at the 10% percentile within the input frame. Expressed in
  5952. range of [0-255].
  5953. @item YAVG
  5954. Display the average Y value within the input frame. Expressed in range of
  5955. [0-255].
  5956. @item YHIGH
  5957. Display the Y value at the 90% percentile within the input frame. Expressed in
  5958. range of [0-255].
  5959. @item YMAX
  5960. Display the maximum Y value contained within the input frame. Expressed in
  5961. range of [0-255].
  5962. @item UMIN
  5963. Display the minimal U value contained within the input frame. Expressed in
  5964. range of [0-255].
  5965. @item ULOW
  5966. Display the U value at the 10% percentile within the input frame. Expressed in
  5967. range of [0-255].
  5968. @item UAVG
  5969. Display the average U value within the input frame. Expressed in range of
  5970. [0-255].
  5971. @item UHIGH
  5972. Display the U value at the 90% percentile within the input frame. Expressed in
  5973. range of [0-255].
  5974. @item UMAX
  5975. Display the maximum U value contained within the input frame. Expressed in
  5976. range of [0-255].
  5977. @item VMIN
  5978. Display the minimal V value contained within the input frame. Expressed in
  5979. range of [0-255].
  5980. @item VLOW
  5981. Display the V value at the 10% percentile within the input frame. Expressed in
  5982. range of [0-255].
  5983. @item VAVG
  5984. Display the average V value within the input frame. Expressed in range of
  5985. [0-255].
  5986. @item VHIGH
  5987. Display the V value at the 90% percentile within the input frame. Expressed in
  5988. range of [0-255].
  5989. @item VMAX
  5990. Display the maximum V value contained within the input frame. Expressed in
  5991. range of [0-255].
  5992. @item SATMIN
  5993. Display the minimal saturation value contained within the input frame.
  5994. Expressed in range of [0-~181.02].
  5995. @item SATLOW
  5996. Display the saturation value at the 10% percentile within the input frame.
  5997. Expressed in range of [0-~181.02].
  5998. @item SATAVG
  5999. Display the average saturation value within the input frame. Expressed in range
  6000. of [0-~181.02].
  6001. @item SATHIGH
  6002. Display the saturation value at the 90% percentile within the input frame.
  6003. Expressed in range of [0-~181.02].
  6004. @item SATMAX
  6005. Display the maximum saturation value contained within the input frame.
  6006. Expressed in range of [0-~181.02].
  6007. @item HUEMED
  6008. Display the median value for hue within the input frame. Expressed in range of
  6009. [0-360].
  6010. @item HUEAVG
  6011. Display the average value for hue within the input frame. Expressed in range of
  6012. [0-360].
  6013. @item YDIF
  6014. Display the average of sample value difference between all values of the Y
  6015. plane in the current frame and corresponding values of the previous input frame.
  6016. Expressed in range of [0-255].
  6017. @item UDIF
  6018. Display the average of sample value difference between all values of the U
  6019. plane in the current frame and corresponding values of the previous input frame.
  6020. Expressed in range of [0-255].
  6021. @item VDIF
  6022. Display the average of sample value difference between all values of the V
  6023. plane in the current frame and corresponding values of the previous input frame.
  6024. Expressed in range of [0-255].
  6025. @end table
  6026. The filter accepts the following options:
  6027. @table @option
  6028. @item stat
  6029. @item out
  6030. @option{stat} specify an additional form of image analysis.
  6031. @option{out} output video with the specified type of pixel highlighted.
  6032. Both options accept the following values:
  6033. @table @samp
  6034. @item tout
  6035. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  6036. unlike the neighboring pixels of the same field. Examples of temporal outliers
  6037. include the results of video dropouts, head clogs, or tape tracking issues.
  6038. @item vrep
  6039. Identify @var{vertical line repetition}. Vertical line repetition includes
  6040. similar rows of pixels within a frame. In born-digital video vertical line
  6041. repetition is common, but this pattern is uncommon in video digitized from an
  6042. analog source. When it occurs in video that results from the digitization of an
  6043. analog source it can indicate concealment from a dropout compensator.
  6044. @item brng
  6045. Identify pixels that fall outside of legal broadcast range.
  6046. @end table
  6047. @item color, c
  6048. Set the highlight color for the @option{out} option. The default color is
  6049. yellow.
  6050. @end table
  6051. @subsection Examples
  6052. @itemize
  6053. @item
  6054. Output data of various video metrics:
  6055. @example
  6056. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  6057. @end example
  6058. @item
  6059. Output specific data about the minimum and maximum values of the Y plane per frame:
  6060. @example
  6061. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  6062. @end example
  6063. @item
  6064. Playback video while highlighting pixels that are outside of broadcast range in red.
  6065. @example
  6066. ffplay example.mov -vf signalstats="out=brng:color=red"
  6067. @end example
  6068. @item
  6069. Playback video with signalstats metadata drawn over the frame.
  6070. @example
  6071. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  6072. @end example
  6073. The contents of signalstat_drawtext.txt used in the command are:
  6074. @example
  6075. time %@{pts:hms@}
  6076. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  6077. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  6078. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  6079. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  6080. @end example
  6081. @end itemize
  6082. @anchor{smartblur}
  6083. @section smartblur
  6084. Blur the input video without impacting the outlines.
  6085. It accepts the following options:
  6086. @table @option
  6087. @item luma_radius, lr
  6088. Set the luma radius. The option value must be a float number in
  6089. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6090. used to blur the image (slower if larger). Default value is 1.0.
  6091. @item luma_strength, ls
  6092. Set the luma strength. The option value must be a float number
  6093. in the range [-1.0,1.0] that configures the blurring. A value included
  6094. in [0.0,1.0] will blur the image whereas a value included in
  6095. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6096. @item luma_threshold, lt
  6097. Set the luma threshold used as a coefficient to determine
  6098. whether a pixel should be blurred or not. The option value must be an
  6099. integer in the range [-30,30]. A value of 0 will filter all the image,
  6100. a value included in [0,30] will filter flat areas and a value included
  6101. in [-30,0] will filter edges. Default value is 0.
  6102. @item chroma_radius, cr
  6103. Set the chroma radius. The option value must be a float number in
  6104. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6105. used to blur the image (slower if larger). Default value is 1.0.
  6106. @item chroma_strength, cs
  6107. Set the chroma strength. The option value must be a float number
  6108. in the range [-1.0,1.0] that configures the blurring. A value included
  6109. in [0.0,1.0] will blur the image whereas a value included in
  6110. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6111. @item chroma_threshold, ct
  6112. Set the chroma threshold used as a coefficient to determine
  6113. whether a pixel should be blurred or not. The option value must be an
  6114. integer in the range [-30,30]. A value of 0 will filter all the image,
  6115. a value included in [0,30] will filter flat areas and a value included
  6116. in [-30,0] will filter edges. Default value is 0.
  6117. @end table
  6118. If a chroma option is not explicitly set, the corresponding luma value
  6119. is set.
  6120. @section stereo3d
  6121. Convert between different stereoscopic image formats.
  6122. The filters accept the following options:
  6123. @table @option
  6124. @item in
  6125. Set stereoscopic image format of input.
  6126. Available values for input image formats are:
  6127. @table @samp
  6128. @item sbsl
  6129. side by side parallel (left eye left, right eye right)
  6130. @item sbsr
  6131. side by side crosseye (right eye left, left eye right)
  6132. @item sbs2l
  6133. side by side parallel with half width resolution
  6134. (left eye left, right eye right)
  6135. @item sbs2r
  6136. side by side crosseye with half width resolution
  6137. (right eye left, left eye right)
  6138. @item abl
  6139. above-below (left eye above, right eye below)
  6140. @item abr
  6141. above-below (right eye above, left eye below)
  6142. @item ab2l
  6143. above-below with half height resolution
  6144. (left eye above, right eye below)
  6145. @item ab2r
  6146. above-below with half height resolution
  6147. (right eye above, left eye below)
  6148. @item al
  6149. alternating frames (left eye first, right eye second)
  6150. @item ar
  6151. alternating frames (right eye first, left eye second)
  6152. Default value is @samp{sbsl}.
  6153. @end table
  6154. @item out
  6155. Set stereoscopic image format of output.
  6156. Available values for output image formats are all the input formats as well as:
  6157. @table @samp
  6158. @item arbg
  6159. anaglyph red/blue gray
  6160. (red filter on left eye, blue filter on right eye)
  6161. @item argg
  6162. anaglyph red/green gray
  6163. (red filter on left eye, green filter on right eye)
  6164. @item arcg
  6165. anaglyph red/cyan gray
  6166. (red filter on left eye, cyan filter on right eye)
  6167. @item arch
  6168. anaglyph red/cyan half colored
  6169. (red filter on left eye, cyan filter on right eye)
  6170. @item arcc
  6171. anaglyph red/cyan color
  6172. (red filter on left eye, cyan filter on right eye)
  6173. @item arcd
  6174. anaglyph red/cyan color optimized with the least squares projection of dubois
  6175. (red filter on left eye, cyan filter on right eye)
  6176. @item agmg
  6177. anaglyph green/magenta gray
  6178. (green filter on left eye, magenta filter on right eye)
  6179. @item agmh
  6180. anaglyph green/magenta half colored
  6181. (green filter on left eye, magenta filter on right eye)
  6182. @item agmc
  6183. anaglyph green/magenta colored
  6184. (green filter on left eye, magenta filter on right eye)
  6185. @item agmd
  6186. anaglyph green/magenta color optimized with the least squares projection of dubois
  6187. (green filter on left eye, magenta filter on right eye)
  6188. @item aybg
  6189. anaglyph yellow/blue gray
  6190. (yellow filter on left eye, blue filter on right eye)
  6191. @item aybh
  6192. anaglyph yellow/blue half colored
  6193. (yellow filter on left eye, blue filter on right eye)
  6194. @item aybc
  6195. anaglyph yellow/blue colored
  6196. (yellow filter on left eye, blue filter on right eye)
  6197. @item aybd
  6198. anaglyph yellow/blue color optimized with the least squares projection of dubois
  6199. (yellow filter on left eye, blue filter on right eye)
  6200. @item irl
  6201. interleaved rows (left eye has top row, right eye starts on next row)
  6202. @item irr
  6203. interleaved rows (right eye has top row, left eye starts on next row)
  6204. @item ml
  6205. mono output (left eye only)
  6206. @item mr
  6207. mono output (right eye only)
  6208. @end table
  6209. Default value is @samp{arcd}.
  6210. @end table
  6211. @subsection Examples
  6212. @itemize
  6213. @item
  6214. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  6215. @example
  6216. stereo3d=sbsl:aybd
  6217. @end example
  6218. @item
  6219. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  6220. @example
  6221. stereo3d=abl:sbsr
  6222. @end example
  6223. @end itemize
  6224. @section spp
  6225. Apply a simple postprocessing filter that compresses and decompresses the image
  6226. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  6227. and average the results.
  6228. The filter accepts the following options:
  6229. @table @option
  6230. @item quality
  6231. Set quality. This option defines the number of levels for averaging. It accepts
  6232. an integer in the range 0-6. If set to @code{0}, the filter will have no
  6233. effect. A value of @code{6} means the higher quality. For each increment of
  6234. that value the speed drops by a factor of approximately 2. Default value is
  6235. @code{3}.
  6236. @item qp
  6237. Force a constant quantization parameter. If not set, the filter will use the QP
  6238. from the video stream (if available).
  6239. @item mode
  6240. Set thresholding mode. Available modes are:
  6241. @table @samp
  6242. @item hard
  6243. Set hard thresholding (default).
  6244. @item soft
  6245. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6246. @end table
  6247. @item use_bframe_qp
  6248. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  6249. option may cause flicker since the B-Frames have often larger QP. Default is
  6250. @code{0} (not enabled).
  6251. @end table
  6252. @anchor{subtitles}
  6253. @section subtitles
  6254. Draw subtitles on top of input video using the libass library.
  6255. To enable compilation of this filter you need to configure FFmpeg with
  6256. @code{--enable-libass}. This filter also requires a build with libavcodec and
  6257. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  6258. Alpha) subtitles format.
  6259. The filter accepts the following options:
  6260. @table @option
  6261. @item filename, f
  6262. Set the filename of the subtitle file to read. It must be specified.
  6263. @item original_size
  6264. Specify the size of the original video, the video for which the ASS file
  6265. was composed. For the syntax of this option, check the "Video size" section in
  6266. the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic,
  6267. this is necessary to correctly scale the fonts if the aspect ratio has been
  6268. changed.
  6269. @item charenc
  6270. Set subtitles input character encoding. @code{subtitles} filter only. Only
  6271. useful if not UTF-8.
  6272. @item stream_index, si
  6273. Set subtitles stream index. @code{subtitles} filter only.
  6274. @end table
  6275. If the first key is not specified, it is assumed that the first value
  6276. specifies the @option{filename}.
  6277. For example, to render the file @file{sub.srt} on top of the input
  6278. video, use the command:
  6279. @example
  6280. subtitles=sub.srt
  6281. @end example
  6282. which is equivalent to:
  6283. @example
  6284. subtitles=filename=sub.srt
  6285. @end example
  6286. To render the default subtitles stream from file @file{video.mkv}, use:
  6287. @example
  6288. subtitles=video.mkv
  6289. @end example
  6290. To render the second subtitles stream from that file, use:
  6291. @example
  6292. subtitles=video.mkv:si=1
  6293. @end example
  6294. @section super2xsai
  6295. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  6296. Interpolate) pixel art scaling algorithm.
  6297. Useful for enlarging pixel art images without reducing sharpness.
  6298. @section swapuv
  6299. Swap U & V plane.
  6300. @section telecine
  6301. Apply telecine process to the video.
  6302. This filter accepts the following options:
  6303. @table @option
  6304. @item first_field
  6305. @table @samp
  6306. @item top, t
  6307. top field first
  6308. @item bottom, b
  6309. bottom field first
  6310. The default value is @code{top}.
  6311. @end table
  6312. @item pattern
  6313. A string of numbers representing the pulldown pattern you wish to apply.
  6314. The default value is @code{23}.
  6315. @end table
  6316. @example
  6317. Some typical patterns:
  6318. NTSC output (30i):
  6319. 27.5p: 32222
  6320. 24p: 23 (classic)
  6321. 24p: 2332 (preferred)
  6322. 20p: 33
  6323. 18p: 334
  6324. 16p: 3444
  6325. PAL output (25i):
  6326. 27.5p: 12222
  6327. 24p: 222222222223 ("Euro pulldown")
  6328. 16.67p: 33
  6329. 16p: 33333334
  6330. @end example
  6331. @section thumbnail
  6332. Select the most representative frame in a given sequence of consecutive frames.
  6333. The filter accepts the following options:
  6334. @table @option
  6335. @item n
  6336. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  6337. will pick one of them, and then handle the next batch of @var{n} frames until
  6338. the end. Default is @code{100}.
  6339. @end table
  6340. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  6341. value will result in a higher memory usage, so a high value is not recommended.
  6342. @subsection Examples
  6343. @itemize
  6344. @item
  6345. Extract one picture each 50 frames:
  6346. @example
  6347. thumbnail=50
  6348. @end example
  6349. @item
  6350. Complete example of a thumbnail creation with @command{ffmpeg}:
  6351. @example
  6352. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  6353. @end example
  6354. @end itemize
  6355. @section tile
  6356. Tile several successive frames together.
  6357. The filter accepts the following options:
  6358. @table @option
  6359. @item layout
  6360. Set the grid size (i.e. the number of lines and columns). For the syntax of
  6361. this option, check the "Video size" section in the ffmpeg-utils manual.
  6362. @item nb_frames
  6363. Set the maximum number of frames to render in the given area. It must be less
  6364. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  6365. the area will be used.
  6366. @item margin
  6367. Set the outer border margin in pixels.
  6368. @item padding
  6369. Set the inner border thickness (i.e. the number of pixels between frames). For
  6370. more advanced padding options (such as having different values for the edges),
  6371. refer to the pad video filter.
  6372. @item color
  6373. Specify the color of the unused areaFor the syntax of this option, check the
  6374. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  6375. is "black".
  6376. @end table
  6377. @subsection Examples
  6378. @itemize
  6379. @item
  6380. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  6381. @example
  6382. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  6383. @end example
  6384. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  6385. duplicating each output frame to accommodate the originally detected frame
  6386. rate.
  6387. @item
  6388. Display @code{5} pictures in an area of @code{3x2} frames,
  6389. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  6390. mixed flat and named options:
  6391. @example
  6392. tile=3x2:nb_frames=5:padding=7:margin=2
  6393. @end example
  6394. @end itemize
  6395. @section tinterlace
  6396. Perform various types of temporal field interlacing.
  6397. Frames are counted starting from 1, so the first input frame is
  6398. considered odd.
  6399. The filter accepts the following options:
  6400. @table @option
  6401. @item mode
  6402. Specify the mode of the interlacing. This option can also be specified
  6403. as a value alone. See below for a list of values for this option.
  6404. Available values are:
  6405. @table @samp
  6406. @item merge, 0
  6407. Move odd frames into the upper field, even into the lower field,
  6408. generating a double height frame at half frame rate.
  6409. @item drop_odd, 1
  6410. Only output even frames, odd frames are dropped, generating a frame with
  6411. unchanged height at half frame rate.
  6412. @item drop_even, 2
  6413. Only output odd frames, even frames are dropped, generating a frame with
  6414. unchanged height at half frame rate.
  6415. @item pad, 3
  6416. Expand each frame to full height, but pad alternate lines with black,
  6417. generating a frame with double height at the same input frame rate.
  6418. @item interleave_top, 4
  6419. Interleave the upper field from odd frames with the lower field from
  6420. even frames, generating a frame with unchanged height at half frame rate.
  6421. @item interleave_bottom, 5
  6422. Interleave the lower field from odd frames with the upper field from
  6423. even frames, generating a frame with unchanged height at half frame rate.
  6424. @item interlacex2, 6
  6425. Double frame rate with unchanged height. Frames are inserted each
  6426. containing the second temporal field from the previous input frame and
  6427. the first temporal field from the next input frame. This mode relies on
  6428. the top_field_first flag. Useful for interlaced video displays with no
  6429. field synchronisation.
  6430. @end table
  6431. Numeric values are deprecated but are accepted for backward
  6432. compatibility reasons.
  6433. Default mode is @code{merge}.
  6434. @item flags
  6435. Specify flags influencing the filter process.
  6436. Available value for @var{flags} is:
  6437. @table @option
  6438. @item low_pass_filter, vlfp
  6439. Enable vertical low-pass filtering in the filter.
  6440. Vertical low-pass filtering is required when creating an interlaced
  6441. destination from a progressive source which contains high-frequency
  6442. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  6443. patterning.
  6444. Vertical low-pass filtering can only be enabled for @option{mode}
  6445. @var{interleave_top} and @var{interleave_bottom}.
  6446. @end table
  6447. @end table
  6448. @section transpose
  6449. Transpose rows with columns in the input video and optionally flip it.
  6450. It accepts the following parameters:
  6451. @table @option
  6452. @item dir
  6453. Specify the transposition direction.
  6454. Can assume the following values:
  6455. @table @samp
  6456. @item 0, 4, cclock_flip
  6457. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  6458. @example
  6459. L.R L.l
  6460. . . -> . .
  6461. l.r R.r
  6462. @end example
  6463. @item 1, 5, clock
  6464. Rotate by 90 degrees clockwise, that is:
  6465. @example
  6466. L.R l.L
  6467. . . -> . .
  6468. l.r r.R
  6469. @end example
  6470. @item 2, 6, cclock
  6471. Rotate by 90 degrees counterclockwise, that is:
  6472. @example
  6473. L.R R.r
  6474. . . -> . .
  6475. l.r L.l
  6476. @end example
  6477. @item 3, 7, clock_flip
  6478. Rotate by 90 degrees clockwise and vertically flip, that is:
  6479. @example
  6480. L.R r.R
  6481. . . -> . .
  6482. l.r l.L
  6483. @end example
  6484. @end table
  6485. For values between 4-7, the transposition is only done if the input
  6486. video geometry is portrait and not landscape. These values are
  6487. deprecated, the @code{passthrough} option should be used instead.
  6488. Numerical values are deprecated, and should be dropped in favor of
  6489. symbolic constants.
  6490. @item passthrough
  6491. Do not apply the transposition if the input geometry matches the one
  6492. specified by the specified value. It accepts the following values:
  6493. @table @samp
  6494. @item none
  6495. Always apply transposition.
  6496. @item portrait
  6497. Preserve portrait geometry (when @var{height} >= @var{width}).
  6498. @item landscape
  6499. Preserve landscape geometry (when @var{width} >= @var{height}).
  6500. @end table
  6501. Default value is @code{none}.
  6502. @end table
  6503. For example to rotate by 90 degrees clockwise and preserve portrait
  6504. layout:
  6505. @example
  6506. transpose=dir=1:passthrough=portrait
  6507. @end example
  6508. The command above can also be specified as:
  6509. @example
  6510. transpose=1:portrait
  6511. @end example
  6512. @section trim
  6513. Trim the input so that the output contains one continuous subpart of the input.
  6514. It accepts the following parameters:
  6515. @table @option
  6516. @item start
  6517. Specify the time of the start of the kept section, i.e. the frame with the
  6518. timestamp @var{start} will be the first frame in the output.
  6519. @item end
  6520. Specify the time of the first frame that will be dropped, i.e. the frame
  6521. immediately preceding the one with the timestamp @var{end} will be the last
  6522. frame in the output.
  6523. @item start_pts
  6524. This is the same as @var{start}, except this option sets the start timestamp
  6525. in timebase units instead of seconds.
  6526. @item end_pts
  6527. This is the same as @var{end}, except this option sets the end timestamp
  6528. in timebase units instead of seconds.
  6529. @item duration
  6530. The maximum duration of the output in seconds.
  6531. @item start_frame
  6532. The number of the first frame that should be passed to the output.
  6533. @item end_frame
  6534. The number of the first frame that should be dropped.
  6535. @end table
  6536. @option{start}, @option{end}, @option{duration} are expressed as time
  6537. duration specifications, check the "Time duration" section in the
  6538. ffmpeg-utils manual.
  6539. Note that the first two sets of the start/end options and the @option{duration}
  6540. option look at the frame timestamp, while the _frame variants simply count the
  6541. frames that pass through the filter. Also note that this filter does not modify
  6542. the timestamps. If you wish for the output timestamps to start at zero, insert a
  6543. setpts filter after the trim filter.
  6544. If multiple start or end options are set, this filter tries to be greedy and
  6545. keep all the frames that match at least one of the specified constraints. To keep
  6546. only the part that matches all the constraints at once, chain multiple trim
  6547. filters.
  6548. The defaults are such that all the input is kept. So it is possible to set e.g.
  6549. just the end values to keep everything before the specified time.
  6550. Examples:
  6551. @itemize
  6552. @item
  6553. Drop everything except the second minute of input:
  6554. @example
  6555. ffmpeg -i INPUT -vf trim=60:120
  6556. @end example
  6557. @item
  6558. Keep only the first second:
  6559. @example
  6560. ffmpeg -i INPUT -vf trim=duration=1
  6561. @end example
  6562. @end itemize
  6563. @section unsharp
  6564. Sharpen or blur the input video.
  6565. It accepts the following parameters:
  6566. @table @option
  6567. @item luma_msize_x, lx
  6568. Set the luma matrix horizontal size. It must be an odd integer between
  6569. 3 and 63. The default value is 5.
  6570. @item luma_msize_y, ly
  6571. Set the luma matrix vertical size. It must be an odd integer between 3
  6572. and 63. The default value is 5.
  6573. @item luma_amount, la
  6574. Set the luma effect strength. It must be a floating point number, reasonable
  6575. values lay between -1.5 and 1.5.
  6576. Negative values will blur the input video, while positive values will
  6577. sharpen it, a value of zero will disable the effect.
  6578. Default value is 1.0.
  6579. @item chroma_msize_x, cx
  6580. Set the chroma matrix horizontal size. It must be an odd integer
  6581. between 3 and 63. The default value is 5.
  6582. @item chroma_msize_y, cy
  6583. Set the chroma matrix vertical size. It must be an odd integer
  6584. between 3 and 63. The default value is 5.
  6585. @item chroma_amount, ca
  6586. Set the chroma effect strength. It must be a floating point number, reasonable
  6587. values lay between -1.5 and 1.5.
  6588. Negative values will blur the input video, while positive values will
  6589. sharpen it, a value of zero will disable the effect.
  6590. Default value is 0.0.
  6591. @item opencl
  6592. If set to 1, specify using OpenCL capabilities, only available if
  6593. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  6594. @end table
  6595. All parameters are optional and default to the equivalent of the
  6596. string '5:5:1.0:5:5:0.0'.
  6597. @subsection Examples
  6598. @itemize
  6599. @item
  6600. Apply strong luma sharpen effect:
  6601. @example
  6602. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  6603. @end example
  6604. @item
  6605. Apply a strong blur of both luma and chroma parameters:
  6606. @example
  6607. unsharp=7:7:-2:7:7:-2
  6608. @end example
  6609. @end itemize
  6610. @anchor{vidstabdetect}
  6611. @section vidstabdetect
  6612. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  6613. @ref{vidstabtransform} for pass 2.
  6614. This filter generates a file with relative translation and rotation
  6615. transform information about subsequent frames, which is then used by
  6616. the @ref{vidstabtransform} filter.
  6617. To enable compilation of this filter you need to configure FFmpeg with
  6618. @code{--enable-libvidstab}.
  6619. This filter accepts the following options:
  6620. @table @option
  6621. @item result
  6622. Set the path to the file used to write the transforms information.
  6623. Default value is @file{transforms.trf}.
  6624. @item shakiness
  6625. Set how shaky the video is and how quick the camera is. It accepts an
  6626. integer in the range 1-10, a value of 1 means little shakiness, a
  6627. value of 10 means strong shakiness. Default value is 5.
  6628. @item accuracy
  6629. Set the accuracy of the detection process. It must be a value in the
  6630. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  6631. accuracy. Default value is 15.
  6632. @item stepsize
  6633. Set stepsize of the search process. The region around minimum is
  6634. scanned with 1 pixel resolution. Default value is 6.
  6635. @item mincontrast
  6636. Set minimum contrast. Below this value a local measurement field is
  6637. discarded. Must be a floating point value in the range 0-1. Default
  6638. value is 0.3.
  6639. @item tripod
  6640. Set reference frame number for tripod mode.
  6641. If enabled, the motion of the frames is compared to a reference frame
  6642. in the filtered stream, identified by the specified number. The idea
  6643. is to compensate all movements in a more-or-less static scene and keep
  6644. the camera view absolutely still.
  6645. If set to 0, it is disabled. The frames are counted starting from 1.
  6646. @item show
  6647. Show fields and transforms in the resulting frames. It accepts an
  6648. integer in the range 0-2. Default value is 0, which disables any
  6649. visualization.
  6650. @end table
  6651. @subsection Examples
  6652. @itemize
  6653. @item
  6654. Use default values:
  6655. @example
  6656. vidstabdetect
  6657. @end example
  6658. @item
  6659. Analyze strongly shaky movie and put the results in file
  6660. @file{mytransforms.trf}:
  6661. @example
  6662. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  6663. @end example
  6664. @item
  6665. Visualize the result of internal transformations in the resulting
  6666. video:
  6667. @example
  6668. vidstabdetect=show=1
  6669. @end example
  6670. @item
  6671. Analyze a video with medium shakiness using @command{ffmpeg}:
  6672. @example
  6673. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  6674. @end example
  6675. @end itemize
  6676. @anchor{vidstabtransform}
  6677. @section vidstabtransform
  6678. Video stabilization/deshaking: pass 2 of 2,
  6679. see @ref{vidstabdetect} for pass 1.
  6680. Read a file with transform information for each frame and
  6681. apply/compensate them. Together with the @ref{vidstabdetect}
  6682. filter this can be used to deshake videos. See also
  6683. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  6684. the unsharp filter, see below.
  6685. To enable compilation of this filter you need to configure FFmpeg with
  6686. @code{--enable-libvidstab}.
  6687. @subsection Options
  6688. @table @option
  6689. @item input
  6690. Set path to the file used to read the transforms. Default value is
  6691. @file{transforms.trf}).
  6692. @item smoothing
  6693. Set the number of frames (value*2 + 1) used for lowpass filtering the
  6694. camera movements. Default value is 10.
  6695. For example a number of 10 means that 21 frames are used (10 in the
  6696. past and 10 in the future) to smoothen the motion in the video. A
  6697. larger values leads to a smoother video, but limits the acceleration
  6698. of the camera (pan/tilt movements). 0 is a special case where a
  6699. static camera is simulated.
  6700. @item optalgo
  6701. Set the camera path optimization algorithm.
  6702. Accepted values are:
  6703. @table @samp
  6704. @item gauss
  6705. gaussian kernel low-pass filter on camera motion (default)
  6706. @item avg
  6707. averaging on transformations
  6708. @end table
  6709. @item maxshift
  6710. Set maximal number of pixels to translate frames. Default value is -1,
  6711. meaning no limit.
  6712. @item maxangle
  6713. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  6714. value is -1, meaning no limit.
  6715. @item crop
  6716. Specify how to deal with borders that may be visible due to movement
  6717. compensation.
  6718. Available values are:
  6719. @table @samp
  6720. @item keep
  6721. keep image information from previous frame (default)
  6722. @item black
  6723. fill the border black
  6724. @end table
  6725. @item invert
  6726. Invert transforms if set to 1. Default value is 0.
  6727. @item relative
  6728. Consider transforms as relative to previsou frame if set to 1,
  6729. absolute if set to 0. Default value is 0.
  6730. @item zoom
  6731. Set percentage to zoom. A positive value will result in a zoom-in
  6732. effect, a negative value in a zoom-out effect. Default value is 0 (no
  6733. zoom).
  6734. @item optzoom
  6735. Set optimal zooming to avoid borders.
  6736. Accepted values are:
  6737. @table @samp
  6738. @item 0
  6739. disabled
  6740. @item 1
  6741. optimal static zoom value is determined (only very strong movements
  6742. will lead to visible borders) (default)
  6743. @item 2
  6744. optimal adaptive zoom value is determined (no borders will be
  6745. visible), see @option{zoomspeed}
  6746. @end table
  6747. Note that the value given at zoom is added to the one calculated here.
  6748. @item zoomspeed
  6749. Set percent to zoom maximally each frame (enabled when
  6750. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  6751. 0.25.
  6752. @item interpol
  6753. Specify type of interpolation.
  6754. Available values are:
  6755. @table @samp
  6756. @item no
  6757. no interpolation
  6758. @item linear
  6759. linear only horizontal
  6760. @item bilinear
  6761. linear in both directions (default)
  6762. @item bicubic
  6763. cubic in both directions (slow)
  6764. @end table
  6765. @item tripod
  6766. Enable virtual tripod mode if set to 1, which is equivalent to
  6767. @code{relative=0:smoothing=0}. Default value is 0.
  6768. Use also @code{tripod} option of @ref{vidstabdetect}.
  6769. @item debug
  6770. Increase log verbosity if set to 1. Also the detected global motions
  6771. are written to the temporary file @file{global_motions.trf}. Default
  6772. value is 0.
  6773. @end table
  6774. @subsection Examples
  6775. @itemize
  6776. @item
  6777. Use @command{ffmpeg} for a typical stabilization with default values:
  6778. @example
  6779. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  6780. @end example
  6781. Note the use of the unsharp filter which is always recommended.
  6782. @item
  6783. Zoom in a bit more and load transform data from a given file:
  6784. @example
  6785. vidstabtransform=zoom=5:input="mytransforms.trf"
  6786. @end example
  6787. @item
  6788. Smoothen the video even more:
  6789. @example
  6790. vidstabtransform=smoothing=30
  6791. @end example
  6792. @end itemize
  6793. @section vflip
  6794. Flip the input video vertically.
  6795. For example, to vertically flip a video with @command{ffmpeg}:
  6796. @example
  6797. ffmpeg -i in.avi -vf "vflip" out.avi
  6798. @end example
  6799. @anchor{vignette}
  6800. @section vignette
  6801. Make or reverse a natural vignetting effect.
  6802. The filter accepts the following options:
  6803. @table @option
  6804. @item angle, a
  6805. Set lens angle expression as a number of radians.
  6806. The value is clipped in the @code{[0,PI/2]} range.
  6807. Default value: @code{"PI/5"}
  6808. @item x0
  6809. @item y0
  6810. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  6811. by default.
  6812. @item mode
  6813. Set forward/backward mode.
  6814. Available modes are:
  6815. @table @samp
  6816. @item forward
  6817. The larger the distance from the central point, the darker the image becomes.
  6818. @item backward
  6819. The larger the distance from the central point, the brighter the image becomes.
  6820. This can be used to reverse a vignette effect, though there is no automatic
  6821. detection to extract the lens @option{angle} and other settings (yet). It can
  6822. also be used to create a burning effect.
  6823. @end table
  6824. Default value is @samp{forward}.
  6825. @item eval
  6826. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  6827. It accepts the following values:
  6828. @table @samp
  6829. @item init
  6830. Evaluate expressions only once during the filter initialization.
  6831. @item frame
  6832. Evaluate expressions for each incoming frame. This is way slower than the
  6833. @samp{init} mode since it requires all the scalers to be re-computed, but it
  6834. allows advanced dynamic expressions.
  6835. @end table
  6836. Default value is @samp{init}.
  6837. @item dither
  6838. Set dithering to reduce the circular banding effects. Default is @code{1}
  6839. (enabled).
  6840. @item aspect
  6841. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  6842. Setting this value to the SAR of the input will make a rectangular vignetting
  6843. following the dimensions of the video.
  6844. Default is @code{1/1}.
  6845. @end table
  6846. @subsection Expressions
  6847. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  6848. following parameters.
  6849. @table @option
  6850. @item w
  6851. @item h
  6852. input width and height
  6853. @item n
  6854. the number of input frame, starting from 0
  6855. @item pts
  6856. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  6857. @var{TB} units, NAN if undefined
  6858. @item r
  6859. frame rate of the input video, NAN if the input frame rate is unknown
  6860. @item t
  6861. the PTS (Presentation TimeStamp) of the filtered video frame,
  6862. expressed in seconds, NAN if undefined
  6863. @item tb
  6864. time base of the input video
  6865. @end table
  6866. @subsection Examples
  6867. @itemize
  6868. @item
  6869. Apply simple strong vignetting effect:
  6870. @example
  6871. vignette=PI/4
  6872. @end example
  6873. @item
  6874. Make a flickering vignetting:
  6875. @example
  6876. vignette='PI/4+random(1)*PI/50':eval=frame
  6877. @end example
  6878. @end itemize
  6879. @section w3fdif
  6880. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  6881. Deinterlacing Filter").
  6882. Based on the process described by Martin Weston for BBC R&D, and
  6883. implemented based on the de-interlace algorithm written by Jim
  6884. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  6885. uses filter coefficients calculated by BBC R&D.
  6886. There are two sets of filter coefficients, so called "simple":
  6887. and "complex". Which set of filter coefficients is used can
  6888. be set by passing an optional parameter:
  6889. @table @option
  6890. @item filter
  6891. Set the interlacing filter coefficients. Accepts one of the following values:
  6892. @table @samp
  6893. @item simple
  6894. Simple filter coefficient set.
  6895. @item complex
  6896. More-complex filter coefficient set.
  6897. @end table
  6898. Default value is @samp{complex}.
  6899. @item deint
  6900. Specify which frames to deinterlace. Accept one of the following values:
  6901. @table @samp
  6902. @item all
  6903. Deinterlace all frames,
  6904. @item interlaced
  6905. Only deinterlace frames marked as interlaced.
  6906. @end table
  6907. Default value is @samp{all}.
  6908. @end table
  6909. @anchor{yadif}
  6910. @section yadif
  6911. Deinterlace the input video ("yadif" means "yet another deinterlacing
  6912. filter").
  6913. It accepts the following parameters:
  6914. @table @option
  6915. @item mode
  6916. The interlacing mode to adopt. It accepts one of the following values:
  6917. @table @option
  6918. @item 0, send_frame
  6919. Output one frame for each frame.
  6920. @item 1, send_field
  6921. Output one frame for each field.
  6922. @item 2, send_frame_nospatial
  6923. Like @code{send_frame}, but it skips the spatial interlacing check.
  6924. @item 3, send_field_nospatial
  6925. Like @code{send_field}, but it skips the spatial interlacing check.
  6926. @end table
  6927. The default value is @code{send_frame}.
  6928. @item parity
  6929. The picture field parity assumed for the input interlaced video. It accepts one
  6930. of the following values:
  6931. @table @option
  6932. @item 0, tff
  6933. Assume the top field is first.
  6934. @item 1, bff
  6935. Assume the bottom field is first.
  6936. @item -1, auto
  6937. Enable automatic detection of field parity.
  6938. @end table
  6939. The default value is @code{auto}.
  6940. If the interlacing is unknown or the decoder does not export this information,
  6941. top field first will be assumed.
  6942. @item deint
  6943. Specify which frames to deinterlace. Accept one of the following
  6944. values:
  6945. @table @option
  6946. @item 0, all
  6947. Deinterlace all frames.
  6948. @item 1, interlaced
  6949. Only deinterlace frames marked as interlaced.
  6950. @end table
  6951. The default value is @code{all}.
  6952. @end table
  6953. @section zoompan
  6954. Apply Zoom & Pan effect.
  6955. This filter accepts the following options:
  6956. @table @option
  6957. @item zoom, z
  6958. Set the zoom expression. Default is 1.
  6959. @item x
  6960. @item y
  6961. Set the x and y expression. Default is 0.
  6962. @item d
  6963. Set the duration expression in number of frames.
  6964. This sets for how many number of frames effect will last for
  6965. single input image.
  6966. @item s
  6967. Set the output image size, default is 'hd720'.
  6968. @end table
  6969. Each expression can contain the following constants:
  6970. @table @option
  6971. @item in_w, iw
  6972. Input width.
  6973. @item in_h, ih
  6974. Input height.
  6975. @item out_w, ow
  6976. Output width.
  6977. @item out_h, oh
  6978. Output height.
  6979. @item in
  6980. Input frame count.
  6981. @item on
  6982. Output frame count.
  6983. @item x
  6984. @item y
  6985. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  6986. for current input frame.
  6987. @item px
  6988. @item py
  6989. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  6990. not yet such frame (first input frame).
  6991. @item zoom
  6992. Last calculated zoom from 'z' expression for current input frame.
  6993. @item pzoom
  6994. Last calculated zoom of last output frame of previous input frame.
  6995. @item duration
  6996. Number of output frames for current input frame. Calculated from 'd' expression
  6997. for each input frame.
  6998. @item pduration
  6999. number of output frames created for previous input frame
  7000. @item a
  7001. Rational number: input width / input height
  7002. @item sar
  7003. sample aspect ratio
  7004. @item dar
  7005. display aspect ratio
  7006. @end table
  7007. @subsection Examples
  7008. @itemize
  7009. @item
  7010. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  7011. @example
  7012. 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
  7013. @end example
  7014. @end itemize
  7015. @c man end VIDEO FILTERS
  7016. @chapter Video Sources
  7017. @c man begin VIDEO SOURCES
  7018. Below is a description of the currently available video sources.
  7019. @section buffer
  7020. Buffer video frames, and make them available to the filter chain.
  7021. This source is mainly intended for a programmatic use, in particular
  7022. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  7023. It accepts the following parameters:
  7024. @table @option
  7025. @item video_size
  7026. Specify the size (width and height) of the buffered video frames. For the
  7027. syntax of this option, check the "Video size" section in the ffmpeg-utils
  7028. manual.
  7029. @item width
  7030. The input video width.
  7031. @item height
  7032. The input video height.
  7033. @item pix_fmt
  7034. A string representing the pixel format of the buffered video frames.
  7035. It may be a number corresponding to a pixel format, or a pixel format
  7036. name.
  7037. @item time_base
  7038. Specify the timebase assumed by the timestamps of the buffered frames.
  7039. @item frame_rate
  7040. Specify the frame rate expected for the video stream.
  7041. @item pixel_aspect, sar
  7042. The sample (pixel) aspect ratio of the input video.
  7043. @item sws_param
  7044. Specify the optional parameters to be used for the scale filter which
  7045. is automatically inserted when an input change is detected in the
  7046. input size or format.
  7047. @end table
  7048. For example:
  7049. @example
  7050. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  7051. @end example
  7052. will instruct the source to accept video frames with size 320x240 and
  7053. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  7054. square pixels (1:1 sample aspect ratio).
  7055. Since the pixel format with name "yuv410p" corresponds to the number 6
  7056. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  7057. this example corresponds to:
  7058. @example
  7059. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  7060. @end example
  7061. Alternatively, the options can be specified as a flat string, but this
  7062. syntax is deprecated:
  7063. @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}]
  7064. @section cellauto
  7065. Create a pattern generated by an elementary cellular automaton.
  7066. The initial state of the cellular automaton can be defined through the
  7067. @option{filename}, and @option{pattern} options. If such options are
  7068. not specified an initial state is created randomly.
  7069. At each new frame a new row in the video is filled with the result of
  7070. the cellular automaton next generation. The behavior when the whole
  7071. frame is filled is defined by the @option{scroll} option.
  7072. This source accepts the following options:
  7073. @table @option
  7074. @item filename, f
  7075. Read the initial cellular automaton state, i.e. the starting row, from
  7076. the specified file.
  7077. In the file, each non-whitespace character is considered an alive
  7078. cell, a newline will terminate the row, and further characters in the
  7079. file will be ignored.
  7080. @item pattern, p
  7081. Read the initial cellular automaton state, i.e. the starting row, from
  7082. the specified string.
  7083. Each non-whitespace character in the string is considered an alive
  7084. cell, a newline will terminate the row, and further characters in the
  7085. string will be ignored.
  7086. @item rate, r
  7087. Set the video rate, that is the number of frames generated per second.
  7088. Default is 25.
  7089. @item random_fill_ratio, ratio
  7090. Set the random fill ratio for the initial cellular automaton row. It
  7091. is a floating point number value ranging from 0 to 1, defaults to
  7092. 1/PHI.
  7093. This option is ignored when a file or a pattern is specified.
  7094. @item random_seed, seed
  7095. Set the seed for filling randomly the initial row, must be an integer
  7096. included between 0 and UINT32_MAX. If not specified, or if explicitly
  7097. set to -1, the filter will try to use a good random seed on a best
  7098. effort basis.
  7099. @item rule
  7100. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  7101. Default value is 110.
  7102. @item size, s
  7103. Set the size of the output video. For the syntax of this option, check
  7104. the "Video size" section in the ffmpeg-utils manual.
  7105. If @option{filename} or @option{pattern} is specified, the size is set
  7106. by default to the width of the specified initial state row, and the
  7107. height is set to @var{width} * PHI.
  7108. If @option{size} is set, it must contain the width of the specified
  7109. pattern string, and the specified pattern will be centered in the
  7110. larger row.
  7111. If a filename or a pattern string is not specified, the size value
  7112. defaults to "320x518" (used for a randomly generated initial state).
  7113. @item scroll
  7114. If set to 1, scroll the output upward when all the rows in the output
  7115. have been already filled. If set to 0, the new generated row will be
  7116. written over the top row just after the bottom row is filled.
  7117. Defaults to 1.
  7118. @item start_full, full
  7119. If set to 1, completely fill the output with generated rows before
  7120. outputting the first frame.
  7121. This is the default behavior, for disabling set the value to 0.
  7122. @item stitch
  7123. If set to 1, stitch the left and right row edges together.
  7124. This is the default behavior, for disabling set the value to 0.
  7125. @end table
  7126. @subsection Examples
  7127. @itemize
  7128. @item
  7129. Read the initial state from @file{pattern}, and specify an output of
  7130. size 200x400.
  7131. @example
  7132. cellauto=f=pattern:s=200x400
  7133. @end example
  7134. @item
  7135. Generate a random initial row with a width of 200 cells, with a fill
  7136. ratio of 2/3:
  7137. @example
  7138. cellauto=ratio=2/3:s=200x200
  7139. @end example
  7140. @item
  7141. Create a pattern generated by rule 18 starting by a single alive cell
  7142. centered on an initial row with width 100:
  7143. @example
  7144. cellauto=p=@@:s=100x400:full=0:rule=18
  7145. @end example
  7146. @item
  7147. Specify a more elaborated initial pattern:
  7148. @example
  7149. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  7150. @end example
  7151. @end itemize
  7152. @section mandelbrot
  7153. Generate a Mandelbrot set fractal, and progressively zoom towards the
  7154. point specified with @var{start_x} and @var{start_y}.
  7155. This source accepts the following options:
  7156. @table @option
  7157. @item end_pts
  7158. Set the terminal pts value. Default value is 400.
  7159. @item end_scale
  7160. Set the terminal scale value.
  7161. Must be a floating point value. Default value is 0.3.
  7162. @item inner
  7163. Set the inner coloring mode, that is the algorithm used to draw the
  7164. Mandelbrot fractal internal region.
  7165. It shall assume one of the following values:
  7166. @table @option
  7167. @item black
  7168. Set black mode.
  7169. @item convergence
  7170. Show time until convergence.
  7171. @item mincol
  7172. Set color based on point closest to the origin of the iterations.
  7173. @item period
  7174. Set period mode.
  7175. @end table
  7176. Default value is @var{mincol}.
  7177. @item bailout
  7178. Set the bailout value. Default value is 10.0.
  7179. @item maxiter
  7180. Set the maximum of iterations performed by the rendering
  7181. algorithm. Default value is 7189.
  7182. @item outer
  7183. Set outer coloring mode.
  7184. It shall assume one of following values:
  7185. @table @option
  7186. @item iteration_count
  7187. Set iteration cound mode.
  7188. @item normalized_iteration_count
  7189. set normalized iteration count mode.
  7190. @end table
  7191. Default value is @var{normalized_iteration_count}.
  7192. @item rate, r
  7193. Set frame rate, expressed as number of frames per second. Default
  7194. value is "25".
  7195. @item size, s
  7196. Set frame size. For the syntax of this option, check the "Video
  7197. size" section in the ffmpeg-utils manual. Default value is "640x480".
  7198. @item start_scale
  7199. Set the initial scale value. Default value is 3.0.
  7200. @item start_x
  7201. Set the initial x position. Must be a floating point value between
  7202. -100 and 100. Default value is -0.743643887037158704752191506114774.
  7203. @item start_y
  7204. Set the initial y position. Must be a floating point value between
  7205. -100 and 100. Default value is -0.131825904205311970493132056385139.
  7206. @end table
  7207. @section mptestsrc
  7208. Generate various test patterns, as generated by the MPlayer test filter.
  7209. The size of the generated video is fixed, and is 256x256.
  7210. This source is useful in particular for testing encoding features.
  7211. This source accepts the following options:
  7212. @table @option
  7213. @item rate, r
  7214. Specify the frame rate of the sourced video, as the number of frames
  7215. generated per second. It has to be a string in the format
  7216. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  7217. number or a valid video frame rate abbreviation. The default value is
  7218. "25".
  7219. @item duration, d
  7220. Set the video duration of the sourced video. The accepted syntax is:
  7221. @example
  7222. [-]HH:MM:SS[.m...]
  7223. [-]S+[.m...]
  7224. @end example
  7225. See also the function @code{av_parse_time()}.
  7226. If not specified, or the expressed duration is negative, the video is
  7227. supposed to be generated forever.
  7228. @item test, t
  7229. Set the number or the name of the test to perform. Supported tests are:
  7230. @table @option
  7231. @item dc_luma
  7232. @item dc_chroma
  7233. @item freq_luma
  7234. @item freq_chroma
  7235. @item amp_luma
  7236. @item amp_chroma
  7237. @item cbp
  7238. @item mv
  7239. @item ring1
  7240. @item ring2
  7241. @item all
  7242. @end table
  7243. Default value is "all", which will cycle through the list of all tests.
  7244. @end table
  7245. Some examples:
  7246. @example
  7247. testsrc=t=dc_luma
  7248. @end example
  7249. will generate a "dc_luma" test pattern.
  7250. @section frei0r_src
  7251. Provide a frei0r source.
  7252. To enable compilation of this filter you need to install the frei0r
  7253. header and configure FFmpeg with @code{--enable-frei0r}.
  7254. This source accepts the following parameters:
  7255. @table @option
  7256. @item size
  7257. The size of the video to generate. For the syntax of this option, check the
  7258. "Video size" section in the ffmpeg-utils manual.
  7259. @item framerate
  7260. The framerate of the generated video. It may be a string of the form
  7261. @var{num}/@var{den} or a frame rate abbreviation.
  7262. @item filter_name
  7263. The name to the frei0r source to load. For more information regarding frei0r and
  7264. how to set the parameters, read the @ref{frei0r} section in the video filters
  7265. documentation.
  7266. @item filter_params
  7267. A '|'-separated list of parameters to pass to the frei0r source.
  7268. @end table
  7269. For example, to generate a frei0r partik0l source with size 200x200
  7270. and frame rate 10 which is overlayed on the overlay filter main input:
  7271. @example
  7272. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  7273. @end example
  7274. @section life
  7275. Generate a life pattern.
  7276. This source is based on a generalization of John Conway's life game.
  7277. The sourced input represents a life grid, each pixel represents a cell
  7278. which can be in one of two possible states, alive or dead. Every cell
  7279. interacts with its eight neighbours, which are the cells that are
  7280. horizontally, vertically, or diagonally adjacent.
  7281. At each interaction the grid evolves according to the adopted rule,
  7282. which specifies the number of neighbor alive cells which will make a
  7283. cell stay alive or born. The @option{rule} option allows one to specify
  7284. the rule to adopt.
  7285. This source accepts the following options:
  7286. @table @option
  7287. @item filename, f
  7288. Set the file from which to read the initial grid state. In the file,
  7289. each non-whitespace character is considered an alive cell, and newline
  7290. is used to delimit the end of each row.
  7291. If this option is not specified, the initial grid is generated
  7292. randomly.
  7293. @item rate, r
  7294. Set the video rate, that is the number of frames generated per second.
  7295. Default is 25.
  7296. @item random_fill_ratio, ratio
  7297. Set the random fill ratio for the initial random grid. It is a
  7298. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  7299. It is ignored when a file is specified.
  7300. @item random_seed, seed
  7301. Set the seed for filling the initial random grid, must be an integer
  7302. included between 0 and UINT32_MAX. If not specified, or if explicitly
  7303. set to -1, the filter will try to use a good random seed on a best
  7304. effort basis.
  7305. @item rule
  7306. Set the life rule.
  7307. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  7308. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  7309. @var{NS} specifies the number of alive neighbor cells which make a
  7310. live cell stay alive, and @var{NB} the number of alive neighbor cells
  7311. which make a dead cell to become alive (i.e. to "born").
  7312. "s" and "b" can be used in place of "S" and "B", respectively.
  7313. Alternatively a rule can be specified by an 18-bits integer. The 9
  7314. high order bits are used to encode the next cell state if it is alive
  7315. for each number of neighbor alive cells, the low order bits specify
  7316. the rule for "borning" new cells. Higher order bits encode for an
  7317. higher number of neighbor cells.
  7318. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  7319. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  7320. Default value is "S23/B3", which is the original Conway's game of life
  7321. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  7322. cells, and will born a new cell if there are three alive cells around
  7323. a dead cell.
  7324. @item size, s
  7325. Set the size of the output video. For the syntax of this option, check the
  7326. "Video size" section in the ffmpeg-utils manual.
  7327. If @option{filename} is specified, the size is set by default to the
  7328. same size of the input file. If @option{size} is set, it must contain
  7329. the size specified in the input file, and the initial grid defined in
  7330. that file is centered in the larger resulting area.
  7331. If a filename is not specified, the size value defaults to "320x240"
  7332. (used for a randomly generated initial grid).
  7333. @item stitch
  7334. If set to 1, stitch the left and right grid edges together, and the
  7335. top and bottom edges also. Defaults to 1.
  7336. @item mold
  7337. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  7338. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  7339. value from 0 to 255.
  7340. @item life_color
  7341. Set the color of living (or new born) cells.
  7342. @item death_color
  7343. Set the color of dead cells. If @option{mold} is set, this is the first color
  7344. used to represent a dead cell.
  7345. @item mold_color
  7346. Set mold color, for definitely dead and moldy cells.
  7347. For the syntax of these 3 color options, check the "Color" section in the
  7348. ffmpeg-utils manual.
  7349. @end table
  7350. @subsection Examples
  7351. @itemize
  7352. @item
  7353. Read a grid from @file{pattern}, and center it on a grid of size
  7354. 300x300 pixels:
  7355. @example
  7356. life=f=pattern:s=300x300
  7357. @end example
  7358. @item
  7359. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  7360. @example
  7361. life=ratio=2/3:s=200x200
  7362. @end example
  7363. @item
  7364. Specify a custom rule for evolving a randomly generated grid:
  7365. @example
  7366. life=rule=S14/B34
  7367. @end example
  7368. @item
  7369. Full example with slow death effect (mold) using @command{ffplay}:
  7370. @example
  7371. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  7372. @end example
  7373. @end itemize
  7374. @anchor{color}
  7375. @anchor{haldclutsrc}
  7376. @anchor{nullsrc}
  7377. @anchor{rgbtestsrc}
  7378. @anchor{smptebars}
  7379. @anchor{smptehdbars}
  7380. @anchor{testsrc}
  7381. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  7382. The @code{color} source provides an uniformly colored input.
  7383. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  7384. @ref{haldclut} filter.
  7385. The @code{nullsrc} source returns unprocessed video frames. It is
  7386. mainly useful to be employed in analysis / debugging tools, or as the
  7387. source for filters which ignore the input data.
  7388. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  7389. detecting RGB vs BGR issues. You should see a red, green and blue
  7390. stripe from top to bottom.
  7391. The @code{smptebars} source generates a color bars pattern, based on
  7392. the SMPTE Engineering Guideline EG 1-1990.
  7393. The @code{smptehdbars} source generates a color bars pattern, based on
  7394. the SMPTE RP 219-2002.
  7395. The @code{testsrc} source generates a test video pattern, showing a
  7396. color pattern, a scrolling gradient and a timestamp. This is mainly
  7397. intended for testing purposes.
  7398. The sources accept the following parameters:
  7399. @table @option
  7400. @item color, c
  7401. Specify the color of the source, only available in the @code{color}
  7402. source. For the syntax of this option, check the "Color" section in the
  7403. ffmpeg-utils manual.
  7404. @item level
  7405. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  7406. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  7407. pixels to be used as identity matrix for 3D lookup tables. Each component is
  7408. coded on a @code{1/(N*N)} scale.
  7409. @item size, s
  7410. Specify the size of the sourced video. For the syntax of this option, check the
  7411. "Video size" section in the ffmpeg-utils manual. The default value is
  7412. "320x240".
  7413. This option is not available with the @code{haldclutsrc} filter.
  7414. @item rate, r
  7415. Specify the frame rate of the sourced video, as the number of frames
  7416. generated per second. It has to be a string in the format
  7417. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  7418. number or a valid video frame rate abbreviation. The default value is
  7419. "25".
  7420. @item sar
  7421. Set the sample aspect ratio of the sourced video.
  7422. @item duration, d
  7423. Set the video duration of the sourced video. The accepted syntax is:
  7424. @example
  7425. [-]HH[:MM[:SS[.m...]]]
  7426. [-]S+[.m...]
  7427. @end example
  7428. Also see the the @code{av_parse_time()} function.
  7429. If not specified, or the expressed duration is negative, the video is
  7430. supposed to be generated forever.
  7431. @item decimals, n
  7432. Set the number of decimals to show in the timestamp, only available in the
  7433. @code{testsrc} source.
  7434. The displayed timestamp value will correspond to the original
  7435. timestamp value multiplied by the power of 10 of the specified
  7436. value. Default value is 0.
  7437. @end table
  7438. For example the following:
  7439. @example
  7440. testsrc=duration=5.3:size=qcif:rate=10
  7441. @end example
  7442. will generate a video with a duration of 5.3 seconds, with size
  7443. 176x144 and a frame rate of 10 frames per second.
  7444. The following graph description will generate a red source
  7445. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  7446. frames per second.
  7447. @example
  7448. color=c=red@@0.2:s=qcif:r=10
  7449. @end example
  7450. If the input content is to be ignored, @code{nullsrc} can be used. The
  7451. following command generates noise in the luminance plane by employing
  7452. the @code{geq} filter:
  7453. @example
  7454. nullsrc=s=256x256, geq=random(1)*255:128:128
  7455. @end example
  7456. @subsection Commands
  7457. The @code{color} source supports the following commands:
  7458. @table @option
  7459. @item c, color
  7460. Set the color of the created image. Accepts the same syntax of the
  7461. corresponding @option{color} option.
  7462. @end table
  7463. @c man end VIDEO SOURCES
  7464. @chapter Video Sinks
  7465. @c man begin VIDEO SINKS
  7466. Below is a description of the currently available video sinks.
  7467. @section buffersink
  7468. Buffer video frames, and make them available to the end of the filter
  7469. graph.
  7470. This sink is mainly intended for programmatic use, in particular
  7471. through the interface defined in @file{libavfilter/buffersink.h}
  7472. or the options system.
  7473. It accepts a pointer to an AVBufferSinkContext structure, which
  7474. defines the incoming buffers' formats, to be passed as the opaque
  7475. parameter to @code{avfilter_init_filter} for initialization.
  7476. @section nullsink
  7477. Null video sink: do absolutely nothing with the input video. It is
  7478. mainly useful as a template and for use in analysis / debugging
  7479. tools.
  7480. @c man end VIDEO SINKS
  7481. @chapter Multimedia Filters
  7482. @c man begin MULTIMEDIA FILTERS
  7483. Below is a description of the currently available multimedia filters.
  7484. @section avectorscope
  7485. Convert input audio to a video output, representing the audio vector
  7486. scope.
  7487. The filter is used to measure the difference between channels of stereo
  7488. audio stream. A monoaural signal, consisting of identical left and right
  7489. signal, results in straight vertical line. Any stereo separation is visible
  7490. as a deviation from this line, creating a Lissajous figure.
  7491. If the straight (or deviation from it) but horizontal line appears this
  7492. indicates that the left and right channels are out of phase.
  7493. The filter accepts the following options:
  7494. @table @option
  7495. @item mode, m
  7496. Set the vectorscope mode.
  7497. Available values are:
  7498. @table @samp
  7499. @item lissajous
  7500. Lissajous rotated by 45 degrees.
  7501. @item lissajous_xy
  7502. Same as above but not rotated.
  7503. @end table
  7504. Default value is @samp{lissajous}.
  7505. @item size, s
  7506. Set the video size for the output. For the syntax of this option, check the "Video size"
  7507. section in the ffmpeg-utils manual. Default value is @code{400x400}.
  7508. @item rate, r
  7509. Set the output frame rate. Default value is @code{25}.
  7510. @item rc
  7511. @item gc
  7512. @item bc
  7513. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  7514. Allowed range is @code{[0, 255]}.
  7515. @item rf
  7516. @item gf
  7517. @item bf
  7518. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  7519. Allowed range is @code{[0, 255]}.
  7520. @item zoom
  7521. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  7522. @end table
  7523. @subsection Examples
  7524. @itemize
  7525. @item
  7526. Complete example using @command{ffplay}:
  7527. @example
  7528. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  7529. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  7530. @end example
  7531. @end itemize
  7532. @section concat
  7533. Concatenate audio and video streams, joining them together one after the
  7534. other.
  7535. The filter works on segments of synchronized video and audio streams. All
  7536. segments must have the same number of streams of each type, and that will
  7537. also be the number of streams at output.
  7538. The filter accepts the following options:
  7539. @table @option
  7540. @item n
  7541. Set the number of segments. Default is 2.
  7542. @item v
  7543. Set the number of output video streams, that is also the number of video
  7544. streams in each segment. Default is 1.
  7545. @item a
  7546. Set the number of output audio streams, that is also the number of audio
  7547. streams in each segment. Default is 0.
  7548. @item unsafe
  7549. Activate unsafe mode: do not fail if segments have a different format.
  7550. @end table
  7551. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  7552. @var{a} audio outputs.
  7553. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  7554. segment, in the same order as the outputs, then the inputs for the second
  7555. segment, etc.
  7556. Related streams do not always have exactly the same duration, for various
  7557. reasons including codec frame size or sloppy authoring. For that reason,
  7558. related synchronized streams (e.g. a video and its audio track) should be
  7559. concatenated at once. The concat filter will use the duration of the longest
  7560. stream in each segment (except the last one), and if necessary pad shorter
  7561. audio streams with silence.
  7562. For this filter to work correctly, all segments must start at timestamp 0.
  7563. All corresponding streams must have the same parameters in all segments; the
  7564. filtering system will automatically select a common pixel format for video
  7565. streams, and a common sample format, sample rate and channel layout for
  7566. audio streams, but other settings, such as resolution, must be converted
  7567. explicitly by the user.
  7568. Different frame rates are acceptable but will result in variable frame rate
  7569. at output; be sure to configure the output file to handle it.
  7570. @subsection Examples
  7571. @itemize
  7572. @item
  7573. Concatenate an opening, an episode and an ending, all in bilingual version
  7574. (video in stream 0, audio in streams 1 and 2):
  7575. @example
  7576. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  7577. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  7578. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  7579. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  7580. @end example
  7581. @item
  7582. Concatenate two parts, handling audio and video separately, using the
  7583. (a)movie sources, and adjusting the resolution:
  7584. @example
  7585. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  7586. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  7587. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  7588. @end example
  7589. Note that a desync will happen at the stitch if the audio and video streams
  7590. do not have exactly the same duration in the first file.
  7591. @end itemize
  7592. @section ebur128
  7593. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  7594. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  7595. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  7596. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  7597. The filter also has a video output (see the @var{video} option) with a real
  7598. time graph to observe the loudness evolution. The graphic contains the logged
  7599. message mentioned above, so it is not printed anymore when this option is set,
  7600. unless the verbose logging is set. The main graphing area contains the
  7601. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  7602. the momentary loudness (400 milliseconds).
  7603. More information about the Loudness Recommendation EBU R128 on
  7604. @url{http://tech.ebu.ch/loudness}.
  7605. The filter accepts the following options:
  7606. @table @option
  7607. @item video
  7608. Activate the video output. The audio stream is passed unchanged whether this
  7609. option is set or no. The video stream will be the first output stream if
  7610. activated. Default is @code{0}.
  7611. @item size
  7612. Set the video size. This option is for video only. For the syntax of this
  7613. option, check the "Video size" section in the ffmpeg-utils manual. Default
  7614. and minimum resolution is @code{640x480}.
  7615. @item meter
  7616. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  7617. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  7618. other integer value between this range is allowed.
  7619. @item metadata
  7620. Set metadata injection. If set to @code{1}, the audio input will be segmented
  7621. into 100ms output frames, each of them containing various loudness information
  7622. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  7623. Default is @code{0}.
  7624. @item framelog
  7625. Force the frame logging level.
  7626. Available values are:
  7627. @table @samp
  7628. @item info
  7629. information logging level
  7630. @item verbose
  7631. verbose logging level
  7632. @end table
  7633. By default, the logging level is set to @var{info}. If the @option{video} or
  7634. the @option{metadata} options are set, it switches to @var{verbose}.
  7635. @item peak
  7636. Set peak mode(s).
  7637. Available modes can be cumulated (the option is a @code{flag} type). Possible
  7638. values are:
  7639. @table @samp
  7640. @item none
  7641. Disable any peak mode (default).
  7642. @item sample
  7643. Enable sample-peak mode.
  7644. Simple peak mode looking for the higher sample value. It logs a message
  7645. for sample-peak (identified by @code{SPK}).
  7646. @item true
  7647. Enable true-peak mode.
  7648. If enabled, the peak lookup is done on an over-sampled version of the input
  7649. stream for better peak accuracy. It logs a message for true-peak.
  7650. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  7651. This mode requires a build with @code{libswresample}.
  7652. @end table
  7653. @end table
  7654. @subsection Examples
  7655. @itemize
  7656. @item
  7657. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  7658. @example
  7659. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  7660. @end example
  7661. @item
  7662. Run an analysis with @command{ffmpeg}:
  7663. @example
  7664. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  7665. @end example
  7666. @end itemize
  7667. @section interleave, ainterleave
  7668. Temporally interleave frames from several inputs.
  7669. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  7670. These filters read frames from several inputs and send the oldest
  7671. queued frame to the output.
  7672. Input streams must have a well defined, monotonically increasing frame
  7673. timestamp values.
  7674. In order to submit one frame to output, these filters need to enqueue
  7675. at least one frame for each input, so they cannot work in case one
  7676. input is not yet terminated and will not receive incoming frames.
  7677. For example consider the case when one input is a @code{select} filter
  7678. which always drop input frames. The @code{interleave} filter will keep
  7679. reading from that input, but it will never be able to send new frames
  7680. to output until the input will send an end-of-stream signal.
  7681. Also, depending on inputs synchronization, the filters will drop
  7682. frames in case one input receives more frames than the other ones, and
  7683. the queue is already filled.
  7684. These filters accept the following options:
  7685. @table @option
  7686. @item nb_inputs, n
  7687. Set the number of different inputs, it is 2 by default.
  7688. @end table
  7689. @subsection Examples
  7690. @itemize
  7691. @item
  7692. Interleave frames belonging to different streams using @command{ffmpeg}:
  7693. @example
  7694. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  7695. @end example
  7696. @item
  7697. Add flickering blur effect:
  7698. @example
  7699. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  7700. @end example
  7701. @end itemize
  7702. @section perms, aperms
  7703. Set read/write permissions for the output frames.
  7704. These filters are mainly aimed at developers to test direct path in the
  7705. following filter in the filtergraph.
  7706. The filters accept the following options:
  7707. @table @option
  7708. @item mode
  7709. Select the permissions mode.
  7710. It accepts the following values:
  7711. @table @samp
  7712. @item none
  7713. Do nothing. This is the default.
  7714. @item ro
  7715. Set all the output frames read-only.
  7716. @item rw
  7717. Set all the output frames directly writable.
  7718. @item toggle
  7719. Make the frame read-only if writable, and writable if read-only.
  7720. @item random
  7721. Set each output frame read-only or writable randomly.
  7722. @end table
  7723. @item seed
  7724. Set the seed for the @var{random} mode, must be an integer included between
  7725. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7726. @code{-1}, the filter will try to use a good random seed on a best effort
  7727. basis.
  7728. @end table
  7729. Note: in case of auto-inserted filter between the permission filter and the
  7730. following one, the permission might not be received as expected in that
  7731. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  7732. perms/aperms filter can avoid this problem.
  7733. @section select, aselect
  7734. Select frames to pass in output.
  7735. This filter accepts the following options:
  7736. @table @option
  7737. @item expr, e
  7738. Set expression, which is evaluated for each input frame.
  7739. If the expression is evaluated to zero, the frame is discarded.
  7740. If the evaluation result is negative or NaN, the frame is sent to the
  7741. first output; otherwise it is sent to the output with index
  7742. @code{ceil(val)-1}, assuming that the input index starts from 0.
  7743. For example a value of @code{1.2} corresponds to the output with index
  7744. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  7745. @item outputs, n
  7746. Set the number of outputs. The output to which to send the selected
  7747. frame is based on the result of the evaluation. Default value is 1.
  7748. @end table
  7749. The expression can contain the following constants:
  7750. @table @option
  7751. @item n
  7752. The (sequential) number of the filtered frame, starting from 0.
  7753. @item selected_n
  7754. The (sequential) number of the selected frame, starting from 0.
  7755. @item prev_selected_n
  7756. The sequential number of the last selected frame. It's NAN if undefined.
  7757. @item TB
  7758. The timebase of the input timestamps.
  7759. @item pts
  7760. The PTS (Presentation TimeStamp) of the filtered video frame,
  7761. expressed in @var{TB} units. It's NAN if undefined.
  7762. @item t
  7763. The PTS of the filtered video frame,
  7764. expressed in seconds. It's NAN if undefined.
  7765. @item prev_pts
  7766. The PTS of the previously filtered video frame. It's NAN if undefined.
  7767. @item prev_selected_pts
  7768. The PTS of the last previously filtered video frame. It's NAN if undefined.
  7769. @item prev_selected_t
  7770. The PTS of the last previously selected video frame. It's NAN if undefined.
  7771. @item start_pts
  7772. The PTS of the first video frame in the video. It's NAN if undefined.
  7773. @item start_t
  7774. The time of the first video frame in the video. It's NAN if undefined.
  7775. @item pict_type @emph{(video only)}
  7776. The type of the filtered frame. It can assume one of the following
  7777. values:
  7778. @table @option
  7779. @item I
  7780. @item P
  7781. @item B
  7782. @item S
  7783. @item SI
  7784. @item SP
  7785. @item BI
  7786. @end table
  7787. @item interlace_type @emph{(video only)}
  7788. The frame interlace type. It can assume one of the following values:
  7789. @table @option
  7790. @item PROGRESSIVE
  7791. The frame is progressive (not interlaced).
  7792. @item TOPFIRST
  7793. The frame is top-field-first.
  7794. @item BOTTOMFIRST
  7795. The frame is bottom-field-first.
  7796. @end table
  7797. @item consumed_sample_n @emph{(audio only)}
  7798. the number of selected samples before the current frame
  7799. @item samples_n @emph{(audio only)}
  7800. the number of samples in the current frame
  7801. @item sample_rate @emph{(audio only)}
  7802. the input sample rate
  7803. @item key
  7804. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  7805. @item pos
  7806. the position in the file of the filtered frame, -1 if the information
  7807. is not available (e.g. for synthetic video)
  7808. @item scene @emph{(video only)}
  7809. value between 0 and 1 to indicate a new scene; a low value reflects a low
  7810. probability for the current frame to introduce a new scene, while a higher
  7811. value means the current frame is more likely to be one (see the example below)
  7812. @end table
  7813. The default value of the select expression is "1".
  7814. @subsection Examples
  7815. @itemize
  7816. @item
  7817. Select all frames in input:
  7818. @example
  7819. select
  7820. @end example
  7821. The example above is the same as:
  7822. @example
  7823. select=1
  7824. @end example
  7825. @item
  7826. Skip all frames:
  7827. @example
  7828. select=0
  7829. @end example
  7830. @item
  7831. Select only I-frames:
  7832. @example
  7833. select='eq(pict_type\,I)'
  7834. @end example
  7835. @item
  7836. Select one frame every 100:
  7837. @example
  7838. select='not(mod(n\,100))'
  7839. @end example
  7840. @item
  7841. Select only frames contained in the 10-20 time interval:
  7842. @example
  7843. select=between(t\,10\,20)
  7844. @end example
  7845. @item
  7846. Select only I frames contained in the 10-20 time interval:
  7847. @example
  7848. select=between(t\,10\,20)*eq(pict_type\,I)
  7849. @end example
  7850. @item
  7851. Select frames with a minimum distance of 10 seconds:
  7852. @example
  7853. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  7854. @end example
  7855. @item
  7856. Use aselect to select only audio frames with samples number > 100:
  7857. @example
  7858. aselect='gt(samples_n\,100)'
  7859. @end example
  7860. @item
  7861. Create a mosaic of the first scenes:
  7862. @example
  7863. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  7864. @end example
  7865. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  7866. choice.
  7867. @item
  7868. Send even and odd frames to separate outputs, and compose them:
  7869. @example
  7870. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  7871. @end example
  7872. @end itemize
  7873. @section sendcmd, asendcmd
  7874. Send commands to filters in the filtergraph.
  7875. These filters read commands to be sent to other filters in the
  7876. filtergraph.
  7877. @code{sendcmd} must be inserted between two video filters,
  7878. @code{asendcmd} must be inserted between two audio filters, but apart
  7879. from that they act the same way.
  7880. The specification of commands can be provided in the filter arguments
  7881. with the @var{commands} option, or in a file specified by the
  7882. @var{filename} option.
  7883. These filters accept the following options:
  7884. @table @option
  7885. @item commands, c
  7886. Set the commands to be read and sent to the other filters.
  7887. @item filename, f
  7888. Set the filename of the commands to be read and sent to the other
  7889. filters.
  7890. @end table
  7891. @subsection Commands syntax
  7892. A commands description consists of a sequence of interval
  7893. specifications, comprising a list of commands to be executed when a
  7894. particular event related to that interval occurs. The occurring event
  7895. is typically the current frame time entering or leaving a given time
  7896. interval.
  7897. An interval is specified by the following syntax:
  7898. @example
  7899. @var{START}[-@var{END}] @var{COMMANDS};
  7900. @end example
  7901. The time interval is specified by the @var{START} and @var{END} times.
  7902. @var{END} is optional and defaults to the maximum time.
  7903. The current frame time is considered within the specified interval if
  7904. it is included in the interval [@var{START}, @var{END}), that is when
  7905. the time is greater or equal to @var{START} and is lesser than
  7906. @var{END}.
  7907. @var{COMMANDS} consists of a sequence of one or more command
  7908. specifications, separated by ",", relating to that interval. The
  7909. syntax of a command specification is given by:
  7910. @example
  7911. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  7912. @end example
  7913. @var{FLAGS} is optional and specifies the type of events relating to
  7914. the time interval which enable sending the specified command, and must
  7915. be a non-null sequence of identifier flags separated by "+" or "|" and
  7916. enclosed between "[" and "]".
  7917. The following flags are recognized:
  7918. @table @option
  7919. @item enter
  7920. The command is sent when the current frame timestamp enters the
  7921. specified interval. In other words, the command is sent when the
  7922. previous frame timestamp was not in the given interval, and the
  7923. current is.
  7924. @item leave
  7925. The command is sent when the current frame timestamp leaves the
  7926. specified interval. In other words, the command is sent when the
  7927. previous frame timestamp was in the given interval, and the
  7928. current is not.
  7929. @end table
  7930. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  7931. assumed.
  7932. @var{TARGET} specifies the target of the command, usually the name of
  7933. the filter class or a specific filter instance name.
  7934. @var{COMMAND} specifies the name of the command for the target filter.
  7935. @var{ARG} is optional and specifies the optional list of argument for
  7936. the given @var{COMMAND}.
  7937. Between one interval specification and another, whitespaces, or
  7938. sequences of characters starting with @code{#} until the end of line,
  7939. are ignored and can be used to annotate comments.
  7940. A simplified BNF description of the commands specification syntax
  7941. follows:
  7942. @example
  7943. @var{COMMAND_FLAG} ::= "enter" | "leave"
  7944. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  7945. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  7946. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  7947. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  7948. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  7949. @end example
  7950. @subsection Examples
  7951. @itemize
  7952. @item
  7953. Specify audio tempo change at second 4:
  7954. @example
  7955. asendcmd=c='4.0 atempo tempo 1.5',atempo
  7956. @end example
  7957. @item
  7958. Specify a list of drawtext and hue commands in a file.
  7959. @example
  7960. # show text in the interval 5-10
  7961. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  7962. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  7963. # desaturate the image in the interval 15-20
  7964. 15.0-20.0 [enter] hue s 0,
  7965. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  7966. [leave] hue s 1,
  7967. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  7968. # apply an exponential saturation fade-out effect, starting from time 25
  7969. 25 [enter] hue s exp(25-t)
  7970. @end example
  7971. A filtergraph allowing to read and process the above command list
  7972. stored in a file @file{test.cmd}, can be specified with:
  7973. @example
  7974. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  7975. @end example
  7976. @end itemize
  7977. @anchor{setpts}
  7978. @section setpts, asetpts
  7979. Change the PTS (presentation timestamp) of the input frames.
  7980. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  7981. This filter accepts the following options:
  7982. @table @option
  7983. @item expr
  7984. The expression which is evaluated for each frame to construct its timestamp.
  7985. @end table
  7986. The expression is evaluated through the eval API and can contain the following
  7987. constants:
  7988. @table @option
  7989. @item FRAME_RATE
  7990. frame rate, only defined for constant frame-rate video
  7991. @item PTS
  7992. The presentation timestamp in input
  7993. @item N
  7994. The count of the input frame for video or the number of consumed samples,
  7995. not including the current frame for audio, starting from 0.
  7996. @item NB_CONSUMED_SAMPLES
  7997. The number of consumed samples, not including the current frame (only
  7998. audio)
  7999. @item NB_SAMPLES, S
  8000. The number of samples in the current frame (only audio)
  8001. @item SAMPLE_RATE, SR
  8002. The audio sample rate.
  8003. @item STARTPTS
  8004. The PTS of the first frame.
  8005. @item STARTT
  8006. the time in seconds of the first frame
  8007. @item INTERLACED
  8008. State whether the current frame is interlaced.
  8009. @item T
  8010. the time in seconds of the current frame
  8011. @item POS
  8012. original position in the file of the frame, or undefined if undefined
  8013. for the current frame
  8014. @item PREV_INPTS
  8015. The previous input PTS.
  8016. @item PREV_INT
  8017. previous input time in seconds
  8018. @item PREV_OUTPTS
  8019. The previous output PTS.
  8020. @item PREV_OUTT
  8021. previous output time in seconds
  8022. @item RTCTIME
  8023. The wallclock (RTC) time in microseconds.. This is deprecated, use time(0)
  8024. instead.
  8025. @item RTCSTART
  8026. The wallclock (RTC) time at the start of the movie in microseconds.
  8027. @item TB
  8028. The timebase of the input timestamps.
  8029. @end table
  8030. @subsection Examples
  8031. @itemize
  8032. @item
  8033. Start counting PTS from zero
  8034. @example
  8035. setpts=PTS-STARTPTS
  8036. @end example
  8037. @item
  8038. Apply fast motion effect:
  8039. @example
  8040. setpts=0.5*PTS
  8041. @end example
  8042. @item
  8043. Apply slow motion effect:
  8044. @example
  8045. setpts=2.0*PTS
  8046. @end example
  8047. @item
  8048. Set fixed rate of 25 frames per second:
  8049. @example
  8050. setpts=N/(25*TB)
  8051. @end example
  8052. @item
  8053. Set fixed rate 25 fps with some jitter:
  8054. @example
  8055. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  8056. @end example
  8057. @item
  8058. Apply an offset of 10 seconds to the input PTS:
  8059. @example
  8060. setpts=PTS+10/TB
  8061. @end example
  8062. @item
  8063. Generate timestamps from a "live source" and rebase onto the current timebase:
  8064. @example
  8065. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  8066. @end example
  8067. @item
  8068. Generate timestamps by counting samples:
  8069. @example
  8070. asetpts=N/SR/TB
  8071. @end example
  8072. @end itemize
  8073. @section settb, asettb
  8074. Set the timebase to use for the output frames timestamps.
  8075. It is mainly useful for testing timebase configuration.
  8076. It accepts the following parameters:
  8077. @table @option
  8078. @item expr, tb
  8079. The expression which is evaluated into the output timebase.
  8080. @end table
  8081. The value for @option{tb} is an arithmetic expression representing a
  8082. rational. The expression can contain the constants "AVTB" (the default
  8083. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  8084. audio only). Default value is "intb".
  8085. @subsection Examples
  8086. @itemize
  8087. @item
  8088. Set the timebase to 1/25:
  8089. @example
  8090. settb=expr=1/25
  8091. @end example
  8092. @item
  8093. Set the timebase to 1/10:
  8094. @example
  8095. settb=expr=0.1
  8096. @end example
  8097. @item
  8098. Set the timebase to 1001/1000:
  8099. @example
  8100. settb=1+0.001
  8101. @end example
  8102. @item
  8103. Set the timebase to 2*intb:
  8104. @example
  8105. settb=2*intb
  8106. @end example
  8107. @item
  8108. Set the default timebase value:
  8109. @example
  8110. settb=AVTB
  8111. @end example
  8112. @end itemize
  8113. @section showcqt
  8114. Convert input audio to a video output representing
  8115. frequency spectrum logarithmically (using constant Q transform with
  8116. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  8117. The filter accepts the following options:
  8118. @table @option
  8119. @item volume
  8120. Specify transform volume (multiplier) expression. The expression can contain
  8121. variables:
  8122. @table @option
  8123. @item frequency, freq, f
  8124. the frequency where transform is evaluated
  8125. @item timeclamp, tc
  8126. value of timeclamp option
  8127. @end table
  8128. and functions:
  8129. @table @option
  8130. @item a_weighting(f)
  8131. A-weighting of equal loudness
  8132. @item b_weighting(f)
  8133. B-weighting of equal loudness
  8134. @item c_weighting(f)
  8135. C-weighting of equal loudness
  8136. @end table
  8137. Default value is @code{16}.
  8138. @item tlength
  8139. Specify transform length expression. The expression can contain variables:
  8140. @table @option
  8141. @item frequency, freq, f
  8142. the frequency where transform is evaluated
  8143. @item timeclamp, tc
  8144. value of timeclamp option
  8145. @end table
  8146. Default value is @code{384/f*tc/(384/f+tc)}.
  8147. @item timeclamp
  8148. Specify the transform timeclamp. At low frequency, there is trade-off between
  8149. accuracy in time domain and frequency domain. If timeclamp is lower,
  8150. event in time domain is represented more accurately (such as fast bass drum),
  8151. otherwise event in frequency domain is represented more accurately
  8152. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  8153. @item coeffclamp
  8154. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  8155. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  8156. Default value is @code{1.0}.
  8157. @item gamma
  8158. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  8159. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  8160. Default value is @code{3.0}.
  8161. @item fontfile
  8162. Specify font file for use with freetype. If not specified, use embedded font.
  8163. @item fontcolor
  8164. Specify font color expression. This is arithmetic expression that should return
  8165. integer value 0xRRGGBB. The expression can contain variables:
  8166. @table @option
  8167. @item frequency, freq, f
  8168. the frequency where transform is evaluated
  8169. @item timeclamp, tc
  8170. value of timeclamp option
  8171. @end table
  8172. and functions:
  8173. @table @option
  8174. @item midi(f)
  8175. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  8176. @item r(x), g(x), b(x)
  8177. red, green, and blue value of intensity x
  8178. @end table
  8179. Default value is @code{st(0, (midi(f)-59.5)/12);
  8180. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  8181. r(1-ld(1)) + b(ld(1))}
  8182. @item fullhd
  8183. If set to 1 (the default), the video size is 1920x1080 (full HD),
  8184. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  8185. @item fps
  8186. Specify video fps. Default value is @code{25}.
  8187. @item count
  8188. Specify number of transform per frame, so there are fps*count transforms
  8189. per second. Note that audio data rate must be divisible by fps*count.
  8190. Default value is @code{6}.
  8191. @end table
  8192. @subsection Examples
  8193. @itemize
  8194. @item
  8195. Playing audio while showing the spectrum:
  8196. @example
  8197. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  8198. @end example
  8199. @item
  8200. Same as above, but with frame rate 30 fps:
  8201. @example
  8202. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  8203. @end example
  8204. @item
  8205. Playing at 960x540 and lower CPU usage:
  8206. @example
  8207. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  8208. @end example
  8209. @item
  8210. A1 and its harmonics: A1, A2, (near)E3, A3:
  8211. @example
  8212. 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),
  8213. asplit[a][out1]; [a] showcqt [out0]'
  8214. @end example
  8215. @item
  8216. Same as above, but with more accuracy in frequency domain (and slower):
  8217. @example
  8218. 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),
  8219. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  8220. @end example
  8221. @item
  8222. B-weighting of equal loudness
  8223. @example
  8224. volume=16*b_weighting(f)
  8225. @end example
  8226. @item
  8227. Lower Q factor
  8228. @example
  8229. tlength=100/f*tc/(100/f+tc)
  8230. @end example
  8231. @item
  8232. Custom fontcolor, C-note is colored green, others are colored blue
  8233. @example
  8234. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  8235. @end example
  8236. @end itemize
  8237. @section showspectrum
  8238. Convert input audio to a video output, representing the audio frequency
  8239. spectrum.
  8240. The filter accepts the following options:
  8241. @table @option
  8242. @item size, s
  8243. Specify the video size for the output. For the syntax of this option, check
  8244. the "Video size" section in the ffmpeg-utils manual. Default value is
  8245. @code{640x512}.
  8246. @item slide
  8247. Specify how the spectrum should slide along the window.
  8248. It accepts the following values:
  8249. @table @samp
  8250. @item replace
  8251. the samples start again on the left when they reach the right
  8252. @item scroll
  8253. the samples scroll from right to left
  8254. @item fullframe
  8255. frames are only produced when the samples reach the right
  8256. @end table
  8257. Default value is @code{replace}.
  8258. @item mode
  8259. Specify display mode.
  8260. It accepts the following values:
  8261. @table @samp
  8262. @item combined
  8263. all channels are displayed in the same row
  8264. @item separate
  8265. all channels are displayed in separate rows
  8266. @end table
  8267. Default value is @samp{combined}.
  8268. @item color
  8269. Specify display color mode.
  8270. It accepts the following values:
  8271. @table @samp
  8272. @item channel
  8273. each channel is displayed in a separate color
  8274. @item intensity
  8275. each channel is is displayed using the same color scheme
  8276. @end table
  8277. Default value is @samp{channel}.
  8278. @item scale
  8279. Specify scale used for calculating intensity color values.
  8280. It accepts the following values:
  8281. @table @samp
  8282. @item lin
  8283. linear
  8284. @item sqrt
  8285. square root, default
  8286. @item cbrt
  8287. cubic root
  8288. @item log
  8289. logarithmic
  8290. @end table
  8291. Default value is @samp{sqrt}.
  8292. @item saturation
  8293. Set saturation modifier for displayed colors. Negative values provide
  8294. alternative color scheme. @code{0} is no saturation at all.
  8295. Saturation must be in [-10.0, 10.0] range.
  8296. Default value is @code{1}.
  8297. @item win_func
  8298. Set window function.
  8299. It accepts the following values:
  8300. @table @samp
  8301. @item none
  8302. No samples pre-processing (do not expect this to be faster)
  8303. @item hann
  8304. Hann window
  8305. @item hamming
  8306. Hamming window
  8307. @item blackman
  8308. Blackman window
  8309. @end table
  8310. Default value is @code{hann}.
  8311. @end table
  8312. The usage is very similar to the showwaves filter; see the examples in that
  8313. section.
  8314. @subsection Examples
  8315. @itemize
  8316. @item
  8317. Large window with logarithmic color scaling:
  8318. @example
  8319. showspectrum=s=1280x480:scale=log
  8320. @end example
  8321. @item
  8322. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  8323. @example
  8324. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  8325. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  8326. @end example
  8327. @end itemize
  8328. @section showwaves
  8329. Convert input audio to a video output, representing the samples waves.
  8330. The filter accepts the following options:
  8331. @table @option
  8332. @item size, s
  8333. Specify the video size for the output. For the syntax of this option, check
  8334. the "Video size" section in the ffmpeg-utils manual. Default value
  8335. is "600x240".
  8336. @item mode
  8337. Set display mode.
  8338. Available values are:
  8339. @table @samp
  8340. @item point
  8341. Draw a point for each sample.
  8342. @item line
  8343. Draw a vertical line for each sample.
  8344. @item p2p
  8345. Draw a point for each sample and a line between them.
  8346. @item cline
  8347. Draw a centered vertical line for each sample.
  8348. @end table
  8349. Default value is @code{point}.
  8350. @item n
  8351. Set the number of samples which are printed on the same column. A
  8352. larger value will decrease the frame rate. Must be a positive
  8353. integer. This option can be set only if the value for @var{rate}
  8354. is not explicitly specified.
  8355. @item rate, r
  8356. Set the (approximate) output frame rate. This is done by setting the
  8357. option @var{n}. Default value is "25".
  8358. @item split_channels
  8359. Set if channels should be drawn separately or overlap. Default value is 0.
  8360. @end table
  8361. @subsection Examples
  8362. @itemize
  8363. @item
  8364. Output the input file audio and the corresponding video representation
  8365. at the same time:
  8366. @example
  8367. amovie=a.mp3,asplit[out0],showwaves[out1]
  8368. @end example
  8369. @item
  8370. Create a synthetic signal and show it with showwaves, forcing a
  8371. frame rate of 30 frames per second:
  8372. @example
  8373. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  8374. @end example
  8375. @end itemize
  8376. @section split, asplit
  8377. Split input into several identical outputs.
  8378. @code{asplit} works with audio input, @code{split} with video.
  8379. The filter accepts a single parameter which specifies the number of outputs. If
  8380. unspecified, it defaults to 2.
  8381. @subsection Examples
  8382. @itemize
  8383. @item
  8384. Create two separate outputs from the same input:
  8385. @example
  8386. [in] split [out0][out1]
  8387. @end example
  8388. @item
  8389. To create 3 or more outputs, you need to specify the number of
  8390. outputs, like in:
  8391. @example
  8392. [in] asplit=3 [out0][out1][out2]
  8393. @end example
  8394. @item
  8395. Create two separate outputs from the same input, one cropped and
  8396. one padded:
  8397. @example
  8398. [in] split [splitout1][splitout2];
  8399. [splitout1] crop=100:100:0:0 [cropout];
  8400. [splitout2] pad=200:200:100:100 [padout];
  8401. @end example
  8402. @item
  8403. Create 5 copies of the input audio with @command{ffmpeg}:
  8404. @example
  8405. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  8406. @end example
  8407. @end itemize
  8408. @section zmq, azmq
  8409. Receive commands sent through a libzmq client, and forward them to
  8410. filters in the filtergraph.
  8411. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  8412. must be inserted between two video filters, @code{azmq} between two
  8413. audio filters.
  8414. To enable these filters you need to install the libzmq library and
  8415. headers and configure FFmpeg with @code{--enable-libzmq}.
  8416. For more information about libzmq see:
  8417. @url{http://www.zeromq.org/}
  8418. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  8419. receives messages sent through a network interface defined by the
  8420. @option{bind_address} option.
  8421. The received message must be in the form:
  8422. @example
  8423. @var{TARGET} @var{COMMAND} [@var{ARG}]
  8424. @end example
  8425. @var{TARGET} specifies the target of the command, usually the name of
  8426. the filter class or a specific filter instance name.
  8427. @var{COMMAND} specifies the name of the command for the target filter.
  8428. @var{ARG} is optional and specifies the optional argument list for the
  8429. given @var{COMMAND}.
  8430. Upon reception, the message is processed and the corresponding command
  8431. is injected into the filtergraph. Depending on the result, the filter
  8432. will send a reply to the client, adopting the format:
  8433. @example
  8434. @var{ERROR_CODE} @var{ERROR_REASON}
  8435. @var{MESSAGE}
  8436. @end example
  8437. @var{MESSAGE} is optional.
  8438. @subsection Examples
  8439. Look at @file{tools/zmqsend} for an example of a zmq client which can
  8440. be used to send commands processed by these filters.
  8441. Consider the following filtergraph generated by @command{ffplay}
  8442. @example
  8443. ffplay -dumpgraph 1 -f lavfi "
  8444. color=s=100x100:c=red [l];
  8445. color=s=100x100:c=blue [r];
  8446. nullsrc=s=200x100, zmq [bg];
  8447. [bg][l] overlay [bg+l];
  8448. [bg+l][r] overlay=x=100 "
  8449. @end example
  8450. To change the color of the left side of the video, the following
  8451. command can be used:
  8452. @example
  8453. echo Parsed_color_0 c yellow | tools/zmqsend
  8454. @end example
  8455. To change the right side:
  8456. @example
  8457. echo Parsed_color_1 c pink | tools/zmqsend
  8458. @end example
  8459. @c man end MULTIMEDIA FILTERS
  8460. @chapter Multimedia Sources
  8461. @c man begin MULTIMEDIA SOURCES
  8462. Below is a description of the currently available multimedia sources.
  8463. @section amovie
  8464. This is the same as @ref{movie} source, except it selects an audio
  8465. stream by default.
  8466. @anchor{movie}
  8467. @section movie
  8468. Read audio and/or video stream(s) from a movie container.
  8469. It accepts the following parameters:
  8470. @table @option
  8471. @item filename
  8472. The name of the resource to read (not necessarily a file; it can also be a
  8473. device or a stream accessed through some protocol).
  8474. @item format_name, f
  8475. Specifies the format assumed for the movie to read, and can be either
  8476. the name of a container or an input device. If not specified, the
  8477. format is guessed from @var{movie_name} or by probing.
  8478. @item seek_point, sp
  8479. Specifies the seek point in seconds. The frames will be output
  8480. starting from this seek point. The parameter is evaluated with
  8481. @code{av_strtod}, so the numerical value may be suffixed by an IS
  8482. postfix. The default value is "0".
  8483. @item streams, s
  8484. Specifies the streams to read. Several streams can be specified,
  8485. separated by "+". The source will then have as many outputs, in the
  8486. same order. The syntax is explained in the ``Stream specifiers''
  8487. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  8488. respectively the default (best suited) video and audio stream. Default
  8489. is "dv", or "da" if the filter is called as "amovie".
  8490. @item stream_index, si
  8491. Specifies the index of the video stream to read. If the value is -1,
  8492. the most suitable video stream will be automatically selected. The default
  8493. value is "-1". Deprecated. If the filter is called "amovie", it will select
  8494. audio instead of video.
  8495. @item loop
  8496. Specifies how many times to read the stream in sequence.
  8497. If the value is less than 1, the stream will be read again and again.
  8498. Default value is "1".
  8499. Note that when the movie is looped the source timestamps are not
  8500. changed, so it will generate non monotonically increasing timestamps.
  8501. @end table
  8502. It allows overlaying a second video on top of the main input of
  8503. a filtergraph, as shown in this graph:
  8504. @example
  8505. input -----------> deltapts0 --> overlay --> output
  8506. ^
  8507. |
  8508. movie --> scale--> deltapts1 -------+
  8509. @end example
  8510. @subsection Examples
  8511. @itemize
  8512. @item
  8513. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  8514. on top of the input labelled "in":
  8515. @example
  8516. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  8517. [in] setpts=PTS-STARTPTS [main];
  8518. [main][over] overlay=16:16 [out]
  8519. @end example
  8520. @item
  8521. Read from a video4linux2 device, and overlay it on top of the input
  8522. labelled "in":
  8523. @example
  8524. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  8525. [in] setpts=PTS-STARTPTS [main];
  8526. [main][over] overlay=16:16 [out]
  8527. @end example
  8528. @item
  8529. Read the first video stream and the audio stream with id 0x81 from
  8530. dvd.vob; the video is connected to the pad named "video" and the audio is
  8531. connected to the pad named "audio":
  8532. @example
  8533. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  8534. @end example
  8535. @end itemize
  8536. @c man end MULTIMEDIA SOURCES