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.

10208 lines
274KB

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