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.

9352 lines
250KB

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