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.

9214 lines
246KB

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