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.

8593 lines
230KB

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