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.

11138 lines
301KB

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