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.

10497 lines
283KB

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