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.

5759 lines
161KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, it is possible for filters to have multiple inputs and
  5. multiple outputs.
  6. To illustrate the sorts of things that are possible, we can
  7. use a complex filter graph. For example, the following one:
  8. @example
  9. input --> split ---------------------> overlay --> output
  10. | ^
  11. | |
  12. +-----> crop --> vflip -------+
  13. @end example
  14. splits the stream in two streams, sends one stream through the crop filter
  15. and the vflip filter before merging it back with the other stream by
  16. overlaying it on top. You can use the following command to achieve this:
  17. @example
  18. ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
  19. @end example
  20. The result will be that in output the top half of the video is mirrored
  21. onto the bottom half.
  22. Filters are loaded using the @var{-vf} or @var{-af} option passed to
  23. @command{ffmpeg} or to @command{ffplay}. Filters in the same linear
  24. chain are separated by commas. In our example, @var{split,
  25. overlay} are in one linear chain, and @var{crop, vflip} are in
  26. another. The points where the linear chains join are labeled by names
  27. enclosed in square brackets. In our example, that is @var{[T1]} and
  28. @var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
  29. where video is input and output.
  30. Some filters take in input a list of parameters: they are specified
  31. after the filter name and an equal sign, and are separated from each other
  32. by a colon.
  33. There exist so-called @var{source filters} that do not have an
  34. audio/video input, and @var{sink filters} that will not have audio/video
  35. output.
  36. @c man end FILTERING INTRODUCTION
  37. @chapter graph2dot
  38. @c man begin GRAPH2DOT
  39. The @file{graph2dot} program included in the FFmpeg @file{tools}
  40. directory can be used to parse a filter graph description and issue a
  41. corresponding textual representation in the dot language.
  42. Invoke the command:
  43. @example
  44. graph2dot -h
  45. @end example
  46. to see how to use @file{graph2dot}.
  47. You can then pass the dot description to the @file{dot} program (from
  48. the graphviz suite of programs) and obtain a graphical representation
  49. of the filter graph.
  50. For example the sequence of commands:
  51. @example
  52. echo @var{GRAPH_DESCRIPTION} | \
  53. tools/graph2dot -o graph.tmp && \
  54. dot -Tpng graph.tmp -o graph.png && \
  55. display graph.png
  56. @end example
  57. can be used to create and display an image representing the graph
  58. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  59. a complete self-contained graph, with its inputs and outputs explicitly defined.
  60. For example if your command line is of the form:
  61. @example
  62. ffmpeg -i infile -vf scale=640:360 outfile
  63. @end example
  64. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  65. @example
  66. nullsrc,scale=640:360,nullsink
  67. @end example
  68. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  69. filter in order to simulate a specific input file.
  70. @c man end GRAPH2DOT
  71. @chapter Filtergraph description
  72. @c man begin FILTERGRAPH DESCRIPTION
  73. A filtergraph is a directed graph of connected filters. It can contain
  74. cycles, and there can be multiple links between a pair of
  75. filters. Each link has one input pad on one side connecting it to one
  76. filter from which it takes its input, and one output pad on the other
  77. side connecting it to the one filter accepting its output.
  78. Each filter in a filtergraph is an instance of a filter class
  79. registered in the application, which defines the features and the
  80. number of input and output pads of the filter.
  81. A filter with no input pads is called a "source", a filter with no
  82. output pads is called a "sink".
  83. @anchor{Filtergraph syntax}
  84. @section Filtergraph syntax
  85. A filtergraph can be represented using a textual representation, which is
  86. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  87. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  88. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  89. @file{libavfilter/avfiltergraph.h}.
  90. A filterchain consists of a sequence of connected filters, each one
  91. connected to the previous one in the sequence. A filterchain is
  92. represented by a list of ","-separated filter descriptions.
  93. A filtergraph consists of a sequence of filterchains. A sequence of
  94. filterchains is represented by a list of ";"-separated filterchain
  95. descriptions.
  96. A filter is represented by a string of the form:
  97. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  98. @var{filter_name} is the name of the filter class of which the
  99. described filter is an instance of, and has to be the name of one of
  100. the filter classes registered in the program.
  101. The name of the filter class is optionally followed by a string
  102. "=@var{arguments}".
  103. @var{arguments} is a string which contains the parameters used to
  104. initialize the filter instance, and are described in the filter
  105. descriptions below.
  106. The list of arguments can be quoted using the character "'" as initial
  107. and ending mark, and the character '\' for escaping the characters
  108. within the quoted text; otherwise the argument string is considered
  109. terminated when the next special character (belonging to the set
  110. "[]=;,") is encountered.
  111. The name and arguments of the filter are optionally preceded and
  112. followed by a list of link labels.
  113. A link label allows to name a link and associate it to a filter output
  114. or input pad. The preceding labels @var{in_link_1}
  115. ... @var{in_link_N}, are associated to the filter input pads,
  116. the following labels @var{out_link_1} ... @var{out_link_M}, are
  117. associated to the output pads.
  118. When two link labels with the same name are found in the
  119. filtergraph, a link between the corresponding input and output pad is
  120. created.
  121. If an output pad is not labelled, it is linked by default to the first
  122. unlabelled input pad of the next filter in the filterchain.
  123. For example in the filterchain:
  124. @example
  125. nullsrc, split[L1], [L2]overlay, nullsink
  126. @end example
  127. the split filter instance has two output pads, and the overlay filter
  128. instance two input pads. The first output pad of split is labelled
  129. "L1", the first input pad of overlay is labelled "L2", and the second
  130. output pad of split is linked to the second input pad of overlay,
  131. which are both unlabelled.
  132. In a complete filterchain all the unlabelled filter input and output
  133. pads must be connected. A filtergraph is considered valid if all the
  134. filter input and output pads of all the filterchains are connected.
  135. Libavfilter will automatically insert scale filters where format
  136. conversion is required. It is possible to specify swscale flags
  137. for those automatically inserted scalers by prepending
  138. @code{sws_flags=@var{flags};}
  139. to the filtergraph description.
  140. Follows a BNF description for the filtergraph syntax:
  141. @example
  142. @var{NAME} ::= sequence of alphanumeric characters and '_'
  143. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  144. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  145. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  146. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  147. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  148. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  149. @end example
  150. @section Notes on filtergraph escaping
  151. Some filter arguments require the use of special characters, typically
  152. @code{:} to separate key=value pairs in a named options list. In this
  153. case the user should perform a first level escaping when specifying
  154. the filter arguments. For example, consider the following literal
  155. string to be embedded in the @ref{drawtext} filter arguments:
  156. @example
  157. this is a 'string': may contain one, or more, special characters
  158. @end example
  159. Since @code{:} is special for the filter arguments syntax, it needs to
  160. be escaped, so you get:
  161. @example
  162. text=this is a \'string\'\: may contain one, or more, special characters
  163. @end example
  164. A second level of escaping is required when embedding the filter
  165. arguments in a filtergraph description, in order to escape all the
  166. filtergraph special characters. Thus the example above becomes:
  167. @example
  168. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  169. @end example
  170. Finally an additional level of escaping may be needed when writing the
  171. filtergraph description in a shell command, which depends on the
  172. escaping rules of the adopted shell. For example, assuming that
  173. @code{\} is special and needs to be escaped with another @code{\}, the
  174. previous string will finally result in:
  175. @example
  176. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  177. @end example
  178. Sometimes, it might be more convenient to employ quoting in place of
  179. escaping. For example the string:
  180. @example
  181. Caesar: tu quoque, Brute, fili mi
  182. @end example
  183. Can be quoted in the filter arguments as:
  184. @example
  185. text='Caesar: tu quoque, Brute, fili mi'
  186. @end example
  187. And finally inserted in a filtergraph like:
  188. @example
  189. drawtext=text=\'Caesar: tu quoque\, Brute\, fili mi\'
  190. @end example
  191. See the ``Quoting and escaping'' section in the ffmpeg-utils manual
  192. for more information about the escaping and quoting rules adopted by
  193. FFmpeg.
  194. @c man end FILTERGRAPH DESCRIPTION
  195. @chapter Audio Filters
  196. @c man begin AUDIO FILTERS
  197. When you configure your FFmpeg build, you can disable any of the
  198. existing filters using @code{--disable-filters}.
  199. The configure output will show the audio filters included in your
  200. build.
  201. Below is a description of the currently available audio filters.
  202. @section aconvert
  203. Convert the input audio format to the specified formats.
  204. The filter accepts a string of the form:
  205. "@var{sample_format}:@var{channel_layout}".
  206. @var{sample_format} specifies the sample format, and can be a string or the
  207. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  208. suffix for a planar sample format.
  209. @var{channel_layout} specifies the channel layout, and can be a string
  210. or the corresponding number value defined in @file{libavutil/channel_layout.h}.
  211. The special parameter "auto", signifies that the filter will
  212. automatically select the output format depending on the output filter.
  213. Some examples follow.
  214. @itemize
  215. @item
  216. Convert input to float, planar, stereo:
  217. @example
  218. aconvert=fltp:stereo
  219. @end example
  220. @item
  221. Convert input to unsigned 8-bit, automatically select out channel layout:
  222. @example
  223. aconvert=u8:auto
  224. @end example
  225. @end itemize
  226. @section aformat
  227. Set output format constraints for the input audio. The framework will
  228. negotiate the most appropriate format to minimize conversions.
  229. The filter accepts the following named parameters:
  230. @table @option
  231. @item sample_fmts
  232. A comma-separated list of requested sample formats.
  233. @item sample_rates
  234. A comma-separated list of requested sample rates.
  235. @item channel_layouts
  236. A comma-separated list of requested channel layouts.
  237. @end table
  238. If a parameter is omitted, all values are allowed.
  239. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  240. @example
  241. aformat='sample_fmts=u8,s16:channel_layouts=stereo'
  242. @end example
  243. @section amerge
  244. Merge two or more audio streams into a single multi-channel stream.
  245. The filter accepts the following named options:
  246. @table @option
  247. @item inputs
  248. Set the number of inputs. Default is 2.
  249. @end table
  250. If the channel layouts of the inputs are disjoint, and therefore compatible,
  251. the channel layout of the output will be set accordingly and the channels
  252. will be reordered as necessary. If the channel layouts of the inputs are not
  253. disjoint, the output will have all the channels of the first input then all
  254. the channels of the second input, in that order, and the channel layout of
  255. the output will be the default value corresponding to the total number of
  256. channels.
  257. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  258. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  259. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  260. first input, b1 is the first channel of the second input).
  261. On the other hand, if both input are in stereo, the output channels will be
  262. in the default order: a1, a2, b1, b2, and the channel layout will be
  263. arbitrarily set to 4.0, which may or may not be the expected value.
  264. All inputs must have the same sample rate, and format.
  265. If inputs do not have the same duration, the output will stop with the
  266. shortest.
  267. Example: merge two mono files into a stereo stream:
  268. @example
  269. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  270. @end example
  271. Example: multiple merges:
  272. @example
  273. ffmpeg -f lavfi -i "
  274. amovie=input.mkv:si=0 [a0];
  275. amovie=input.mkv:si=1 [a1];
  276. amovie=input.mkv:si=2 [a2];
  277. amovie=input.mkv:si=3 [a3];
  278. amovie=input.mkv:si=4 [a4];
  279. amovie=input.mkv:si=5 [a5];
  280. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  281. @end example
  282. @section amix
  283. Mixes multiple audio inputs into a single output.
  284. For example
  285. @example
  286. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  287. @end example
  288. will mix 3 input audio streams to a single output with the same duration as the
  289. first input and a dropout transition time of 3 seconds.
  290. The filter accepts the following named parameters:
  291. @table @option
  292. @item inputs
  293. Number of inputs. If unspecified, it defaults to 2.
  294. @item duration
  295. How to determine the end-of-stream.
  296. @table @option
  297. @item longest
  298. Duration of longest input. (default)
  299. @item shortest
  300. Duration of shortest input.
  301. @item first
  302. Duration of first input.
  303. @end table
  304. @item dropout_transition
  305. Transition time, in seconds, for volume renormalization when an input
  306. stream ends. The default value is 2 seconds.
  307. @end table
  308. @section anull
  309. Pass the audio source unchanged to the output.
  310. @section apad
  311. Pad the end of a audio stream with silence, this can be used together with
  312. -shortest to extend audio streams to the same length as the video stream.
  313. @anchor{aresample}
  314. @section aresample
  315. Resample the input audio to the specified parameters, using the
  316. libswresample library. If none are specified then the filter will
  317. automatically convert between its input and output.
  318. This filter is also able to stretch/squeeze the audio data to make it match
  319. the timestamps or to inject silence / cut out audio to make it match the
  320. timestamps, do a combination of both or do neither.
  321. The filter accepts the syntax
  322. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  323. expresses a sample rate and @var{resampler_options} is a list of
  324. @var{key}=@var{value} pairs, separated by ":". See the
  325. ffmpeg-resampler manual for the complete list of supported options.
  326. For example, to resample the input audio to 44100Hz:
  327. @example
  328. aresample=44100
  329. @end example
  330. To stretch/squeeze samples to the given timestamps, with a maximum of 1000
  331. samples per second compensation:
  332. @example
  333. aresample=async=1000
  334. @end example
  335. @section asetnsamples
  336. Set the number of samples per each output audio frame.
  337. The last output packet may contain a different number of samples, as
  338. the filter will flush all the remaining samples when the input audio
  339. signal its end.
  340. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  341. separated by ":".
  342. @table @option
  343. @item nb_out_samples, n
  344. Set the number of frames per each output audio frame. The number is
  345. intended as the number of samples @emph{per each channel}.
  346. Default value is 1024.
  347. @item pad, p
  348. If set to 1, the filter will pad the last audio frame with zeroes, so
  349. that the last frame will contain the same number of samples as the
  350. previous ones. Default value is 1.
  351. @end table
  352. For example, to set the number of per-frame samples to 1234 and
  353. disable padding for the last frame, use:
  354. @example
  355. asetnsamples=n=1234:p=0
  356. @end example
  357. @section ashowinfo
  358. Show a line containing various information for each input audio frame.
  359. The input audio is not modified.
  360. The shown line contains a sequence of key/value pairs of the form
  361. @var{key}:@var{value}.
  362. A description of each shown parameter follows:
  363. @table @option
  364. @item n
  365. sequential number of the input frame, starting from 0
  366. @item pts
  367. Presentation timestamp of the input frame, in time base units; the time base
  368. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  369. @item pts_time
  370. presentation timestamp of the input frame in seconds
  371. @item pos
  372. position of the frame in the input stream, -1 if this information in
  373. unavailable and/or meaningless (for example in case of synthetic audio)
  374. @item fmt
  375. sample format
  376. @item chlayout
  377. channel layout
  378. @item rate
  379. sample rate for the audio frame
  380. @item nb_samples
  381. number of samples (per channel) in the frame
  382. @item checksum
  383. Adler-32 checksum (printed in hexadecimal) of the audio data. For planar audio
  384. the data is treated as if all the planes were concatenated.
  385. @item plane_checksums
  386. A list of Adler-32 checksums for each data plane.
  387. @end table
  388. @section asplit
  389. Split input audio into several identical outputs.
  390. The filter accepts a single parameter which specifies the number of outputs. If
  391. unspecified, it defaults to 2.
  392. For example:
  393. @example
  394. [in] asplit [out0][out1]
  395. @end example
  396. will create two separate outputs from the same input.
  397. To create 3 or more outputs, you need to specify the number of
  398. outputs, like in:
  399. @example
  400. [in] asplit=3 [out0][out1][out2]
  401. @end example
  402. @example
  403. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  404. @end example
  405. will create 5 copies of the input audio.
  406. @section astreamsync
  407. Forward two audio streams and control the order the buffers are forwarded.
  408. The argument to the filter is an expression deciding which stream should be
  409. forwarded next: if the result is negative, the first stream is forwarded; if
  410. the result is positive or zero, the second stream is forwarded. It can use
  411. the following variables:
  412. @table @var
  413. @item b1 b2
  414. number of buffers forwarded so far on each stream
  415. @item s1 s2
  416. number of samples forwarded so far on each stream
  417. @item t1 t2
  418. current timestamp of each stream
  419. @end table
  420. The default value is @code{t1-t2}, which means to always forward the stream
  421. that has a smaller timestamp.
  422. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  423. input, while avoiding too much of a desynchronization:
  424. @example
  425. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  426. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  427. [a2] [b2] amerge
  428. @end example
  429. @section atempo
  430. Adjust audio tempo.
  431. The filter accepts exactly one parameter, the audio tempo. If not
  432. specified then the filter will assume nominal 1.0 tempo. Tempo must
  433. be in the [0.5, 2.0] range.
  434. For example, to slow down audio to 80% tempo:
  435. @example
  436. atempo=0.8
  437. @end example
  438. For example, to speed up audio to 125% tempo:
  439. @example
  440. atempo=1.25
  441. @end example
  442. @section earwax
  443. Make audio easier to listen to on headphones.
  444. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  445. so that when listened to on headphones the stereo image is moved from
  446. inside your head (standard for headphones) to outside and in front of
  447. the listener (standard for speakers).
  448. Ported from SoX.
  449. @section pan
  450. Mix channels with specific gain levels. The filter accepts the output
  451. channel layout followed by a set of channels definitions.
  452. This filter is also designed to remap efficiently the channels of an audio
  453. stream.
  454. The filter accepts parameters of the form:
  455. "@var{l}:@var{outdef}:@var{outdef}:..."
  456. @table @option
  457. @item l
  458. output channel layout or number of channels
  459. @item outdef
  460. output channel specification, of the form:
  461. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  462. @item out_name
  463. output channel to define, either a channel name (FL, FR, etc.) or a channel
  464. number (c0, c1, etc.)
  465. @item gain
  466. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  467. @item in_name
  468. input channel to use, see out_name for details; it is not possible to mix
  469. named and numbered input channels
  470. @end table
  471. If the `=' in a channel specification is replaced by `<', then the gains for
  472. that specification will be renormalized so that the total is 1, thus
  473. avoiding clipping noise.
  474. @subsection Mixing examples
  475. For example, if you want to down-mix from stereo to mono, but with a bigger
  476. factor for the left channel:
  477. @example
  478. pan=1:c0=0.9*c0+0.1*c1
  479. @end example
  480. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  481. 7-channels surround:
  482. @example
  483. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  484. @end example
  485. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  486. that should be preferred (see "-ac" option) unless you have very specific
  487. needs.
  488. @subsection Remapping examples
  489. The channel remapping will be effective if, and only if:
  490. @itemize
  491. @item gain coefficients are zeroes or ones,
  492. @item only one input per channel output,
  493. @end itemize
  494. If all these conditions are satisfied, the filter will notify the user ("Pure
  495. channel mapping detected"), and use an optimized and lossless method to do the
  496. remapping.
  497. For example, if you have a 5.1 source and want a stereo audio stream by
  498. dropping the extra channels:
  499. @example
  500. pan="stereo: c0=FL : c1=FR"
  501. @end example
  502. Given the same source, you can also switch front left and front right channels
  503. and keep the input channel layout:
  504. @example
  505. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  506. @end example
  507. If the input is a stereo audio stream, you can mute the front left channel (and
  508. still keep the stereo channel layout) with:
  509. @example
  510. pan="stereo:c1=c1"
  511. @end example
  512. Still with a stereo audio stream input, you can copy the right channel in both
  513. front left and right:
  514. @example
  515. pan="stereo: c0=FR : c1=FR"
  516. @end example
  517. @section silencedetect
  518. Detect silence in an audio stream.
  519. This filter logs a message when it detects that the input audio volume is less
  520. or equal to a noise tolerance value for a duration greater or equal to the
  521. minimum detected noise duration.
  522. The printed times and duration are expressed in seconds.
  523. @table @option
  524. @item duration, d
  525. Set silence duration until notification (default is 2 seconds).
  526. @item noise, n
  527. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  528. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  529. @end table
  530. Detect 5 seconds of silence with -50dB noise tolerance:
  531. @example
  532. silencedetect=n=-50dB:d=5
  533. @end example
  534. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  535. tolerance in @file{silence.mp3}:
  536. @example
  537. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  538. @end example
  539. @section asyncts
  540. Synchronize audio data with timestamps by squeezing/stretching it and/or
  541. dropping samples/adding silence when needed.
  542. As an alternative, you can use @ref{aresample} to do squeezing/stretching.
  543. The filter accepts the following named parameters:
  544. @table @option
  545. @item compensate
  546. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  547. by default. When disabled, time gaps are covered with silence.
  548. @item min_delta
  549. Minimum difference between timestamps and audio data (in seconds) to trigger
  550. adding/dropping samples. Default value is 0.1. If you get non-perfect sync with
  551. this filter, try setting this parameter to 0.
  552. @item max_comp
  553. Maximum compensation in samples per second. Relevant only with compensate=1.
  554. Default value 500.
  555. @item first_pts
  556. Assume the first pts should be this value. The time base is 1 / sample rate.
  557. This allows for padding/trimming at the start of stream. By default, no
  558. assumption is made about the first frame's expected pts, so no padding or
  559. trimming is done. For example, this could be set to 0 to pad the beginning with
  560. silence if an audio stream starts after the video stream or to trim any samples
  561. with a negative pts due to encoder delay.
  562. @end table
  563. @section channelsplit
  564. Split each channel in input audio stream into a separate output stream.
  565. This filter accepts the following named parameters:
  566. @table @option
  567. @item channel_layout
  568. Channel layout of the input stream. Default is "stereo".
  569. @end table
  570. For example, assuming a stereo input MP3 file
  571. @example
  572. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  573. @end example
  574. will create an output Matroska file with two audio streams, one containing only
  575. the left channel and the other the right channel.
  576. To split a 5.1 WAV file into per-channel files
  577. @example
  578. ffmpeg -i in.wav -filter_complex
  579. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  580. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  581. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  582. side_right.wav
  583. @end example
  584. @section channelmap
  585. Remap input channels to new locations.
  586. This filter accepts the following named parameters:
  587. @table @option
  588. @item channel_layout
  589. Channel layout of the output stream.
  590. @item map
  591. Map channels from input to output. The argument is a comma-separated list of
  592. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  593. @var{in_channel} form. @var{in_channel} can be either the name of the input
  594. channel (e.g. FL for front left) or its index in the input channel layout.
  595. @var{out_channel} is the name of the output channel or its index in the output
  596. channel layout. If @var{out_channel} is not given then it is implicitly an
  597. index, starting with zero and increasing by one for each mapping.
  598. @end table
  599. If no mapping is present, the filter will implicitly map input channels to
  600. output channels preserving index.
  601. For example, assuming a 5.1+downmix input MOV file
  602. @example
  603. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav
  604. @end example
  605. will create an output WAV file tagged as stereo from the downmix channels of
  606. the input.
  607. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  608. @example
  609. ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav
  610. @end example
  611. @section join
  612. Join multiple input streams into one multi-channel stream.
  613. The filter accepts the following named parameters:
  614. @table @option
  615. @item inputs
  616. Number of input streams. Defaults to 2.
  617. @item channel_layout
  618. Desired output channel layout. Defaults to stereo.
  619. @item map
  620. Map channels from inputs to output. The argument is a comma-separated list of
  621. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  622. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  623. can be either the name of the input channel (e.g. FL for front left) or its
  624. index in the specified input stream. @var{out_channel} is the name of the output
  625. channel.
  626. @end table
  627. The filter will attempt to guess the mappings when those are not specified
  628. explicitly. It does so by first trying to find an unused matching input channel
  629. and if that fails it picks the first unused input channel.
  630. E.g. to join 3 inputs (with properly set channel layouts)
  631. @example
  632. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  633. @end example
  634. To build a 5.1 output from 6 single-channel streams:
  635. @example
  636. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  637. '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'
  638. out
  639. @end example
  640. @section resample
  641. Convert the audio sample format, sample rate and channel layout. This filter is
  642. not meant to be used directly.
  643. @section volume
  644. Adjust the input audio volume.
  645. The filter accepts the following named parameters. If the key of the
  646. first options is omitted, the arguments are interpreted according to
  647. the following syntax:
  648. @example
  649. volume=@var{volume}:@var{precision}
  650. @end example
  651. @table @option
  652. @item volume
  653. Expresses how the audio volume will be increased or decreased.
  654. Output values are clipped to the maximum value.
  655. The output audio volume is given by the relation:
  656. @example
  657. @var{output_volume} = @var{volume} * @var{input_volume}
  658. @end example
  659. Default value for @var{volume} is 1.0.
  660. @item precision
  661. Set the mathematical precision.
  662. This determines which input sample formats will be allowed, which affects the
  663. precision of the volume scaling.
  664. @table @option
  665. @item fixed
  666. 8-bit fixed-point; limits input sample format to U8, S16, and S32.
  667. @item float
  668. 32-bit floating-point; limits input sample format to FLT. (default)
  669. @item double
  670. 64-bit floating-point; limits input sample format to DBL.
  671. @end table
  672. @end table
  673. @subsection Examples
  674. @itemize
  675. @item
  676. Halve the input audio volume:
  677. @example
  678. volume=volume=0.5
  679. volume=volume=1/2
  680. volume=volume=-6.0206dB
  681. @end example
  682. In all the above example the named key for @option{volume} can be
  683. omitted, for example like in:
  684. @example
  685. volume=0.5
  686. @end example
  687. @item
  688. Increase input audio power by 6 decibels using fixed-point precision:
  689. @example
  690. volume=volume=6dB:precision=fixed
  691. @end example
  692. @end itemize
  693. @section volumedetect
  694. Detect the volume of the input video.
  695. The filter has no parameters. The input is not modified. Statistics about
  696. the volume will be printed in the log when the input stream end is reached.
  697. In particular it will show the mean volume (root mean square), maximum
  698. volume (on a per-sample basis), and the beginning of an histogram of the
  699. registered volume values (from the maximum value to a cumulated 1/1000 of
  700. the samples).
  701. All volumes are in decibels relative to the maximum PCM value.
  702. Here is an excerpt of the output:
  703. @example
  704. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  705. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  706. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  707. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  708. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  709. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  710. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  711. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  712. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  713. @end example
  714. It means that:
  715. @itemize
  716. @item
  717. The mean square energy is approximately -27 dB, or 10^-2.7.
  718. @item
  719. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  720. @item
  721. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  722. @end itemize
  723. In other words, raising the volume by +4 dB does not cause any clipping,
  724. raising it by +5 dB causes clipping for 6 samples, etc.
  725. @c man end AUDIO FILTERS
  726. @chapter Audio Sources
  727. @c man begin AUDIO SOURCES
  728. Below is a description of the currently available audio sources.
  729. @section abuffer
  730. Buffer audio frames, and make them available to the filter chain.
  731. This source is mainly intended for a programmatic use, in particular
  732. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  733. It accepts the following mandatory parameters:
  734. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  735. @table @option
  736. @item sample_rate
  737. The sample rate of the incoming audio buffers.
  738. @item sample_fmt
  739. The sample format of the incoming audio buffers.
  740. Either a sample format name or its corresponging integer representation from
  741. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  742. @item channel_layout
  743. The channel layout of the incoming audio buffers.
  744. Either a channel layout name from channel_layout_map in
  745. @file{libavutil/channel_layout.c} or its corresponding integer representation
  746. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  747. @end table
  748. For example:
  749. @example
  750. abuffer=44100:s16p:stereo
  751. @end example
  752. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  753. Since the sample format with name "s16p" corresponds to the number
  754. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  755. equivalent to:
  756. @example
  757. abuffer=44100:6:0x3
  758. @end example
  759. @section aevalsrc
  760. Generate an audio signal specified by an expression.
  761. This source accepts in input one or more expressions (one for each
  762. channel), which are evaluated and used to generate a corresponding
  763. audio signal.
  764. It accepts the syntax: @var{exprs}[::@var{options}].
  765. @var{exprs} is a list of expressions separated by ":", one for each
  766. separate channel. In case the @var{channel_layout} is not
  767. specified, the selected channel layout depends on the number of
  768. provided expressions.
  769. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  770. separated by ":".
  771. The description of the accepted options follows.
  772. @table @option
  773. @item channel_layout, c
  774. Set the channel layout. The number of channels in the specified layout
  775. must be equal to the number of specified expressions.
  776. @item duration, d
  777. Set the minimum duration of the sourced audio. See the function
  778. @code{av_parse_time()} for the accepted format.
  779. Note that the resulting duration may be greater than the specified
  780. duration, as the generated audio is always cut at the end of a
  781. complete frame.
  782. If not specified, or the expressed duration is negative, the audio is
  783. supposed to be generated forever.
  784. @item nb_samples, n
  785. Set the number of samples per channel per each output frame,
  786. default to 1024.
  787. @item sample_rate, s
  788. Specify the sample rate, default to 44100.
  789. @end table
  790. Each expression in @var{exprs} can contain the following constants:
  791. @table @option
  792. @item n
  793. number of the evaluated sample, starting from 0
  794. @item t
  795. time of the evaluated sample expressed in seconds, starting from 0
  796. @item s
  797. sample rate
  798. @end table
  799. @subsection Examples
  800. @itemize
  801. @item
  802. Generate silence:
  803. @example
  804. aevalsrc=0
  805. @end example
  806. @item
  807. Generate a sin signal with frequency of 440 Hz, set sample rate to
  808. 8000 Hz:
  809. @example
  810. aevalsrc="sin(440*2*PI*t)::s=8000"
  811. @end example
  812. @item
  813. Generate a two channels signal, specify the channel layout (Front
  814. Center + Back Center) explicitly:
  815. @example
  816. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  817. @end example
  818. @item
  819. Generate white noise:
  820. @example
  821. aevalsrc="-2+random(0)"
  822. @end example
  823. @item
  824. Generate an amplitude modulated signal:
  825. @example
  826. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  827. @end example
  828. @item
  829. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  830. @example
  831. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  832. @end example
  833. @end itemize
  834. @section anullsrc
  835. Null audio source, return unprocessed audio frames. It is mainly useful
  836. as a template and to be employed in analysis / debugging tools, or as
  837. the source for filters which ignore the input data (for example the sox
  838. synth filter).
  839. It accepts an optional sequence of @var{key}=@var{value} pairs,
  840. separated by ":".
  841. The description of the accepted options follows.
  842. @table @option
  843. @item sample_rate, s
  844. Specify the sample rate, and defaults to 44100.
  845. @item channel_layout, cl
  846. Specify the channel layout, and can be either an integer or a string
  847. representing a channel layout. The default value of @var{channel_layout}
  848. is "stereo".
  849. Check the channel_layout_map definition in
  850. @file{libavutil/channel_layout.c} for the mapping between strings and
  851. channel layout values.
  852. @item nb_samples, n
  853. Set the number of samples per requested frames.
  854. @end table
  855. Follow some examples:
  856. @example
  857. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  858. anullsrc=r=48000:cl=4
  859. # same as
  860. anullsrc=r=48000:cl=mono
  861. @end example
  862. @section abuffer
  863. Buffer audio frames, and make them available to the filter chain.
  864. This source is not intended to be part of user-supplied graph descriptions but
  865. for insertion by calling programs through the interface defined in
  866. @file{libavfilter/buffersrc.h}.
  867. It accepts the following named parameters:
  868. @table @option
  869. @item time_base
  870. Timebase which will be used for timestamps of submitted frames. It must be
  871. either a floating-point number or in @var{numerator}/@var{denominator} form.
  872. @item sample_rate
  873. Audio sample rate.
  874. @item sample_fmt
  875. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  876. @item channel_layout
  877. Channel layout of the audio data, in the form that can be accepted by
  878. @code{av_get_channel_layout()}.
  879. @end table
  880. All the parameters need to be explicitly defined.
  881. @section flite
  882. Synthesize a voice utterance using the libflite library.
  883. To enable compilation of this filter you need to configure FFmpeg with
  884. @code{--enable-libflite}.
  885. Note that the flite library is not thread-safe.
  886. The source accepts parameters as a list of @var{key}=@var{value} pairs,
  887. separated by ":".
  888. The description of the accepted parameters follows.
  889. @table @option
  890. @item list_voices
  891. If set to 1, list the names of the available voices and exit
  892. immediately. Default value is 0.
  893. @item nb_samples, n
  894. Set the maximum number of samples per frame. Default value is 512.
  895. @item textfile
  896. Set the filename containing the text to speak.
  897. @item text
  898. Set the text to speak.
  899. @item voice, v
  900. Set the voice to use for the speech synthesis. Default value is
  901. @code{kal}. See also the @var{list_voices} option.
  902. @end table
  903. @subsection Examples
  904. @itemize
  905. @item
  906. Read from file @file{speech.txt}, and synthetize the text using the
  907. standard flite voice:
  908. @example
  909. flite=textfile=speech.txt
  910. @end example
  911. @item
  912. Read the specified text selecting the @code{slt} voice:
  913. @example
  914. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  915. @end example
  916. @item
  917. Input text to ffmpeg:
  918. @example
  919. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  920. @end example
  921. @item
  922. Make @file{ffplay} speak the specified text, using @code{flite} and
  923. the @code{lavfi} device:
  924. @example
  925. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  926. @end example
  927. @end itemize
  928. For more information about libflite, check:
  929. @url{http://www.speech.cs.cmu.edu/flite/}
  930. @c man end AUDIO SOURCES
  931. @chapter Audio Sinks
  932. @c man begin AUDIO SINKS
  933. Below is a description of the currently available audio sinks.
  934. @section abuffersink
  935. Buffer audio frames, and make them available to the end of filter chain.
  936. This sink is mainly intended for programmatic use, in particular
  937. through the interface defined in @file{libavfilter/buffersink.h}.
  938. It requires a pointer to an AVABufferSinkContext structure, which
  939. defines the incoming buffers' formats, to be passed as the opaque
  940. parameter to @code{avfilter_init_filter} for initialization.
  941. @section anullsink
  942. Null audio sink, do absolutely nothing with the input audio. It is
  943. mainly useful as a template and to be employed in analysis / debugging
  944. tools.
  945. @section abuffersink
  946. This sink is intended for programmatic use. Frames that arrive on this sink can
  947. be retrieved by the calling program using the interface defined in
  948. @file{libavfilter/buffersink.h}.
  949. This filter accepts no parameters.
  950. @c man end AUDIO SINKS
  951. @chapter Video Filters
  952. @c man begin VIDEO FILTERS
  953. When you configure your FFmpeg build, you can disable any of the
  954. existing filters using @code{--disable-filters}.
  955. The configure output will show the video filters included in your
  956. build.
  957. Below is a description of the currently available video filters.
  958. @section alphaextract
  959. Extract the alpha component from the input as a grayscale video. This
  960. is especially useful with the @var{alphamerge} filter.
  961. @section alphamerge
  962. Add or replace the alpha component of the primary input with the
  963. grayscale value of a second input. This is intended for use with
  964. @var{alphaextract} to allow the transmission or storage of frame
  965. sequences that have alpha in a format that doesn't support an alpha
  966. channel.
  967. For example, to reconstruct full frames from a normal YUV-encoded video
  968. and a separate video created with @var{alphaextract}, you might use:
  969. @example
  970. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  971. @end example
  972. Since this filter is designed for reconstruction, it operates on frame
  973. sequences without considering timestamps, and terminates when either
  974. input reaches end of stream. This will cause problems if your encoding
  975. pipeline drops frames. If you're trying to apply an image as an
  976. overlay to a video stream, consider the @var{overlay} filter instead.
  977. @section ass
  978. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  979. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  980. Substation Alpha) subtitles files.
  981. @section bbox
  982. Compute the bounding box for the non-black pixels in the input frame
  983. luminance plane.
  984. This filter computes the bounding box containing all the pixels with a
  985. luminance value greater than the minimum allowed value.
  986. The parameters describing the bounding box are printed on the filter
  987. log.
  988. @section blackdetect
  989. Detect video intervals that are (almost) completely black. Can be
  990. useful to detect chapter transitions, commercials, or invalid
  991. recordings. Output lines contains the time for the start, end and
  992. duration of the detected black interval expressed in seconds.
  993. In order to display the output lines, you need to set the loglevel at
  994. least to the AV_LOG_INFO value.
  995. This filter accepts a list of options in the form of
  996. @var{key}=@var{value} pairs separated by ":". A description of the
  997. accepted options follows.
  998. @table @option
  999. @item black_min_duration, d
  1000. Set the minimum detected black duration expressed in seconds. It must
  1001. be a non-negative floating point number.
  1002. Default value is 2.0.
  1003. @item picture_black_ratio_th, pic_th
  1004. Set the threshold for considering a picture "black".
  1005. Express the minimum value for the ratio:
  1006. @example
  1007. @var{nb_black_pixels} / @var{nb_pixels}
  1008. @end example
  1009. for which a picture is considered black.
  1010. Default value is 0.98.
  1011. @item pixel_black_th, pix_th
  1012. Set the threshold for considering a pixel "black".
  1013. The threshold expresses the maximum pixel luminance value for which a
  1014. pixel is considered "black". The provided value is scaled according to
  1015. the following equation:
  1016. @example
  1017. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1018. @end example
  1019. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1020. the input video format, the range is [0-255] for YUV full-range
  1021. formats and [16-235] for YUV non full-range formats.
  1022. Default value is 0.10.
  1023. @end table
  1024. The following example sets the maximum pixel threshold to the minimum
  1025. value, and detects only black intervals of 2 or more seconds:
  1026. @example
  1027. blackdetect=d=2:pix_th=0.00
  1028. @end example
  1029. @section blackframe
  1030. Detect frames that are (almost) completely black. Can be useful to
  1031. detect chapter transitions or commercials. Output lines consist of
  1032. the frame number of the detected frame, the percentage of blackness,
  1033. the position in the file if known or -1 and the timestamp in seconds.
  1034. In order to display the output lines, you need to set the loglevel at
  1035. least to the AV_LOG_INFO value.
  1036. The filter accepts the syntax:
  1037. @example
  1038. blackframe[=@var{amount}:[@var{threshold}]]
  1039. @end example
  1040. @var{amount} is the percentage of the pixels that have to be below the
  1041. threshold, and defaults to 98.
  1042. @var{threshold} is the threshold below which a pixel value is
  1043. considered black, and defaults to 32.
  1044. @section boxblur
  1045. Apply boxblur algorithm to the input video.
  1046. This filter accepts the parameters:
  1047. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  1048. Chroma and alpha parameters are optional, if not specified they default
  1049. to the corresponding values set for @var{luma_radius} and
  1050. @var{luma_power}.
  1051. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  1052. the radius in pixels of the box used for blurring the corresponding
  1053. input plane. They are expressions, and can contain the following
  1054. constants:
  1055. @table @option
  1056. @item w, h
  1057. the input width and height in pixels
  1058. @item cw, ch
  1059. the input chroma image width and height in pixels
  1060. @item hsub, vsub
  1061. horizontal and vertical chroma subsample values. For example for the
  1062. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1063. @end table
  1064. The radius must be a non-negative number, and must not be greater than
  1065. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  1066. and of @code{min(cw,ch)/2} for the chroma planes.
  1067. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  1068. how many times the boxblur filter is applied to the corresponding
  1069. plane.
  1070. Some examples follow:
  1071. @itemize
  1072. @item
  1073. Apply a boxblur filter with luma, chroma, and alpha radius
  1074. set to 2:
  1075. @example
  1076. boxblur=2:1
  1077. @end example
  1078. @item
  1079. Set luma radius to 2, alpha and chroma radius to 0
  1080. @example
  1081. boxblur=2:1:0:0:0:0
  1082. @end example
  1083. @item
  1084. Set luma and chroma radius to a fraction of the video dimension
  1085. @example
  1086. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  1087. @end example
  1088. @end itemize
  1089. @section colormatrix
  1090. The colormatrix filter allows conversion between any of the following color
  1091. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  1092. and FCC (@var{fcc}).
  1093. The syntax of the parameters is @var{source}:@var{destination}:
  1094. @example
  1095. colormatrix=bt601:smpte240m
  1096. @end example
  1097. @section copy
  1098. Copy the input source unchanged to the output. Mainly useful for
  1099. testing purposes.
  1100. @section crop
  1101. Crop the input video.
  1102. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  1103. separated by ':'. If the key of the first options is omitted, the
  1104. arguments are interpreted according to the syntax
  1105. @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}.
  1106. A description of the accepted options follows:
  1107. @table @option
  1108. @item w, out_w
  1109. Set the crop area width. It defaults to @code{iw}.
  1110. This expression is evaluated only once during the filter
  1111. configuration.
  1112. @item h, out_h
  1113. Set the crop area width. It defaults to @code{ih}.
  1114. This expression is evaluated only once during the filter
  1115. configuration.
  1116. @item x
  1117. Set the expression for the x top-left coordinate of the cropped area.
  1118. It defaults to @code{(in_w-out_w)/2}.
  1119. This expression is evaluated per-frame.
  1120. @item y
  1121. Set the expression for the y top-left coordinate of the cropped area.
  1122. It defaults to @code{(in_h-out_h)/2}.
  1123. This expression is evaluated per-frame.
  1124. @item keep_aspect
  1125. If set to 1 will force the output display aspect ratio
  1126. to be the same of the input, by changing the output sample aspect
  1127. ratio. It defaults to 0.
  1128. @end table
  1129. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1130. expressions containing the following constants:
  1131. @table @option
  1132. @item x, y
  1133. the computed values for @var{x} and @var{y}. They are evaluated for
  1134. each new frame.
  1135. @item in_w, in_h
  1136. the input width and height
  1137. @item iw, ih
  1138. same as @var{in_w} and @var{in_h}
  1139. @item out_w, out_h
  1140. the output (cropped) width and height
  1141. @item ow, oh
  1142. same as @var{out_w} and @var{out_h}
  1143. @item a
  1144. same as @var{iw} / @var{ih}
  1145. @item sar
  1146. input sample aspect ratio
  1147. @item dar
  1148. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1149. @item hsub, vsub
  1150. horizontal and vertical chroma subsample values. For example for the
  1151. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1152. @item n
  1153. the number of input frame, starting from 0
  1154. @item pos
  1155. the position in the file of the input frame, NAN if unknown
  1156. @item t
  1157. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1158. @end table
  1159. The expression for @var{out_w} may depend on the value of @var{out_h},
  1160. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1161. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1162. evaluated after @var{out_w} and @var{out_h}.
  1163. The @var{x} and @var{y} parameters specify the expressions for the
  1164. position of the top-left corner of the output (non-cropped) area. They
  1165. are evaluated for each frame. If the evaluated value is not valid, it
  1166. is approximated to the nearest valid value.
  1167. The expression for @var{x} may depend on @var{y}, and the expression
  1168. for @var{y} may depend on @var{x}.
  1169. @subsection Examples
  1170. @itemize
  1171. @item
  1172. Crop area with size 100x100 at position (12,34).
  1173. @example
  1174. crop=100:100:12:34
  1175. @end example
  1176. Using named options, the example above becomes:
  1177. @example
  1178. crop=w=100:h=100:x=12:y=34
  1179. @end example
  1180. @item
  1181. Crop the central input area with size 100x100:
  1182. @example
  1183. crop=100:100
  1184. @end example
  1185. @item
  1186. Crop the central input area with size 2/3 of the input video:
  1187. @example
  1188. crop=2/3*in_w:2/3*in_h
  1189. @end example
  1190. @item
  1191. Crop the input video central square:
  1192. @example
  1193. crop=in_h
  1194. @end example
  1195. @item
  1196. Delimit the rectangle with the top-left corner placed at position
  1197. 100:100 and the right-bottom corner corresponding to the right-bottom
  1198. corner of the input image:
  1199. @example
  1200. crop=in_w-100:in_h-100:100:100
  1201. @end example
  1202. @item
  1203. Crop 10 pixels from the left and right borders, and 20 pixels from
  1204. the top and bottom borders
  1205. @example
  1206. crop=in_w-2*10:in_h-2*20
  1207. @end example
  1208. @item
  1209. Keep only the bottom right quarter of the input image:
  1210. @example
  1211. crop=in_w/2:in_h/2:in_w/2:in_h/2
  1212. @end example
  1213. @item
  1214. Crop height for getting Greek harmony:
  1215. @example
  1216. crop=in_w:1/PHI*in_w
  1217. @end example
  1218. @item
  1219. Appply trembling effect:
  1220. @example
  1221. 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)
  1222. @end example
  1223. @item
  1224. Apply erratic camera effect depending on timestamp:
  1225. @example
  1226. 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)"
  1227. @end example
  1228. @item
  1229. Set x depending on the value of y:
  1230. @example
  1231. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  1232. @end example
  1233. @end itemize
  1234. @section cropdetect
  1235. Auto-detect crop size.
  1236. Calculate necessary cropping parameters and prints the recommended
  1237. parameters through the logging system. The detected dimensions
  1238. correspond to the non-black area of the input video.
  1239. It accepts the syntax:
  1240. @example
  1241. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  1242. @end example
  1243. @table @option
  1244. @item limit
  1245. Threshold, which can be optionally specified from nothing (0) to
  1246. everything (255), defaults to 24.
  1247. @item round
  1248. Value which the width/height should be divisible by, defaults to
  1249. 16. The offset is automatically adjusted to center the video. Use 2 to
  1250. get only even dimensions (needed for 4:2:2 video). 16 is best when
  1251. encoding to most video codecs.
  1252. @item reset
  1253. Counter that determines after how many frames cropdetect will reset
  1254. the previously detected largest video area and start over to detect
  1255. the current optimal crop area. Defaults to 0.
  1256. This can be useful when channel logos distort the video area. 0
  1257. indicates never reset and return the largest area encountered during
  1258. playback.
  1259. @end table
  1260. @section decimate
  1261. This filter drops frames that do not differ greatly from the previous
  1262. frame in order to reduce framerate. The main use of this filter is
  1263. for very-low-bitrate encoding (e.g. streaming over dialup modem), but
  1264. it could in theory be used for fixing movies that were
  1265. inverse-telecined incorrectly.
  1266. It accepts the following parameters:
  1267. @var{max}:@var{hi}:@var{lo}:@var{frac}.
  1268. @table @option
  1269. @item max
  1270. Set the maximum number of consecutive frames which can be dropped (if
  1271. positive), or the minimum interval between dropped frames (if
  1272. negative). If the value is 0, the frame is dropped unregarding the
  1273. number of previous sequentially dropped frames.
  1274. Default value is 0.
  1275. @item hi, lo, frac
  1276. Set the dropping threshold values.
  1277. Values for @var{hi} and @var{lo} are for 8x8 pixel blocks and
  1278. represent actual pixel value differences, so a threshold of 64
  1279. corresponds to 1 unit of difference for each pixel, or the same spread
  1280. out differently over the block.
  1281. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1282. than a threshold of @var{hi}, and if no more than @var{frac} blocks (1
  1283. meaning the whole image) differ by more than a threshold of @var{lo}.
  1284. Default value for @var{hi} is 64*12, default value for @var{lo} is
  1285. 64*5, and default value for @var{frac} is 0.33.
  1286. @end table
  1287. @section delogo
  1288. Suppress a TV station logo by a simple interpolation of the surrounding
  1289. pixels. Just set a rectangle covering the logo and watch it disappear
  1290. (and sometimes something even uglier appear - your mileage may vary).
  1291. The filter accepts parameters as a string of the form
  1292. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1293. @var{key}=@var{value} pairs, separated by ":".
  1294. The description of the accepted parameters follows.
  1295. @table @option
  1296. @item x, y
  1297. Specify the top left corner coordinates of the logo. They must be
  1298. specified.
  1299. @item w, h
  1300. Specify the width and height of the logo to clear. They must be
  1301. specified.
  1302. @item band, t
  1303. Specify the thickness of the fuzzy edge of the rectangle (added to
  1304. @var{w} and @var{h}). The default value is 4.
  1305. @item show
  1306. When set to 1, a green rectangle is drawn on the screen to simplify
  1307. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1308. @var{band} is set to 4. The default value is 0.
  1309. @end table
  1310. Some examples follow.
  1311. @itemize
  1312. @item
  1313. Set a rectangle covering the area with top left corner coordinates 0,0
  1314. and size 100x77, setting a band of size 10:
  1315. @example
  1316. delogo=0:0:100:77:10
  1317. @end example
  1318. @item
  1319. As the previous example, but use named options:
  1320. @example
  1321. delogo=x=0:y=0:w=100:h=77:band=10
  1322. @end example
  1323. @end itemize
  1324. @section deshake
  1325. Attempt to fix small changes in horizontal and/or vertical shift. This
  1326. filter helps remove camera shake from hand-holding a camera, bumping a
  1327. tripod, moving on a vehicle, etc.
  1328. The filter accepts parameters as a string of the form
  1329. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  1330. A description of the accepted parameters follows.
  1331. @table @option
  1332. @item x, y, w, h
  1333. Specify a rectangular area where to limit the search for motion
  1334. vectors.
  1335. If desired the search for motion vectors can be limited to a
  1336. rectangular area of the frame defined by its top left corner, width
  1337. and height. These parameters have the same meaning as the drawbox
  1338. filter which can be used to visualise the position of the bounding
  1339. box.
  1340. This is useful when simultaneous movement of subjects within the frame
  1341. might be confused for camera motion by the motion vector search.
  1342. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1343. then the full frame is used. This allows later options to be set
  1344. without specifying the bounding box for the motion vector search.
  1345. Default - search the whole frame.
  1346. @item rx, ry
  1347. Specify the maximum extent of movement in x and y directions in the
  1348. range 0-64 pixels. Default 16.
  1349. @item edge
  1350. Specify how to generate pixels to fill blanks at the edge of the
  1351. frame. An integer from 0 to 3 as follows:
  1352. @table @option
  1353. @item 0
  1354. Fill zeroes at blank locations
  1355. @item 1
  1356. Original image at blank locations
  1357. @item 2
  1358. Extruded edge value at blank locations
  1359. @item 3
  1360. Mirrored edge at blank locations
  1361. @end table
  1362. The default setting is mirror edge at blank locations.
  1363. @item blocksize
  1364. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1365. default 8.
  1366. @item contrast
  1367. Specify the contrast threshold for blocks. Only blocks with more than
  1368. the specified contrast (difference between darkest and lightest
  1369. pixels) will be considered. Range 1-255, default 125.
  1370. @item search
  1371. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  1372. search. Default - exhaustive search.
  1373. @item filename
  1374. If set then a detailed log of the motion search is written to the
  1375. specified file.
  1376. @end table
  1377. @section drawbox
  1378. Draw a colored box on the input image.
  1379. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1380. separated by ":".
  1381. The description of the accepted parameters follows.
  1382. @table @option
  1383. @item x, y
  1384. Specify the top left corner coordinates of the box. Default to 0.
  1385. @item width, w
  1386. @item height, h
  1387. Specify the width and height of the box, if 0 they are interpreted as
  1388. the input width and height. Default to 0.
  1389. @item color, c
  1390. Specify the color of the box to write, it can be the name of a color
  1391. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  1392. value @code{invert} is used, the box edge color is the same as the
  1393. video with inverted luma.
  1394. @item thickness, t
  1395. Set the thickness of the box edge. Default value is @code{4}.
  1396. @end table
  1397. If the key of the first options is omitted, the arguments are
  1398. interpreted according to the syntax
  1399. @var{x}:@var{y}:@var{width}:@var{height}:@var{color}:@var{thickness}.
  1400. Some examples follow:
  1401. @itemize
  1402. @item
  1403. Draw a black box around the edge of the input image:
  1404. @example
  1405. drawbox
  1406. @end example
  1407. @item
  1408. Draw a box with color red and an opacity of 50%:
  1409. @example
  1410. drawbox=10:20:200:60:red@@0.5
  1411. @end example
  1412. The previous example can be specified as:
  1413. @example
  1414. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  1415. @end example
  1416. @item
  1417. Fill the box with pink color:
  1418. @example
  1419. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  1420. @end example
  1421. @end itemize
  1422. @anchor{drawtext}
  1423. @section drawtext
  1424. Draw text string or text from specified file on top of video using the
  1425. libfreetype library.
  1426. To enable compilation of this filter you need to configure FFmpeg with
  1427. @code{--enable-libfreetype}.
  1428. @subsection Syntax
  1429. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1430. separated by ":".
  1431. The description of the accepted parameters follows.
  1432. @table @option
  1433. @item box
  1434. Used to draw a box around text using background color.
  1435. Value should be either 1 (enable) or 0 (disable).
  1436. The default value of @var{box} is 0.
  1437. @item boxcolor
  1438. The color to be used for drawing box around text.
  1439. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1440. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1441. The default value of @var{boxcolor} is "white".
  1442. @item draw
  1443. Set an expression which specifies if the text should be drawn. If the
  1444. expression evaluates to 0, the text is not drawn. This is useful for
  1445. specifying that the text should be drawn only when specific conditions
  1446. are met.
  1447. Default value is "1".
  1448. See below for the list of accepted constants and functions.
  1449. @item expansion
  1450. Select how the @var{text} is expanded. Can be either @code{none},
  1451. @code{strftime} (default for compatibity reasons but deprecated) or
  1452. @code{normal}. See the @ref{drawtext_expansion, Text expansion} section
  1453. below for details.
  1454. @item fix_bounds
  1455. If true, check and fix text coords to avoid clipping.
  1456. @item fontcolor
  1457. The color to be used for drawing fonts.
  1458. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1459. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1460. The default value of @var{fontcolor} is "black".
  1461. @item fontfile
  1462. The font file to be used for drawing text. Path must be included.
  1463. This parameter is mandatory.
  1464. @item fontsize
  1465. The font size to be used for drawing text.
  1466. The default value of @var{fontsize} is 16.
  1467. @item ft_load_flags
  1468. Flags to be used for loading the fonts.
  1469. The flags map the corresponding flags supported by libfreetype, and are
  1470. a combination of the following values:
  1471. @table @var
  1472. @item default
  1473. @item no_scale
  1474. @item no_hinting
  1475. @item render
  1476. @item no_bitmap
  1477. @item vertical_layout
  1478. @item force_autohint
  1479. @item crop_bitmap
  1480. @item pedantic
  1481. @item ignore_global_advance_width
  1482. @item no_recurse
  1483. @item ignore_transform
  1484. @item monochrome
  1485. @item linear_design
  1486. @item no_autohint
  1487. @item end table
  1488. @end table
  1489. Default value is "render".
  1490. For more information consult the documentation for the FT_LOAD_*
  1491. libfreetype flags.
  1492. @item shadowcolor
  1493. The color to be used for drawing a shadow behind the drawn text. It
  1494. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1495. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1496. The default value of @var{shadowcolor} is "black".
  1497. @item shadowx, shadowy
  1498. The x and y offsets for the text shadow position with respect to the
  1499. position of the text. They can be either positive or negative
  1500. values. Default value for both is "0".
  1501. @item tabsize
  1502. The size in number of spaces to use for rendering the tab.
  1503. Default value is 4.
  1504. @item timecode
  1505. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1506. format. It can be used with or without text parameter. @var{timecode_rate}
  1507. option must be specified.
  1508. @item timecode_rate, rate, r
  1509. Set the timecode frame rate (timecode only).
  1510. @item text
  1511. The text string to be drawn. The text must be a sequence of UTF-8
  1512. encoded characters.
  1513. This parameter is mandatory if no file is specified with the parameter
  1514. @var{textfile}.
  1515. @item textfile
  1516. A text file containing text to be drawn. The text must be a sequence
  1517. of UTF-8 encoded characters.
  1518. This parameter is mandatory if no text string is specified with the
  1519. parameter @var{text}.
  1520. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1521. @item reload
  1522. If set to 1, the @var{textfile} will be reloaded before each frame.
  1523. Be sure to update it atomically, or it may be read partially, or even fail.
  1524. @item x, y
  1525. The expressions which specify the offsets where text will be drawn
  1526. within the video frame. They are relative to the top/left border of the
  1527. output image.
  1528. The default value of @var{x} and @var{y} is "0".
  1529. See below for the list of accepted constants and functions.
  1530. @end table
  1531. The parameters for @var{x} and @var{y} are expressions containing the
  1532. following constants and functions:
  1533. @table @option
  1534. @item dar
  1535. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1536. @item hsub, vsub
  1537. horizontal and vertical chroma subsample values. For example for the
  1538. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1539. @item line_h, lh
  1540. the height of each text line
  1541. @item main_h, h, H
  1542. the input height
  1543. @item main_w, w, W
  1544. the input width
  1545. @item max_glyph_a, ascent
  1546. the maximum distance from the baseline to the highest/upper grid
  1547. coordinate used to place a glyph outline point, for all the rendered
  1548. glyphs.
  1549. It is a positive value, due to the grid's orientation with the Y axis
  1550. upwards.
  1551. @item max_glyph_d, descent
  1552. the maximum distance from the baseline to the lowest grid coordinate
  1553. used to place a glyph outline point, for all the rendered glyphs.
  1554. This is a negative value, due to the grid's orientation, with the Y axis
  1555. upwards.
  1556. @item max_glyph_h
  1557. maximum glyph height, that is the maximum height for all the glyphs
  1558. contained in the rendered text, it is equivalent to @var{ascent} -
  1559. @var{descent}.
  1560. @item max_glyph_w
  1561. maximum glyph width, that is the maximum width for all the glyphs
  1562. contained in the rendered text
  1563. @item n
  1564. the number of input frame, starting from 0
  1565. @item rand(min, max)
  1566. return a random number included between @var{min} and @var{max}
  1567. @item sar
  1568. input sample aspect ratio
  1569. @item t
  1570. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1571. @item text_h, th
  1572. the height of the rendered text
  1573. @item text_w, tw
  1574. the width of the rendered text
  1575. @item x, y
  1576. the x and y offset coordinates where the text is drawn.
  1577. These parameters allow the @var{x} and @var{y} expressions to refer
  1578. each other, so you can for example specify @code{y=x/dar}.
  1579. @end table
  1580. If libavfilter was built with @code{--enable-fontconfig}, then
  1581. @option{fontfile} can be a fontconfig pattern or omitted.
  1582. @anchor{drawtext_expansion}
  1583. @subsection Text expansion
  1584. If @option{expansion} is set to @code{strftime} (which is the default for
  1585. now), the filter recognizes strftime() sequences in the provided text and
  1586. expands them accordingly. Check the documentation of strftime(). This
  1587. feature is deprecated.
  1588. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  1589. If @option{expansion} is set to @code{normal} (which will be the default),
  1590. the following expansion mechanism is used.
  1591. The backslash character '\', followed by any character, always expands to
  1592. the second character.
  1593. Sequence of the form @code{%@{...@}} are expanded. The text between the
  1594. braces is a function name, possibly followed by arguments separated by ':'.
  1595. If the arguments contain special characters or delimiters (':' or '@}'),
  1596. they should be escaped.
  1597. Note that they probably must also be escaped as the value for the
  1598. @option{text} option in the filter argument string and as the filter
  1599. argument in the filter graph description, and possibly also for the shell,
  1600. that makes up to four levels of escaping; using a text file avoids these
  1601. problems.
  1602. The following functions are available:
  1603. @table @command
  1604. @item expr, e
  1605. The expression evaluation result.
  1606. It must take one argument specifying the expression to be evaluated,
  1607. which accepts the same constants and functions as the @var{x} and
  1608. @var{y} values. Note that not all constants should be used, for
  1609. example the text size is not known when evaluating the expression, so
  1610. the constants @var{text_w} and @var{text_h} will have an undefined
  1611. value.
  1612. @item gmtime
  1613. The time at which the filter is running, expressed in UTC.
  1614. It can accept an argument: a strftime() format string.
  1615. @item localtime
  1616. The time at which the filter is running, expressed in the local time zone.
  1617. It can accept an argument: a strftime() format string.
  1618. @item n, frame_num
  1619. The frame number, starting from 0.
  1620. @item pts
  1621. The timestamp of the current frame, in seconds, with microsecond accuracy.
  1622. @end table
  1623. @subsection Examples
  1624. Some examples follow.
  1625. @itemize
  1626. @item
  1627. Draw "Test Text" with font FreeSerif, using the default values for the
  1628. optional parameters.
  1629. @example
  1630. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1631. @end example
  1632. @item
  1633. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1634. and y=50 (counting from the top-left corner of the screen), text is
  1635. yellow with a red box around it. Both the text and the box have an
  1636. opacity of 20%.
  1637. @example
  1638. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1639. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1640. @end example
  1641. Note that the double quotes are not necessary if spaces are not used
  1642. within the parameter list.
  1643. @item
  1644. Show the text at the center of the video frame:
  1645. @example
  1646. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1647. @end example
  1648. @item
  1649. Show a text line sliding from right to left in the last row of the video
  1650. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1651. with no newlines.
  1652. @example
  1653. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1654. @end example
  1655. @item
  1656. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1657. @example
  1658. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1659. @end example
  1660. @item
  1661. Draw a single green letter "g", at the center of the input video.
  1662. The glyph baseline is placed at half screen height.
  1663. @example
  1664. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1665. @end example
  1666. @item
  1667. Show text for 1 second every 3 seconds:
  1668. @example
  1669. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  1670. @end example
  1671. @item
  1672. Use fontconfig to set the font. Note that the colons need to be escaped.
  1673. @example
  1674. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  1675. @end example
  1676. @item
  1677. Print the date of a real-time encoding (see strftime(3)):
  1678. @example
  1679. drawtext='fontfile=FreeSans.ttf:expansion=normal:text=%@{localtime:%a %b %d %Y@}'
  1680. @end example
  1681. @end itemize
  1682. For more information about libfreetype, check:
  1683. @url{http://www.freetype.org/}.
  1684. For more information about fontconfig, check:
  1685. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1686. @section edgedetect
  1687. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  1688. This filter accepts the following optional named parameters:
  1689. @table @option
  1690. @item low, high
  1691. Set low and high threshold values used by the Canny thresholding
  1692. algorithm.
  1693. The high threshold selects the "strong" edge pixels, which are then
  1694. connected through 8-connectivity with the "weak" edge pixels selected
  1695. by the low threshold.
  1696. @var{low} and @var{high} threshold values must be choosen in the range
  1697. [0,1], and @var{low} should be lesser or equal to @var{high}.
  1698. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  1699. is @code{50/255}.
  1700. @end table
  1701. Example:
  1702. @example
  1703. edgedetect=low=0.1:high=0.4
  1704. @end example
  1705. @section fade
  1706. Apply fade-in/out effect to input video.
  1707. The filter accepts parameters as a list of @var{key}=@var{value}
  1708. pairs, separated by ":". If the key of the first options is omitted,
  1709. the arguments are interpreted according to the syntax
  1710. @var{type}:@var{start_frame}:@var{nb_frames}.
  1711. A description of the accepted parameters follows.
  1712. @table @option
  1713. @item type, t
  1714. Specify if the effect type, can be either @code{in} for fade-in, or
  1715. @code{out} for a fade-out effect. Default is @code{in}.
  1716. @item start_frame, s
  1717. Specify the number of the start frame for starting to apply the fade
  1718. effect. Default is 0.
  1719. @item nb_frames, n
  1720. Specify the number of frames for which the fade effect has to last. At
  1721. the end of the fade-in effect the output video will have the same
  1722. intensity as the input video, at the end of the fade-out transition
  1723. the output video will be completely black. Default is 25.
  1724. @item alpha
  1725. If set to 1, fade only alpha channel, if one exists on the input.
  1726. Default value is 0.
  1727. @end table
  1728. @subsection Examples
  1729. @itemize
  1730. @item
  1731. Fade in first 30 frames of video:
  1732. @example
  1733. fade=in:0:30
  1734. @end example
  1735. The command above is equivalent to:
  1736. @example
  1737. fade=t=in:s=0:n=30
  1738. @end example
  1739. @item
  1740. Fade out last 45 frames of a 200-frame video:
  1741. @example
  1742. fade=out:155:45
  1743. @end example
  1744. @item
  1745. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  1746. @example
  1747. fade=in:0:25, fade=out:975:25
  1748. @end example
  1749. @item
  1750. Make first 5 frames black, then fade in from frame 5-24:
  1751. @example
  1752. fade=in:5:20
  1753. @end example
  1754. @item
  1755. Fade in alpha over first 25 frames of video:
  1756. @example
  1757. fade=in:0:25:alpha=1
  1758. @end example
  1759. @end itemize
  1760. @section field
  1761. Extract a single field from an interlaced image using stride
  1762. arithmetic to avoid wasting CPU time. The output frames are marked as
  1763. non-interlaced.
  1764. This filter accepts the following named options:
  1765. @table @option
  1766. @item type
  1767. Specify whether to extract the top (if the value is @code{0} or
  1768. @code{top}) or the bottom field (if the value is @code{1} or
  1769. @code{bottom}).
  1770. @end table
  1771. If the option key is not specified, the first value sets the @var{type}
  1772. option. For example:
  1773. @example
  1774. field=bottom
  1775. @end example
  1776. is equivalent to:
  1777. @example
  1778. field=type=bottom
  1779. @end example
  1780. @section fieldorder
  1781. Transform the field order of the input video.
  1782. It accepts one parameter which specifies the required field order that
  1783. the input interlaced video will be transformed to. The parameter can
  1784. assume one of the following values:
  1785. @table @option
  1786. @item 0 or bff
  1787. output bottom field first
  1788. @item 1 or tff
  1789. output top field first
  1790. @end table
  1791. Default value is "tff".
  1792. Transformation is achieved by shifting the picture content up or down
  1793. by one line, and filling the remaining line with appropriate picture content.
  1794. This method is consistent with most broadcast field order converters.
  1795. If the input video is not flagged as being interlaced, or it is already
  1796. flagged as being of the required output field order then this filter does
  1797. not alter the incoming video.
  1798. This filter is very useful when converting to or from PAL DV material,
  1799. which is bottom field first.
  1800. For example:
  1801. @example
  1802. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1803. @end example
  1804. @section fifo
  1805. Buffer input images and send them when they are requested.
  1806. This filter is mainly useful when auto-inserted by the libavfilter
  1807. framework.
  1808. The filter does not take parameters.
  1809. @section format
  1810. Convert the input video to one of the specified pixel formats.
  1811. Libavfilter will try to pick one that is supported for the input to
  1812. the next filter.
  1813. The filter accepts a list of pixel format names, separated by ":",
  1814. for example "yuv420p:monow:rgb24".
  1815. Some examples follow:
  1816. @example
  1817. # convert the input video to the format "yuv420p"
  1818. format=yuv420p
  1819. # convert the input video to any of the formats in the list
  1820. format=yuv420p:yuv444p:yuv410p
  1821. @end example
  1822. @section fps
  1823. Convert the video to specified constant framerate by duplicating or dropping
  1824. frames as necessary.
  1825. This filter accepts the following named parameters:
  1826. @table @option
  1827. @item fps
  1828. Desired output framerate. The default is @code{25}.
  1829. @item round
  1830. Rounding method.
  1831. Possible values are:
  1832. @table @option
  1833. @item zero
  1834. zero round towards 0
  1835. @item inf
  1836. round away from 0
  1837. @item down
  1838. round towards -infinity
  1839. @item up
  1840. round towards +infinity
  1841. @item near
  1842. round to nearest
  1843. @end table
  1844. The default is @code{near}.
  1845. @end table
  1846. Alternatively, the options can be specified as a flat string:
  1847. @var{fps}[:@var{round}].
  1848. See also the @ref{setpts} filter.
  1849. @section framestep
  1850. Select one frame every N.
  1851. This filter accepts in input a string representing a positive
  1852. integer. Default argument is @code{1}.
  1853. @anchor{frei0r}
  1854. @section frei0r
  1855. Apply a frei0r effect to the input video.
  1856. To enable compilation of this filter you need to install the frei0r
  1857. header and configure FFmpeg with @code{--enable-frei0r}.
  1858. The filter supports the syntax:
  1859. @example
  1860. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1861. @end example
  1862. @var{filter_name} is the name of the frei0r effect to load. If the
  1863. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1864. is searched in each one of the directories specified by the colon (or
  1865. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  1866. otherwise in the standard frei0r paths, which are in this order:
  1867. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  1868. @file{/usr/lib/frei0r-1/}.
  1869. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1870. for the frei0r effect.
  1871. A frei0r effect parameter can be a boolean (whose values are specified
  1872. with "y" and "n"), a double, a color (specified by the syntax
  1873. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1874. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1875. description), a position (specified by the syntax @var{X}/@var{Y},
  1876. @var{X} and @var{Y} being float numbers) and a string.
  1877. The number and kind of parameters depend on the loaded effect. If an
  1878. effect parameter is not specified the default value is set.
  1879. Some examples follow:
  1880. @itemize
  1881. @item
  1882. Apply the distort0r effect, set the first two double parameters:
  1883. @example
  1884. frei0r=distort0r:0.5:0.01
  1885. @end example
  1886. @item
  1887. Apply the colordistance effect, take a color as first parameter:
  1888. @example
  1889. frei0r=colordistance:0.2/0.3/0.4
  1890. frei0r=colordistance:violet
  1891. frei0r=colordistance:0x112233
  1892. @end example
  1893. @item
  1894. Apply the perspective effect, specify the top left and top right image
  1895. positions:
  1896. @example
  1897. frei0r=perspective:0.2/0.2:0.8/0.2
  1898. @end example
  1899. @end itemize
  1900. For more information see:
  1901. @url{http://frei0r.dyne.org}
  1902. @section geq
  1903. The filter takes one, two or three equations as parameter, separated by ':'.
  1904. The first equation is mandatory and applies to the luma plane. The two
  1905. following are respectively for chroma blue and chroma red planes.
  1906. The filter syntax allows named parameters:
  1907. @table @option
  1908. @item lum_expr
  1909. the luminance expression
  1910. @item cb_expr
  1911. the chrominance blue expression
  1912. @item cr_expr
  1913. the chrominance red expression
  1914. @end table
  1915. If one of the chrominance expression is not defined, it falls back on the other
  1916. one. If none of them are specified, they will evaluate the luminance
  1917. expression.
  1918. The expressions can use the following variables and functions:
  1919. @table @option
  1920. @item N
  1921. The sequential number of the filtered frame, starting from @code{0}.
  1922. @item X, Y
  1923. The coordinates of the current sample.
  1924. @item W, H
  1925. The width and height of the image.
  1926. @item SW, SH
  1927. Width and height scale depending on the currently filtered plane. It is the
  1928. ratio between the corresponding luma plane number of pixels and the current
  1929. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1930. @code{0.5,0.5} for chroma planes.
  1931. @item T
  1932. Time of the current frame, expressed in seconds.
  1933. @item p(x, y)
  1934. Return the value of the pixel at location (@var{x},@var{y}) of the current
  1935. plane.
  1936. @item lum(x, y)
  1937. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  1938. plane.
  1939. @item cb(x, y)
  1940. Return the value of the pixel at location (@var{x},@var{y}) of the
  1941. blue-difference chroma plane.
  1942. @item cr(x, y)
  1943. Return the value of the pixel at location (@var{x},@var{y}) of the
  1944. red-difference chroma plane.
  1945. @end table
  1946. For functions, if @var{x} and @var{y} are outside the area, the value will be
  1947. automatically clipped to the closer edge.
  1948. Some examples follow:
  1949. @itemize
  1950. @item
  1951. Flip the image horizontally:
  1952. @example
  1953. geq=p(W-X\,Y)
  1954. @end example
  1955. @item
  1956. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  1957. wavelength of 100 pixels:
  1958. @example
  1959. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  1960. @end example
  1961. @item
  1962. Generate a fancy enigmatic moving light:
  1963. @example
  1964. 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
  1965. @end example
  1966. @end itemize
  1967. @section gradfun
  1968. Fix the banding artifacts that are sometimes introduced into nearly flat
  1969. regions by truncation to 8bit color depth.
  1970. Interpolate the gradients that should go where the bands are, and
  1971. dither them.
  1972. This filter is designed for playback only. Do not use it prior to
  1973. lossy compression, because compression tends to lose the dither and
  1974. bring back the bands.
  1975. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  1976. separated by ":". A description of the accepted options follows.
  1977. @table @option
  1978. @item strength
  1979. The maximum amount by which the filter will change
  1980. any one pixel. Also the threshold for detecting nearly flat
  1981. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  1982. is @code{1.2}.
  1983. @item radius
  1984. The neighborhood to fit the gradient to. A larger
  1985. radius makes for smoother gradients, but also prevents the filter from
  1986. modifying the pixels near detailed regions. Acceptable values are
  1987. @code{8-32}, default value is @code{16}.
  1988. @end table
  1989. Alternatively, the options can be specified as a flat string:
  1990. @var{strength}[:@var{radius}]
  1991. @subsection Examples
  1992. @itemize
  1993. @item
  1994. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  1995. @example
  1996. gradfun=3.5:8
  1997. @end example
  1998. @item
  1999. Specify radius, omitting the strength (which will fall-back to the default
  2000. value):
  2001. @example
  2002. gradfun=radius=8
  2003. @end example
  2004. @end itemize
  2005. @section hflip
  2006. Flip the input video horizontally.
  2007. For example to horizontally flip the input video with @command{ffmpeg}:
  2008. @example
  2009. ffmpeg -i in.avi -vf "hflip" out.avi
  2010. @end example
  2011. @section histeq
  2012. This filter applies a global color histogram equalization on a
  2013. per-frame basis.
  2014. It can be used to correct video that has a compressed range of pixel
  2015. intensities. The filter redistributes the pixel intensities to
  2016. equalize their distribution across the intensity range. It may be
  2017. viewed as an "automatically adjusting contrast filter". This filter is
  2018. useful only for correcting degraded or poorly captured source
  2019. video.
  2020. The filter accepts parameters as a list of @var{key}=@var{value}
  2021. pairs, separated by ":". If the key of the first options is omitted,
  2022. the arguments are interpreted according to syntax
  2023. @var{strength}:@var{intensity}:@var{antibanding}.
  2024. This filter accepts the following named options:
  2025. @table @option
  2026. @item strength
  2027. Determine the amount of equalization to be applied. As the strength
  2028. is reduced, the distribution of pixel intensities more-and-more
  2029. approaches that of the input frame. The value must be a float number
  2030. in the range [0,1] and defaults to 0.200.
  2031. @item intensity
  2032. Set the maximum intensity that can generated and scale the output
  2033. values appropriately. The strength should be set as desired and then
  2034. the intensity can be limited if needed to avoid washing-out. The value
  2035. must be a float number in the range [0,1] and defaults to 0.210.
  2036. @item antibanding
  2037. Set the antibanding level. If enabled the filter will randomly vary
  2038. the luminance of output pixels by a small amount to avoid banding of
  2039. the histogram. Possible values are @code{none}, @code{weak} or
  2040. @code{strong}. It defaults to @code{none}.
  2041. @end table
  2042. @section hqdn3d
  2043. High precision/quality 3d denoise filter. This filter aims to reduce
  2044. image noise producing smooth images and making still images really
  2045. still. It should enhance compressibility.
  2046. It accepts the following optional parameters:
  2047. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2048. @table @option
  2049. @item luma_spatial
  2050. a non-negative float number which specifies spatial luma strength,
  2051. defaults to 4.0
  2052. @item chroma_spatial
  2053. a non-negative float number which specifies spatial chroma strength,
  2054. defaults to 3.0*@var{luma_spatial}/4.0
  2055. @item luma_tmp
  2056. a float number which specifies luma temporal strength, defaults to
  2057. 6.0*@var{luma_spatial}/4.0
  2058. @item chroma_tmp
  2059. a float number which specifies chroma temporal strength, defaults to
  2060. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2061. @end table
  2062. @section hue
  2063. Modify the hue and/or the saturation of the input.
  2064. This filter accepts the following optional named options:
  2065. @table @option
  2066. @item h
  2067. Specify the hue angle as a number of degrees. It accepts a float
  2068. number or an expression, and defaults to 0.0.
  2069. @item H
  2070. Specify the hue angle as a number of degrees. It accepts a float
  2071. number or an expression, and defaults to 0.0.
  2072. @item s
  2073. Specify the saturation in the [-10,10] range. It accepts a float number and
  2074. defaults to 1.0.
  2075. @end table
  2076. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2077. following constants:
  2078. @table @option
  2079. @item n
  2080. frame count of the input frame starting from 0
  2081. @item pts
  2082. presentation timestamp of the input frame expressed in time base units
  2083. @item r
  2084. frame rate of the input video, NAN if the input frame rate is unknown
  2085. @item t
  2086. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2087. @item tb
  2088. time base of the input video
  2089. @end table
  2090. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2091. In this case @var{hue} is expressed in degrees.
  2092. Some examples follow:
  2093. @itemize
  2094. @item
  2095. Set the hue to 90 degrees and the saturation to 1.0:
  2096. @example
  2097. hue=h=90:s=1
  2098. @end example
  2099. @item
  2100. Same command but expressing the hue in radians:
  2101. @example
  2102. hue=H=PI/2:s=1
  2103. @end example
  2104. @item
  2105. Same command without named options, hue must be expressed in degrees:
  2106. @example
  2107. hue=90:1
  2108. @end example
  2109. @item
  2110. Note that "h:s" syntax does not support expressions for the values of
  2111. h and s, so the following example will issue an error:
  2112. @example
  2113. hue=PI/2:1
  2114. @end example
  2115. @item
  2116. Rotate hue and make the saturation swing between 0
  2117. and 2 over a period of 1 second:
  2118. @example
  2119. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2120. @end example
  2121. @item
  2122. Apply a 3 seconds saturation fade-in effect starting at 0:
  2123. @example
  2124. hue="s=min(t/3\,1)"
  2125. @end example
  2126. The general fade-in expression can be written as:
  2127. @example
  2128. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2129. @end example
  2130. @item
  2131. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2132. @example
  2133. hue="s=max(0\, min(1\, (8-t)/3))"
  2134. @end example
  2135. The general fade-out expression can be written as:
  2136. @example
  2137. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2138. @end example
  2139. @end itemize
  2140. @subsection Commands
  2141. This filter supports the following command:
  2142. @table @option
  2143. @item reinit
  2144. Modify the hue and/or the saturation of the input video.
  2145. The command accepts the same named options and syntax than when calling the
  2146. filter from the command-line.
  2147. If a parameter is omitted, it is kept at its current value.
  2148. @end table
  2149. @section idet
  2150. Interlaceing detect filter. This filter tries to detect if the input is
  2151. interlaced or progressive. Top or bottom field first.
  2152. @section kerndeint
  2153. Deinterlace input video by applying Donald Graft's adaptive kernel
  2154. deinterling. Work on interlaced parts of a video to produce
  2155. progressive frames.
  2156. This filter accepts parameters as a list of @var{key}=@var{value}
  2157. pairs, separated by ":". If the key of the first options is omitted,
  2158. the arguments are interpreted according to the following syntax:
  2159. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2160. The description of the accepted parameters follows.
  2161. @table @option
  2162. @item thresh
  2163. Set the threshold which affects the filter's tolerance when
  2164. determining if a pixel line must be processed. It must be an integer
  2165. in the range [0,255] and defaults to 10. A value of 0 will result in
  2166. applying the process on every pixels.
  2167. @item map
  2168. Paint pixels exceeding the threshold value to white if set to 1.
  2169. Default is 0.
  2170. @item order
  2171. Set the fields order. Swap fields if set to 1, leave fields alone if
  2172. 0. Default is 0.
  2173. @item sharp
  2174. Enable additional sharpening if set to 1. Default is 0.
  2175. @item twoway
  2176. Enable twoway sharpening if set to 1. Default is 0.
  2177. @end table
  2178. @subsection Examples
  2179. @itemize
  2180. @item
  2181. Apply default values:
  2182. @example
  2183. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2184. @end example
  2185. @item
  2186. Enable additional sharpening:
  2187. @example
  2188. kerndeint=sharp=1
  2189. @end example
  2190. @item
  2191. Paint processed pixels in white:
  2192. @example
  2193. kerndeint=map=1
  2194. @end example
  2195. @end itemize
  2196. @section lut, lutrgb, lutyuv
  2197. Compute a look-up table for binding each pixel component input value
  2198. to an output value, and apply it to input video.
  2199. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2200. to an RGB input video.
  2201. These filters accept in input a ":"-separated list of options, which
  2202. specify the expressions used for computing the lookup table for the
  2203. corresponding pixel component values.
  2204. The @var{lut} filter requires either YUV or RGB pixel formats in
  2205. input, and accepts the options:
  2206. @table @option
  2207. @item @var{c0} (first pixel component)
  2208. @item @var{c1} (second pixel component)
  2209. @item @var{c2} (third pixel component)
  2210. @item @var{c3} (fourth pixel component, corresponds to the alpha component)
  2211. @end table
  2212. The exact component associated to each option depends on the format in
  2213. input.
  2214. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2215. accepts the options:
  2216. @table @option
  2217. @item @var{r} (red component)
  2218. @item @var{g} (green component)
  2219. @item @var{b} (blue component)
  2220. @item @var{a} (alpha component)
  2221. @end table
  2222. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2223. accepts the options:
  2224. @table @option
  2225. @item @var{y} (Y/luminance component)
  2226. @item @var{u} (U/Cb component)
  2227. @item @var{v} (V/Cr component)
  2228. @item @var{a} (alpha component)
  2229. @end table
  2230. The expressions can contain the following constants and functions:
  2231. @table @option
  2232. @item w, h
  2233. the input width and height
  2234. @item val
  2235. input value for the pixel component
  2236. @item clipval
  2237. the input value clipped in the @var{minval}-@var{maxval} range
  2238. @item maxval
  2239. maximum value for the pixel component
  2240. @item minval
  2241. minimum value for the pixel component
  2242. @item negval
  2243. the negated value for the pixel component value clipped in the
  2244. @var{minval}-@var{maxval} range , it corresponds to the expression
  2245. "maxval-clipval+minval"
  2246. @item clip(val)
  2247. the computed value in @var{val} clipped in the
  2248. @var{minval}-@var{maxval} range
  2249. @item gammaval(gamma)
  2250. the computed gamma correction value of the pixel component value
  2251. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2252. expression
  2253. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2254. @end table
  2255. All expressions default to "val".
  2256. Some examples follow:
  2257. @example
  2258. # negate input video
  2259. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2260. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2261. # the above is the same as
  2262. lutrgb="r=negval:g=negval:b=negval"
  2263. lutyuv="y=negval:u=negval:v=negval"
  2264. # negate luminance
  2265. lutyuv=y=negval
  2266. # remove chroma components, turns the video into a graytone image
  2267. lutyuv="u=128:v=128"
  2268. # apply a luma burning effect
  2269. lutyuv="y=2*val"
  2270. # remove green and blue components
  2271. lutrgb="g=0:b=0"
  2272. # set a constant alpha channel value on input
  2273. format=rgba,lutrgb=a="maxval-minval/2"
  2274. # correct luminance gamma by a 0.5 factor
  2275. lutyuv=y=gammaval(0.5)
  2276. @end example
  2277. @section mp
  2278. Apply an MPlayer filter to the input video.
  2279. This filter provides a wrapper around most of the filters of
  2280. MPlayer/MEncoder.
  2281. This wrapper is considered experimental. Some of the wrapped filters
  2282. may not work properly and we may drop support for them, as they will
  2283. be implemented natively into FFmpeg. Thus you should avoid
  2284. depending on them when writing portable scripts.
  2285. The filters accepts the parameters:
  2286. @var{filter_name}[:=]@var{filter_params}
  2287. @var{filter_name} is the name of a supported MPlayer filter,
  2288. @var{filter_params} is a string containing the parameters accepted by
  2289. the named filter.
  2290. The list of the currently supported filters follows:
  2291. @table @var
  2292. @item detc
  2293. @item dint
  2294. @item divtc
  2295. @item down3dright
  2296. @item dsize
  2297. @item eq2
  2298. @item eq
  2299. @item fil
  2300. @item fspp
  2301. @item harddup
  2302. @item il
  2303. @item ilpack
  2304. @item ivtc
  2305. @item kerndeint
  2306. @item mcdeint
  2307. @item noise
  2308. @item ow
  2309. @item perspective
  2310. @item phase
  2311. @item pp7
  2312. @item pullup
  2313. @item qp
  2314. @item sab
  2315. @item softpulldown
  2316. @item softskip
  2317. @item spp
  2318. @item telecine
  2319. @item tinterlace
  2320. @item unsharp
  2321. @item uspp
  2322. @end table
  2323. The parameter syntax and behavior for the listed filters are the same
  2324. of the corresponding MPlayer filters. For detailed instructions check
  2325. the "VIDEO FILTERS" section in the MPlayer manual.
  2326. Some examples follow:
  2327. @itemize
  2328. @item
  2329. Adjust gamma, brightness, contrast:
  2330. @example
  2331. mp=eq2=1.0:2:0.5
  2332. @end example
  2333. @item
  2334. Add temporal noise to input video:
  2335. @example
  2336. mp=noise=20t
  2337. @end example
  2338. @end itemize
  2339. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2340. @section negate
  2341. Negate input video.
  2342. This filter accepts an integer in input, if non-zero it negates the
  2343. alpha component (if available). The default value in input is 0.
  2344. @section noformat
  2345. Force libavfilter not to use any of the specified pixel formats for the
  2346. input to the next filter.
  2347. The filter accepts a list of pixel format names, separated by ":",
  2348. for example "yuv420p:monow:rgb24".
  2349. Some examples follow:
  2350. @example
  2351. # force libavfilter to use a format different from "yuv420p" for the
  2352. # input to the vflip filter
  2353. noformat=yuv420p,vflip
  2354. # convert the input video to any of the formats not contained in the list
  2355. noformat=yuv420p:yuv444p:yuv410p
  2356. @end example
  2357. @section null
  2358. Pass the video source unchanged to the output.
  2359. @section ocv
  2360. Apply video transform using libopencv.
  2361. To enable this filter install libopencv library and headers and
  2362. configure FFmpeg with @code{--enable-libopencv}.
  2363. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2364. @var{filter_name} is the name of the libopencv filter to apply.
  2365. @var{filter_params} specifies the parameters to pass to the libopencv
  2366. filter. If not specified the default values are assumed.
  2367. Refer to the official libopencv documentation for more precise
  2368. information:
  2369. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2370. Follows the list of supported libopencv filters.
  2371. @anchor{dilate}
  2372. @subsection dilate
  2373. Dilate an image by using a specific structuring element.
  2374. This filter corresponds to the libopencv function @code{cvDilate}.
  2375. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2376. @var{struct_el} represents a structuring element, and has the syntax:
  2377. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2378. @var{cols} and @var{rows} represent the number of columns and rows of
  2379. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2380. point, and @var{shape} the shape for the structuring element, and
  2381. can be one of the values "rect", "cross", "ellipse", "custom".
  2382. If the value for @var{shape} is "custom", it must be followed by a
  2383. string of the form "=@var{filename}". The file with name
  2384. @var{filename} is assumed to represent a binary image, with each
  2385. printable character corresponding to a bright pixel. When a custom
  2386. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2387. or columns and rows of the read file are assumed instead.
  2388. The default value for @var{struct_el} is "3x3+0x0/rect".
  2389. @var{nb_iterations} specifies the number of times the transform is
  2390. applied to the image, and defaults to 1.
  2391. Follow some example:
  2392. @example
  2393. # use the default values
  2394. ocv=dilate
  2395. # dilate using a structuring element with a 5x5 cross, iterate two times
  2396. ocv=dilate=5x5+2x2/cross:2
  2397. # read the shape from the file diamond.shape, iterate two times
  2398. # the file diamond.shape may contain a pattern of characters like this:
  2399. # *
  2400. # ***
  2401. # *****
  2402. # ***
  2403. # *
  2404. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2405. ocv=0x0+2x2/custom=diamond.shape:2
  2406. @end example
  2407. @subsection erode
  2408. Erode an image by using a specific structuring element.
  2409. This filter corresponds to the libopencv function @code{cvErode}.
  2410. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2411. with the same syntax and semantics as the @ref{dilate} filter.
  2412. @subsection smooth
  2413. Smooth the input video.
  2414. The filter takes the following parameters:
  2415. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2416. @var{type} is the type of smooth filter to apply, and can be one of
  2417. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2418. "bilateral". The default value is "gaussian".
  2419. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2420. parameters whose meanings depend on smooth type. @var{param1} and
  2421. @var{param2} accept integer positive values or 0, @var{param3} and
  2422. @var{param4} accept float values.
  2423. The default value for @var{param1} is 3, the default value for the
  2424. other parameters is 0.
  2425. These parameters correspond to the parameters assigned to the
  2426. libopencv function @code{cvSmooth}.
  2427. @anchor{overlay}
  2428. @section overlay
  2429. Overlay one video on top of another.
  2430. It takes two inputs and one output, the first input is the "main"
  2431. video on which the second input is overlayed.
  2432. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2433. separated by ":". If the key of the first options is omitted, the
  2434. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2435. A description of the accepted options follows.
  2436. @table @option
  2437. @item x, y
  2438. Set the expression for the x and y coordinates of the overlayed video
  2439. on the main video. Default value is 0.
  2440. The @var{x} and @var{y} expressions can contain the following
  2441. parameters:
  2442. @table @option
  2443. @item main_w, main_h
  2444. main input width and height
  2445. @item W, H
  2446. same as @var{main_w} and @var{main_h}
  2447. @item overlay_w, overlay_h
  2448. overlay input width and height
  2449. @item w, h
  2450. same as @var{overlay_w} and @var{overlay_h}
  2451. @end table
  2452. @item rgb
  2453. If set to 1, force the filter to accept inputs in the RGB
  2454. color space. Default value is 0.
  2455. @end table
  2456. Be aware that frames are taken from each input video in timestamp
  2457. order, hence, if their initial timestamps differ, it is a a good idea
  2458. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2459. have them begin in the same zero timestamp, as it does the example for
  2460. the @var{movie} filter.
  2461. You can chain together more overlays but you should test the
  2462. efficiency of such approach.
  2463. @subsection Examples
  2464. @itemize
  2465. @item
  2466. Draw the overlay at 10 pixels from the bottom right corner of the main
  2467. video:
  2468. @example
  2469. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2470. @end example
  2471. Using named options the example above becomes:
  2472. @example
  2473. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2474. @end example
  2475. @item
  2476. Insert a transparent PNG logo in the bottom left corner of the input,
  2477. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2478. @example
  2479. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2480. @end example
  2481. @item
  2482. Insert 2 different transparent PNG logos (second logo on bottom
  2483. right corner) using the @command{ffmpeg} tool:
  2484. @example
  2485. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2486. @end example
  2487. @item
  2488. Add a transparent color layer on top of the main video, WxH specifies
  2489. the size of the main input to the overlay filter:
  2490. @example
  2491. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2492. @end example
  2493. @item
  2494. Play an original video and a filtered version (here with the deshake
  2495. filter) side by side using the @command{ffplay} tool:
  2496. @example
  2497. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2498. @end example
  2499. The above command is the same as:
  2500. @example
  2501. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2502. @end example
  2503. @item
  2504. Chain several overlays in cascade:
  2505. @example
  2506. nullsrc=s=200x200 [bg];
  2507. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2508. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2509. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2510. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2511. [in3] null, [mid2] overlay=100:100 [out0]
  2512. @end example
  2513. @end itemize
  2514. @section pad
  2515. Add paddings to the input image, and places the original input at the
  2516. given coordinates @var{x}, @var{y}.
  2517. It accepts the following parameters:
  2518. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2519. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  2520. expressions containing the following constants:
  2521. @table @option
  2522. @item in_w, in_h
  2523. the input video width and height
  2524. @item iw, ih
  2525. same as @var{in_w} and @var{in_h}
  2526. @item out_w, out_h
  2527. the output width and height, that is the size of the padded area as
  2528. specified by the @var{width} and @var{height} expressions
  2529. @item ow, oh
  2530. same as @var{out_w} and @var{out_h}
  2531. @item x, y
  2532. x and y offsets as specified by the @var{x} and @var{y}
  2533. expressions, or NAN if not yet specified
  2534. @item a
  2535. same as @var{iw} / @var{ih}
  2536. @item sar
  2537. input sample aspect ratio
  2538. @item dar
  2539. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2540. @item hsub, vsub
  2541. horizontal and vertical chroma subsample values. For example for the
  2542. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2543. @end table
  2544. Follows the description of the accepted parameters.
  2545. @table @option
  2546. @item width, height
  2547. Specify the size of the output image with the paddings added. If the
  2548. value for @var{width} or @var{height} is 0, the corresponding input size
  2549. is used for the output.
  2550. The @var{width} expression can reference the value set by the
  2551. @var{height} expression, and vice versa.
  2552. The default value of @var{width} and @var{height} is 0.
  2553. @item x, y
  2554. Specify the offsets where to place the input image in the padded area
  2555. with respect to the top/left border of the output image.
  2556. The @var{x} expression can reference the value set by the @var{y}
  2557. expression, and vice versa.
  2558. The default value of @var{x} and @var{y} is 0.
  2559. @item color
  2560. Specify the color of the padded area, it can be the name of a color
  2561. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2562. The default value of @var{color} is "black".
  2563. @end table
  2564. @subsection Examples
  2565. @itemize
  2566. @item
  2567. Add paddings with color "violet" to the input video. Output video
  2568. size is 640x480, the top-left corner of the input video is placed at
  2569. column 0, row 40:
  2570. @example
  2571. pad=640:480:0:40:violet
  2572. @end example
  2573. @item
  2574. Pad the input to get an output with dimensions increased by 3/2,
  2575. and put the input video at the center of the padded area:
  2576. @example
  2577. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  2578. @end example
  2579. @item
  2580. Pad the input to get a squared output with size equal to the maximum
  2581. value between the input width and height, and put the input video at
  2582. the center of the padded area:
  2583. @example
  2584. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  2585. @end example
  2586. @item
  2587. Pad the input to get a final w/h ratio of 16:9:
  2588. @example
  2589. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  2590. @end example
  2591. @item
  2592. In case of anamorphic video, in order to set the output display aspect
  2593. correctly, it is necessary to use @var{sar} in the expression,
  2594. according to the relation:
  2595. @example
  2596. (ih * X / ih) * sar = output_dar
  2597. X = output_dar / sar
  2598. @end example
  2599. Thus the previous example needs to be modified to:
  2600. @example
  2601. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  2602. @end example
  2603. @item
  2604. Double output size and put the input video in the bottom-right
  2605. corner of the output padded area:
  2606. @example
  2607. pad="2*iw:2*ih:ow-iw:oh-ih"
  2608. @end example
  2609. @end itemize
  2610. @section pixdesctest
  2611. Pixel format descriptor test filter, mainly useful for internal
  2612. testing. The output video should be equal to the input video.
  2613. For example:
  2614. @example
  2615. format=monow, pixdesctest
  2616. @end example
  2617. can be used to test the monowhite pixel format descriptor definition.
  2618. @section pp
  2619. Enable the specified chain of postprocessing subfilters using libpostproc. This
  2620. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  2621. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  2622. Each subfilter and some options have a short and a long name that can be used
  2623. interchangeably, i.e. dr/dering are the same.
  2624. All subfilters share common options to determine their scope:
  2625. @table @option
  2626. @item a/autoq
  2627. Honor the quality commands for this subfilter.
  2628. @item c/chrom
  2629. Do chrominance filtering, too (default).
  2630. @item y/nochrom
  2631. Do luminance filtering only (no chrominance).
  2632. @item n/noluma
  2633. Do chrominance filtering only (no luminance).
  2634. @end table
  2635. These options can be appended after the subfilter name, separated by a ':'.
  2636. Available subfilters are:
  2637. @table @option
  2638. @item hb/hdeblock[:difference[:flatness]]
  2639. Horizontal deblocking filter
  2640. @table @option
  2641. @item difference
  2642. Difference factor where higher values mean more deblocking (default: @code{32}).
  2643. @item flatness
  2644. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2645. @end table
  2646. @item vb/vdeblock[:difference[:flatness]]
  2647. Vertical deblocking filter
  2648. @table @option
  2649. @item difference
  2650. Difference factor where higher values mean more deblocking (default: @code{32}).
  2651. @item flatness
  2652. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2653. @end table
  2654. @item ha/hadeblock[:difference[:flatness]]
  2655. Accurate horizontal deblocking filter
  2656. @table @option
  2657. @item difference
  2658. Difference factor where higher values mean more deblocking (default: @code{32}).
  2659. @item flatness
  2660. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2661. @end table
  2662. @item va/vadeblock[:difference[:flatness]]
  2663. Accurate vertical deblocking filter
  2664. @table @option
  2665. @item difference
  2666. Difference factor where higher values mean more deblocking (default: @code{32}).
  2667. @item flatness
  2668. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2669. @end table
  2670. @end table
  2671. The horizontal and vertical deblocking filters share the difference and
  2672. flatness values so you cannot set different horizontal and vertical
  2673. thresholds.
  2674. @table @option
  2675. @item h1/x1hdeblock
  2676. Experimental horizontal deblocking filter
  2677. @item v1/x1vdeblock
  2678. Experimental vertical deblocking filter
  2679. @item dr/dering
  2680. Deringing filter
  2681. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  2682. @table @option
  2683. @item threshold1
  2684. larger -> stronger filtering
  2685. @item threshold2
  2686. larger -> stronger filtering
  2687. @item threshold3
  2688. larger -> stronger filtering
  2689. @end table
  2690. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  2691. @table @option
  2692. @item f/fullyrange
  2693. Stretch luminance to @code{0-255}.
  2694. @end table
  2695. @item lb/linblenddeint
  2696. Linear blend deinterlacing filter that deinterlaces the given block by
  2697. filtering all lines with a @code{(1 2 1)} filter.
  2698. @item li/linipoldeint
  2699. Linear interpolating deinterlacing filter that deinterlaces the given block by
  2700. linearly interpolating every second line.
  2701. @item ci/cubicipoldeint
  2702. Cubic interpolating deinterlacing filter deinterlaces the given block by
  2703. cubically interpolating every second line.
  2704. @item md/mediandeint
  2705. Median deinterlacing filter that deinterlaces the given block by applying a
  2706. median filter to every second line.
  2707. @item fd/ffmpegdeint
  2708. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  2709. second line with a @code{(-1 4 2 4 -1)} filter.
  2710. @item l5/lowpass5
  2711. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  2712. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  2713. @item fq/forceQuant[:quantizer]
  2714. Overrides the quantizer table from the input with the constant quantizer you
  2715. specify.
  2716. @table @option
  2717. @item quantizer
  2718. Quantizer to use
  2719. @end table
  2720. @item de/default
  2721. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  2722. @item fa/fast
  2723. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  2724. @item ac
  2725. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  2726. @end table
  2727. @subsection Examples
  2728. @itemize
  2729. @item
  2730. Apply horizontal and vertical deblocking, deringing and automatic
  2731. brightness/contrast:
  2732. @example
  2733. pp=hb/vb/dr/al
  2734. @end example
  2735. @item
  2736. Apply default filters without brightness/contrast correction:
  2737. @example
  2738. pp=de/-al
  2739. @end example
  2740. @item
  2741. Apply default filters and temporal denoiser:
  2742. @example
  2743. pp=default/tmpnoise:1:2:3
  2744. @end example
  2745. @item
  2746. Apply deblocking on luminance only, and switch vertical deblocking on or off
  2747. automatically depending on available CPU time:
  2748. @example
  2749. pp=hb:y/vb:a
  2750. @end example
  2751. @end itemize
  2752. @section removelogo
  2753. Suppress a TV station logo, using an image file to determine which
  2754. pixels comprise the logo. It works by filling in the pixels that
  2755. comprise the logo with neighboring pixels.
  2756. This filter requires one argument which specifies the filter bitmap
  2757. file, which can be any image format supported by libavformat. The
  2758. width and height of the image file must match those of the video
  2759. stream being processed.
  2760. Pixels in the provided bitmap image with a value of zero are not
  2761. considered part of the logo, non-zero pixels are considered part of
  2762. the logo. If you use white (255) for the logo and black (0) for the
  2763. rest, you will be safe. For making the filter bitmap, it is
  2764. recommended to take a screen capture of a black frame with the logo
  2765. visible, and then using a threshold filter followed by the erode
  2766. filter once or twice.
  2767. If needed, little splotches can be fixed manually. Remember that if
  2768. logo pixels are not covered, the filter quality will be much
  2769. reduced. Marking too many pixels as part of the logo does not hurt as
  2770. much, but it will increase the amount of blurring needed to cover over
  2771. the image and will destroy more information than necessary, and extra
  2772. pixels will slow things down on a large logo.
  2773. @section scale
  2774. Scale (resize) the input video, using the libswscale library.
  2775. The scale filter forces the output display aspect ratio to be the same
  2776. of the input, by changing the output sample aspect ratio.
  2777. This filter accepts a list of named options in the form of
  2778. @var{key}=@var{value} pairs separated by ":". If the key for the first
  2779. two options is not specified, the assumed keys for the first two
  2780. values are @code{w} and @code{h}. If the first option has no key and
  2781. can be interpreted like a video size specification, it will be used
  2782. to set the video size.
  2783. A description of the accepted options follows.
  2784. @table @option
  2785. @item width, w
  2786. Set the video width expression, default value is @code{iw}. See below
  2787. for the list of accepted constants.
  2788. @item height, h
  2789. Set the video heiht expression, default value is @code{ih}.
  2790. See below for the list of accepted constants.
  2791. @item interl
  2792. Set the interlacing. It accepts the following values:
  2793. @table @option
  2794. @item 1
  2795. force interlaced aware scaling
  2796. @item 0
  2797. do not apply interlaced scaling
  2798. @item -1
  2799. select interlaced aware scaling depending on whether the source frames
  2800. are flagged as interlaced or not
  2801. @end table
  2802. Default value is @code{0}.
  2803. @item flags
  2804. Set libswscale scaling flags. If not explictly specified the filter
  2805. applies a bilinear scaling algorithm.
  2806. @item size, s
  2807. Set the video size, the value must be a valid abbreviation or in the
  2808. form @var{width}x@var{height}.
  2809. @end table
  2810. The values of the @var{w} and @var{h} options are expressions
  2811. containing the following constants:
  2812. @table @option
  2813. @item in_w, in_h
  2814. the input width and height
  2815. @item iw, ih
  2816. same as @var{in_w} and @var{in_h}
  2817. @item out_w, out_h
  2818. the output (cropped) width and height
  2819. @item ow, oh
  2820. same as @var{out_w} and @var{out_h}
  2821. @item a
  2822. same as @var{iw} / @var{ih}
  2823. @item sar
  2824. input sample aspect ratio
  2825. @item dar
  2826. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2827. @item hsub, vsub
  2828. horizontal and vertical chroma subsample values. For example for the
  2829. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2830. @end table
  2831. If the input image format is different from the format requested by
  2832. the next filter, the scale filter will convert the input to the
  2833. requested format.
  2834. If the value for @var{width} or @var{height} is 0, the respective input
  2835. size is used for the output.
  2836. If the value for @var{width} or @var{height} is -1, the scale filter will
  2837. use, for the respective output size, a value that maintains the aspect
  2838. ratio of the input image.
  2839. @subsection Examples
  2840. @itemize
  2841. @item
  2842. Scale the input video to a size of 200x100:
  2843. @example
  2844. scale=200:100
  2845. @end example
  2846. This is equivalent to:
  2847. @example
  2848. scale=w=200:h=100
  2849. @end example
  2850. or:
  2851. @example
  2852. scale=200x100
  2853. @end example
  2854. @item
  2855. Specify a size abbreviation for the output size:
  2856. @example
  2857. scale=qcif
  2858. @end example
  2859. which can also be written as:
  2860. @example
  2861. scale=size=qcif
  2862. @end example
  2863. @item
  2864. Scale the input to 2x:
  2865. @example
  2866. scale=2*iw:2*ih
  2867. @end example
  2868. @item
  2869. The above is the same as:
  2870. @example
  2871. scale=2*in_w:2*in_h
  2872. @end example
  2873. @item
  2874. Scale the input to 2x with forced interlaced scaling:
  2875. @example
  2876. scale=2*iw:2*ih:interl=1
  2877. @end example
  2878. @item
  2879. Scale the input to half size:
  2880. @example
  2881. scale=iw/2:ih/2
  2882. @end example
  2883. @item
  2884. Increase the width, and set the height to the same size:
  2885. @example
  2886. scale=3/2*iw:ow
  2887. @end example
  2888. @item
  2889. Seek for Greek harmony:
  2890. @example
  2891. scale=iw:1/PHI*iw
  2892. scale=ih*PHI:ih
  2893. @end example
  2894. @item
  2895. Increase the height, and set the width to 3/2 of the height:
  2896. @example
  2897. scale=3/2*oh:3/5*ih
  2898. @end example
  2899. @item
  2900. Increase the size, but make the size a multiple of the chroma:
  2901. @example
  2902. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  2903. @end example
  2904. @item
  2905. Increase the width to a maximum of 500 pixels, keep the same input
  2906. aspect ratio:
  2907. @example
  2908. scale='min(500\, iw*3/2):-1'
  2909. @end example
  2910. @end itemize
  2911. @section setdar, setsar
  2912. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  2913. output video.
  2914. This is done by changing the specified Sample (aka Pixel) Aspect
  2915. Ratio, according to the following equation:
  2916. @example
  2917. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  2918. @end example
  2919. Keep in mind that the @code{setdar} filter does not modify the pixel
  2920. dimensions of the video frame. Also the display aspect ratio set by
  2921. this filter may be changed by later filters in the filterchain,
  2922. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  2923. applied.
  2924. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  2925. the filter output video.
  2926. Note that as a consequence of the application of this filter, the
  2927. output display aspect ratio will change according to the equation
  2928. above.
  2929. Keep in mind that the sample aspect ratio set by the @code{setsar}
  2930. filter may be changed by later filters in the filterchain, e.g. if
  2931. another "setsar" or a "setdar" filter is applied.
  2932. The @code{setdar} and @code{setsar} filters accept a string in the
  2933. form @var{num}:@var{den} expressing an aspect ratio, or the following
  2934. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  2935. separated by ":".
  2936. @table @option
  2937. @item max
  2938. Set the maximum integer value to use for expressing numerator and
  2939. denominator when reducing the expressed aspect ratio to a rational.
  2940. Default value is @code{100}.
  2941. @item r, ratio:
  2942. Set the aspect ratio used by the filter.
  2943. The parameter can be a floating point number string, an expression, or
  2944. a string of the form @var{num}:@var{den}, where @var{num} and
  2945. @var{den} are the numerator and denominator of the aspect ratio. If
  2946. the parameter is not specified, it is assumed the value "0".
  2947. In case the form "@var{num}:@var{den}" the @code{:} character should
  2948. be escaped.
  2949. @end table
  2950. If the keys are omitted in the named options list, the specifed values
  2951. are assumed to be @var{ratio} and @var{max} in that order.
  2952. For example to change the display aspect ratio to 16:9, specify:
  2953. @example
  2954. setdar='16:9'
  2955. @end example
  2956. The example above is equivalent to:
  2957. @example
  2958. setdar=1.77777
  2959. @end example
  2960. To change the sample aspect ratio to 10:11, specify:
  2961. @example
  2962. setsar='10:11'
  2963. @end example
  2964. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  2965. 1000 in the aspect ratio reduction, use the command:
  2966. @example
  2967. setdar=ratio='16:9':max=1000
  2968. @end example
  2969. @section setfield
  2970. Force field for the output video frame.
  2971. The @code{setfield} filter marks the interlace type field for the
  2972. output frames. It does not change the input frame, but only sets the
  2973. corresponding property, which affects how the frame is treated by
  2974. following filters (e.g. @code{fieldorder} or @code{yadif}).
  2975. This filter accepts a single option @option{mode}, which can be
  2976. specified either by setting @code{mode=VALUE} or setting the value
  2977. alone. Available values are:
  2978. @table @samp
  2979. @item auto
  2980. Keep the same field property.
  2981. @item bff
  2982. Mark the frame as bottom-field-first.
  2983. @item tff
  2984. Mark the frame as top-field-first.
  2985. @item prog
  2986. Mark the frame as progressive.
  2987. @end table
  2988. @section showinfo
  2989. Show a line containing various information for each input video frame.
  2990. The input video is not modified.
  2991. The shown line contains a sequence of key/value pairs of the form
  2992. @var{key}:@var{value}.
  2993. A description of each shown parameter follows:
  2994. @table @option
  2995. @item n
  2996. sequential number of the input frame, starting from 0
  2997. @item pts
  2998. Presentation TimeStamp of the input frame, expressed as a number of
  2999. time base units. The time base unit depends on the filter input pad.
  3000. @item pts_time
  3001. Presentation TimeStamp of the input frame, expressed as a number of
  3002. seconds
  3003. @item pos
  3004. position of the frame in the input stream, -1 if this information in
  3005. unavailable and/or meaningless (for example in case of synthetic video)
  3006. @item fmt
  3007. pixel format name
  3008. @item sar
  3009. sample aspect ratio of the input frame, expressed in the form
  3010. @var{num}/@var{den}
  3011. @item s
  3012. size of the input frame, expressed in the form
  3013. @var{width}x@var{height}
  3014. @item i
  3015. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3016. for bottom field first)
  3017. @item iskey
  3018. 1 if the frame is a key frame, 0 otherwise
  3019. @item type
  3020. picture type of the input frame ("I" for an I-frame, "P" for a
  3021. P-frame, "B" for a B-frame, "?" for unknown type).
  3022. Check also the documentation of the @code{AVPictureType} enum and of
  3023. the @code{av_get_picture_type_char} function defined in
  3024. @file{libavutil/avutil.h}.
  3025. @item checksum
  3026. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3027. @item plane_checksum
  3028. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3029. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3030. @end table
  3031. @section smartblur
  3032. Blur the input video without impacting the outlines.
  3033. The filter accepts the following parameters:
  3034. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3035. Parameters prefixed by @var{luma} indicate that they work on the
  3036. luminance of the pixels whereas parameters prefixed by @var{chroma}
  3037. refer to the chrominance of the pixels.
  3038. If the chroma parameters are not set, the luma parameters are used for
  3039. either the luminance and the chrominance of the pixels.
  3040. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  3041. range [0.1,5.0] that specifies the variance of the gaussian filter
  3042. used to blur the image (slower if larger).
  3043. @var{luma_strength} or @var{chroma_strength} must be a float number in
  3044. the range [-1.0,1.0] that configures the blurring. A value included in
  3045. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  3046. will sharpen the image.
  3047. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  3048. the range [-30,30] that is used as a coefficient to determine whether
  3049. a pixel should be blurred or not. A value of 0 will filter all the
  3050. image, a value included in [0,30] will filter flat areas and a value
  3051. included in [-30,0] will filter edges.
  3052. @anchor{subtitles}
  3053. @section subtitles
  3054. Draw subtitles on top of input video using the libass library.
  3055. To enable compilation of this filter you need to configure FFmpeg with
  3056. @code{--enable-libass}. This filter also requires a build with libavcodec and
  3057. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  3058. Alpha) subtitles format.
  3059. This filter accepts the following named options, expressed as a
  3060. sequence of @var{key}=@var{value} pairs, separated by ":".
  3061. @table @option
  3062. @item filename, f
  3063. Set the filename of the subtitle file to read. It must be specified.
  3064. @item original_size
  3065. Specify the size of the original video, the video for which the ASS file
  3066. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  3067. necessary to correctly scale the fonts if the aspect ratio has been changed.
  3068. @end table
  3069. If the first key is not specified, it is assumed that the first value
  3070. specifies the @option{filename}.
  3071. For example, to render the file @file{sub.srt} on top of the input
  3072. video, use the command:
  3073. @example
  3074. subtitles=sub.srt
  3075. @end example
  3076. which is equivalent to:
  3077. @example
  3078. subtitles=filename=sub.srt
  3079. @end example
  3080. @section split
  3081. Split input video into several identical outputs.
  3082. The filter accepts a single parameter which specifies the number of outputs. If
  3083. unspecified, it defaults to 2.
  3084. For example
  3085. @example
  3086. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  3087. @end example
  3088. will create 5 copies of the input video.
  3089. For example:
  3090. @example
  3091. [in] split [splitout1][splitout2];
  3092. [splitout1] crop=100:100:0:0 [cropout];
  3093. [splitout2] pad=200:200:100:100 [padout];
  3094. @end example
  3095. will create two separate outputs from the same input, one cropped and
  3096. one padded.
  3097. @section super2xsai
  3098. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3099. Interpolate) pixel art scaling algorithm.
  3100. Useful for enlarging pixel art images without reducing sharpness.
  3101. @section swapuv
  3102. Swap U & V plane.
  3103. @section thumbnail
  3104. Select the most representative frame in a given sequence of consecutive frames.
  3105. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3106. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3107. the next batch of @var{N} frames until the end.
  3108. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3109. value will result in a higher memory usage, so a high value is not recommended.
  3110. The following example extract one picture each 50 frames:
  3111. @example
  3112. thumbnail=50
  3113. @end example
  3114. Complete example of a thumbnail creation with @command{ffmpeg}:
  3115. @example
  3116. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3117. @end example
  3118. @section tile
  3119. Tile several successive frames together.
  3120. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3121. separated by ":". A description of the accepted options follows.
  3122. @table @option
  3123. @item layout
  3124. Set the grid size (i.e. the number of lines and columns) in the form
  3125. "@var{w}x@var{h}".
  3126. @item margin
  3127. Set the outer border margin in pixels.
  3128. @item padding
  3129. Set the inner border thickness (i.e. the number of pixels between frames). For
  3130. more advanced padding options (such as having different values for the edges),
  3131. refer to the pad video filter.
  3132. @item nb_frames
  3133. Set the maximum number of frames to render in the given area. It must be less
  3134. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3135. the area will be used.
  3136. @end table
  3137. Alternatively, the options can be specified as a flat string:
  3138. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3139. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  3140. nokey}) in a movie:
  3141. @example
  3142. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3143. @end example
  3144. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3145. duplicating each output frame to accomodate the originally detected frame
  3146. rate.
  3147. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3148. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3149. mixed flat and named options:
  3150. @example
  3151. tile=3x2:nb_frames=5:padding=7:margin=2
  3152. @end example
  3153. @section tinterlace
  3154. Perform various types of temporal field interlacing.
  3155. Frames are counted starting from 1, so the first input frame is
  3156. considered odd.
  3157. This filter accepts options in the form of @var{key}=@var{value} pairs
  3158. separated by ":".
  3159. Alternatively, the @var{mode} option can be specified as a value alone,
  3160. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3161. pairs.
  3162. A description of the accepted options follows.
  3163. @table @option
  3164. @item mode
  3165. Specify the mode of the interlacing. This option can also be specified
  3166. as a value alone. See below for a list of values for this option.
  3167. Available values are:
  3168. @table @samp
  3169. @item merge, 0
  3170. Move odd frames into the upper field, even into the lower field,
  3171. generating a double height frame at half framerate.
  3172. @item drop_odd, 1
  3173. Only output even frames, odd frames are dropped, generating a frame with
  3174. unchanged height at half framerate.
  3175. @item drop_even, 2
  3176. Only output odd frames, even frames are dropped, generating a frame with
  3177. unchanged height at half framerate.
  3178. @item pad, 3
  3179. Expand each frame to full height, but pad alternate lines with black,
  3180. generating a frame with double height at the same input framerate.
  3181. @item interleave_top, 4
  3182. Interleave the upper field from odd frames with the lower field from
  3183. even frames, generating a frame with unchanged height at half framerate.
  3184. @item interleave_bottom, 5
  3185. Interleave the lower field from odd frames with the upper field from
  3186. even frames, generating a frame with unchanged height at half framerate.
  3187. @item interlacex2, 6
  3188. Double frame rate with unchanged height. Frames are inserted each
  3189. containing the second temporal field from the previous input frame and
  3190. the first temporal field from the next input frame. This mode relies on
  3191. the top_field_first flag. Useful for interlaced video displays with no
  3192. field synchronisation.
  3193. @end table
  3194. Numeric values are deprecated but are accepted for backward
  3195. compatibility reasons.
  3196. Default mode is @code{merge}.
  3197. @item flags
  3198. Specify flags influencing the filter process.
  3199. Available value for @var{flags} is:
  3200. @table @option
  3201. @item low_pass_filter, vlfp
  3202. Enable vertical low-pass filtering in the filter.
  3203. Vertical low-pass filtering is required when creating an interlaced
  3204. destination from a progressive source which contains high-frequency
  3205. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3206. patterning.
  3207. Vertical low-pass filtering can only be enabled for @option{mode}
  3208. @var{interleave_top} and @var{interleave_bottom}.
  3209. @end table
  3210. @end table
  3211. @section transpose
  3212. Transpose rows with columns in the input video and optionally flip it.
  3213. The filter accepts parameters as a list of @var{key}=@var{value}
  3214. pairs, separated by ':'. If the key of the first options is omitted,
  3215. the arguments are interpreted according to the syntax
  3216. @var{dir}:@var{passthrough}.
  3217. @table @option
  3218. @item dir
  3219. Specify the transposition direction. Can assume the following values:
  3220. @table @samp
  3221. @item 0, 4
  3222. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3223. @example
  3224. L.R L.l
  3225. . . -> . .
  3226. l.r R.r
  3227. @end example
  3228. @item 1, 5
  3229. Rotate by 90 degrees clockwise, that is:
  3230. @example
  3231. L.R l.L
  3232. . . -> . .
  3233. l.r r.R
  3234. @end example
  3235. @item 2, 6
  3236. Rotate by 90 degrees counterclockwise, that is:
  3237. @example
  3238. L.R R.r
  3239. . . -> . .
  3240. l.r L.l
  3241. @end example
  3242. @item 3, 7
  3243. Rotate by 90 degrees clockwise and vertically flip, that is:
  3244. @example
  3245. L.R r.R
  3246. . . -> . .
  3247. l.r l.L
  3248. @end example
  3249. @end table
  3250. For values between 4-7, the transposition is only done if the input
  3251. video geometry is portrait and not landscape. These values are
  3252. deprecated, the @code{passthrough} option should be used instead.
  3253. @item passthrough
  3254. Do not apply the transposition if the input geometry matches the one
  3255. specified by the specified value. It accepts the following values:
  3256. @table @samp
  3257. @item none
  3258. Always apply transposition.
  3259. @item portrait
  3260. Preserve portrait geometry (when @var{height} >= @var{width}).
  3261. @item landscape
  3262. Preserve landscape geometry (when @var{width} >= @var{height}).
  3263. @end table
  3264. Default value is @code{none}.
  3265. @end table
  3266. For example to rotate by 90 degrees clockwise and preserve portrait
  3267. layout:
  3268. @example
  3269. transpose=dir=1:passthrough=portrait
  3270. @end example
  3271. The command above can also be specified as:
  3272. @example
  3273. transpose=1:portrait
  3274. @end example
  3275. @section unsharp
  3276. Sharpen or blur the input video.
  3277. It accepts the following parameters:
  3278. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3279. Negative values for the amount will blur the input video, while positive
  3280. values will sharpen. All parameters are optional and default to the
  3281. equivalent of the string '5:5:1.0:5:5:0.0'.
  3282. @table @option
  3283. @item luma_msize_x
  3284. Set the luma matrix horizontal size. It can be an integer between 3
  3285. and 13, default value is 5.
  3286. @item luma_msize_y
  3287. Set the luma matrix vertical size. It can be an integer between 3
  3288. and 13, default value is 5.
  3289. @item luma_amount
  3290. Set the luma effect strength. It can be a float number between -2.0
  3291. and 5.0, default value is 1.0.
  3292. @item chroma_msize_x
  3293. Set the chroma matrix horizontal size. It can be an integer between 3
  3294. and 13, default value is 5.
  3295. @item chroma_msize_y
  3296. Set the chroma matrix vertical size. It can be an integer between 3
  3297. and 13, default value is 5.
  3298. @item chroma_amount
  3299. Set the chroma effect strength. It can be a float number between -2.0
  3300. and 5.0, default value is 0.0.
  3301. @end table
  3302. @example
  3303. # Strong luma sharpen effect parameters
  3304. unsharp=7:7:2.5
  3305. # Strong blur of both luma and chroma parameters
  3306. unsharp=7:7:-2:7:7:-2
  3307. # Use the default values with @command{ffmpeg}
  3308. ffmpeg -i in.avi -vf "unsharp" out.mp4
  3309. @end example
  3310. @section vflip
  3311. Flip the input video vertically.
  3312. @example
  3313. ffmpeg -i in.avi -vf "vflip" out.avi
  3314. @end example
  3315. @section yadif
  3316. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3317. filter").
  3318. The filter accepts parameters as a list of @var{key}=@var{value}
  3319. pairs, separated by ":". If the key of the first options is omitted,
  3320. the arguments are interpreted according to syntax
  3321. @var{mode}:@var{parity}:@var{deint}.
  3322. The description of the accepted parameters follows.
  3323. @table @option
  3324. @item mode
  3325. Specify the interlacing mode to adopt. Accept one of the following
  3326. values:
  3327. @table @option
  3328. @item 0, send_frame
  3329. output 1 frame for each frame
  3330. @item 1, send_field
  3331. output 1 frame for each field
  3332. @item 2, send_frame_nospatial
  3333. like @code{send_frame} but skip spatial interlacing check
  3334. @item 3, send_field_nospatial
  3335. like @code{send_field} but skip spatial interlacing check
  3336. @end table
  3337. Default value is @code{send_frame}.
  3338. @item parity
  3339. Specify the picture field parity assumed for the input interlaced
  3340. video. Accept one of the following values:
  3341. @table @option
  3342. @item 0, tff
  3343. assume top field first
  3344. @item 1, bff
  3345. assume bottom field first
  3346. @item -1, auto
  3347. enable automatic detection
  3348. @end table
  3349. Default value is @code{auto}.
  3350. If interlacing is unknown or decoder does not export this information,
  3351. top field first will be assumed.
  3352. @item deint
  3353. Specify which frames to deinterlace. Accept one of the following
  3354. values:
  3355. @table @option
  3356. @item 0, all
  3357. deinterlace all frames
  3358. @item 1, interlaced
  3359. only deinterlace frames marked as interlaced
  3360. @end table
  3361. Default value is @code{all}.
  3362. @end table
  3363. @c man end VIDEO FILTERS
  3364. @chapter Video Sources
  3365. @c man begin VIDEO SOURCES
  3366. Below is a description of the currently available video sources.
  3367. @section buffer
  3368. Buffer video frames, and make them available to the filter chain.
  3369. This source is mainly intended for a programmatic use, in particular
  3370. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3371. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3372. separated by ":". A description of the accepted options follows.
  3373. @table @option
  3374. @item video_size
  3375. Specify the size (width and height) of the buffered video frames.
  3376. @item pix_fmt
  3377. A string representing the pixel format of the buffered video frames.
  3378. It may be a number corresponding to a pixel format, or a pixel format
  3379. name.
  3380. @item time_base
  3381. Specify the timebase assumed by the timestamps of the buffered frames.
  3382. @item time_base
  3383. Specify the frame rate expected for the video stream.
  3384. @item pixel_aspect
  3385. Specify the sample aspect ratio assumed by the video frames.
  3386. @item sws_param
  3387. Specify the optional parameters to be used for the scale filter which
  3388. is automatically inserted when an input change is detected in the
  3389. input size or format.
  3390. @end table
  3391. For example:
  3392. @example
  3393. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3394. @end example
  3395. will instruct the source to accept video frames with size 320x240 and
  3396. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3397. square pixels (1:1 sample aspect ratio).
  3398. Since the pixel format with name "yuv410p" corresponds to the number 6
  3399. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3400. this example corresponds to:
  3401. @example
  3402. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3403. @end example
  3404. Alternatively, the options can be specified as a flat string, but this
  3405. syntax is deprecated:
  3406. @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}]
  3407. @section cellauto
  3408. Create a pattern generated by an elementary cellular automaton.
  3409. The initial state of the cellular automaton can be defined through the
  3410. @option{filename}, and @option{pattern} options. If such options are
  3411. not specified an initial state is created randomly.
  3412. At each new frame a new row in the video is filled with the result of
  3413. the cellular automaton next generation. The behavior when the whole
  3414. frame is filled is defined by the @option{scroll} option.
  3415. This source accepts a list of options in the form of
  3416. @var{key}=@var{value} pairs separated by ":". A description of the
  3417. accepted options follows.
  3418. @table @option
  3419. @item filename, f
  3420. Read the initial cellular automaton state, i.e. the starting row, from
  3421. the specified file.
  3422. In the file, each non-whitespace character is considered an alive
  3423. cell, a newline will terminate the row, and further characters in the
  3424. file will be ignored.
  3425. @item pattern, p
  3426. Read the initial cellular automaton state, i.e. the starting row, from
  3427. the specified string.
  3428. Each non-whitespace character in the string is considered an alive
  3429. cell, a newline will terminate the row, and further characters in the
  3430. string will be ignored.
  3431. @item rate, r
  3432. Set the video rate, that is the number of frames generated per second.
  3433. Default is 25.
  3434. @item random_fill_ratio, ratio
  3435. Set the random fill ratio for the initial cellular automaton row. It
  3436. is a floating point number value ranging from 0 to 1, defaults to
  3437. 1/PHI.
  3438. This option is ignored when a file or a pattern is specified.
  3439. @item random_seed, seed
  3440. Set the seed for filling randomly the initial row, must be an integer
  3441. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3442. set to -1, the filter will try to use a good random seed on a best
  3443. effort basis.
  3444. @item rule
  3445. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3446. Default value is 110.
  3447. @item size, s
  3448. Set the size of the output video.
  3449. If @option{filename} or @option{pattern} is specified, the size is set
  3450. by default to the width of the specified initial state row, and the
  3451. height is set to @var{width} * PHI.
  3452. If @option{size} is set, it must contain the width of the specified
  3453. pattern string, and the specified pattern will be centered in the
  3454. larger row.
  3455. If a filename or a pattern string is not specified, the size value
  3456. defaults to "320x518" (used for a randomly generated initial state).
  3457. @item scroll
  3458. If set to 1, scroll the output upward when all the rows in the output
  3459. have been already filled. If set to 0, the new generated row will be
  3460. written over the top row just after the bottom row is filled.
  3461. Defaults to 1.
  3462. @item start_full, full
  3463. If set to 1, completely fill the output with generated rows before
  3464. outputting the first frame.
  3465. This is the default behavior, for disabling set the value to 0.
  3466. @item stitch
  3467. If set to 1, stitch the left and right row edges together.
  3468. This is the default behavior, for disabling set the value to 0.
  3469. @end table
  3470. @subsection Examples
  3471. @itemize
  3472. @item
  3473. Read the initial state from @file{pattern}, and specify an output of
  3474. size 200x400.
  3475. @example
  3476. cellauto=f=pattern:s=200x400
  3477. @end example
  3478. @item
  3479. Generate a random initial row with a width of 200 cells, with a fill
  3480. ratio of 2/3:
  3481. @example
  3482. cellauto=ratio=2/3:s=200x200
  3483. @end example
  3484. @item
  3485. Create a pattern generated by rule 18 starting by a single alive cell
  3486. centered on an initial row with width 100:
  3487. @example
  3488. cellauto=p=@@:s=100x400:full=0:rule=18
  3489. @end example
  3490. @item
  3491. Specify a more elaborated initial pattern:
  3492. @example
  3493. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3494. @end example
  3495. @end itemize
  3496. @section mandelbrot
  3497. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3498. point specified with @var{start_x} and @var{start_y}.
  3499. This source accepts a list of options in the form of
  3500. @var{key}=@var{value} pairs separated by ":". A description of the
  3501. accepted options follows.
  3502. @table @option
  3503. @item end_pts
  3504. Set the terminal pts value. Default value is 400.
  3505. @item end_scale
  3506. Set the terminal scale value.
  3507. Must be a floating point value. Default value is 0.3.
  3508. @item inner
  3509. Set the inner coloring mode, that is the algorithm used to draw the
  3510. Mandelbrot fractal internal region.
  3511. It shall assume one of the following values:
  3512. @table @option
  3513. @item black
  3514. Set black mode.
  3515. @item convergence
  3516. Show time until convergence.
  3517. @item mincol
  3518. Set color based on point closest to the origin of the iterations.
  3519. @item period
  3520. Set period mode.
  3521. @end table
  3522. Default value is @var{mincol}.
  3523. @item bailout
  3524. Set the bailout value. Default value is 10.0.
  3525. @item maxiter
  3526. Set the maximum of iterations performed by the rendering
  3527. algorithm. Default value is 7189.
  3528. @item outer
  3529. Set outer coloring mode.
  3530. It shall assume one of following values:
  3531. @table @option
  3532. @item iteration_count
  3533. Set iteration cound mode.
  3534. @item normalized_iteration_count
  3535. set normalized iteration count mode.
  3536. @end table
  3537. Default value is @var{normalized_iteration_count}.
  3538. @item rate, r
  3539. Set frame rate, expressed as number of frames per second. Default
  3540. value is "25".
  3541. @item size, s
  3542. Set frame size. Default value is "640x480".
  3543. @item start_scale
  3544. Set the initial scale value. Default value is 3.0.
  3545. @item start_x
  3546. Set the initial x position. Must be a floating point value between
  3547. -100 and 100. Default value is -0.743643887037158704752191506114774.
  3548. @item start_y
  3549. Set the initial y position. Must be a floating point value between
  3550. -100 and 100. Default value is -0.131825904205311970493132056385139.
  3551. @end table
  3552. @section mptestsrc
  3553. Generate various test patterns, as generated by the MPlayer test filter.
  3554. The size of the generated video is fixed, and is 256x256.
  3555. This source is useful in particular for testing encoding features.
  3556. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  3557. separated by ":". The description of the accepted options follows.
  3558. @table @option
  3559. @item rate, r
  3560. Specify the frame rate of the sourced video, as the number of frames
  3561. generated per second. It has to be a string in the format
  3562. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3563. number or a valid video frame rate abbreviation. The default value is
  3564. "25".
  3565. @item duration, d
  3566. Set the video duration of the sourced video. The accepted syntax is:
  3567. @example
  3568. [-]HH:MM:SS[.m...]
  3569. [-]S+[.m...]
  3570. @end example
  3571. See also the function @code{av_parse_time()}.
  3572. If not specified, or the expressed duration is negative, the video is
  3573. supposed to be generated forever.
  3574. @item test, t
  3575. Set the number or the name of the test to perform. Supported tests are:
  3576. @table @option
  3577. @item dc_luma
  3578. @item dc_chroma
  3579. @item freq_luma
  3580. @item freq_chroma
  3581. @item amp_luma
  3582. @item amp_chroma
  3583. @item cbp
  3584. @item mv
  3585. @item ring1
  3586. @item ring2
  3587. @item all
  3588. @end table
  3589. Default value is "all", which will cycle through the list of all tests.
  3590. @end table
  3591. For example the following:
  3592. @example
  3593. testsrc=t=dc_luma
  3594. @end example
  3595. will generate a "dc_luma" test pattern.
  3596. @section frei0r_src
  3597. Provide a frei0r source.
  3598. To enable compilation of this filter you need to install the frei0r
  3599. header and configure FFmpeg with @code{--enable-frei0r}.
  3600. The source supports the syntax:
  3601. @example
  3602. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  3603. @end example
  3604. @var{size} is the size of the video to generate, may be a string of the
  3605. form @var{width}x@var{height} or a frame size abbreviation.
  3606. @var{rate} is the rate of the video to generate, may be a string of
  3607. the form @var{num}/@var{den} or a frame rate abbreviation.
  3608. @var{src_name} is the name to the frei0r source to load. For more
  3609. information regarding frei0r and how to set the parameters read the
  3610. section @ref{frei0r} in the description of the video filters.
  3611. For example, to generate a frei0r partik0l source with size 200x200
  3612. and frame rate 10 which is overlayed on the overlay filter main input:
  3613. @example
  3614. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  3615. @end example
  3616. @section life
  3617. Generate a life pattern.
  3618. This source is based on a generalization of John Conway's life game.
  3619. The sourced input represents a life grid, each pixel represents a cell
  3620. which can be in one of two possible states, alive or dead. Every cell
  3621. interacts with its eight neighbours, which are the cells that are
  3622. horizontally, vertically, or diagonally adjacent.
  3623. At each interaction the grid evolves according to the adopted rule,
  3624. which specifies the number of neighbor alive cells which will make a
  3625. cell stay alive or born. The @option{rule} option allows to specify
  3626. the rule to adopt.
  3627. This source accepts a list of options in the form of
  3628. @var{key}=@var{value} pairs separated by ":". A description of the
  3629. accepted options follows.
  3630. @table @option
  3631. @item filename, f
  3632. Set the file from which to read the initial grid state. In the file,
  3633. each non-whitespace character is considered an alive cell, and newline
  3634. is used to delimit the end of each row.
  3635. If this option is not specified, the initial grid is generated
  3636. randomly.
  3637. @item rate, r
  3638. Set the video rate, that is the number of frames generated per second.
  3639. Default is 25.
  3640. @item random_fill_ratio, ratio
  3641. Set the random fill ratio for the initial random grid. It is a
  3642. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  3643. It is ignored when a file is specified.
  3644. @item random_seed, seed
  3645. Set the seed for filling the initial random grid, must be an integer
  3646. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3647. set to -1, the filter will try to use a good random seed on a best
  3648. effort basis.
  3649. @item rule
  3650. Set the life rule.
  3651. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  3652. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  3653. @var{NS} specifies the number of alive neighbor cells which make a
  3654. live cell stay alive, and @var{NB} the number of alive neighbor cells
  3655. which make a dead cell to become alive (i.e. to "born").
  3656. "s" and "b" can be used in place of "S" and "B", respectively.
  3657. Alternatively a rule can be specified by an 18-bits integer. The 9
  3658. high order bits are used to encode the next cell state if it is alive
  3659. for each number of neighbor alive cells, the low order bits specify
  3660. the rule for "borning" new cells. Higher order bits encode for an
  3661. higher number of neighbor cells.
  3662. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  3663. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  3664. Default value is "S23/B3", which is the original Conway's game of life
  3665. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  3666. cells, and will born a new cell if there are three alive cells around
  3667. a dead cell.
  3668. @item size, s
  3669. Set the size of the output video.
  3670. If @option{filename} is specified, the size is set by default to the
  3671. same size of the input file. If @option{size} is set, it must contain
  3672. the size specified in the input file, and the initial grid defined in
  3673. that file is centered in the larger resulting area.
  3674. If a filename is not specified, the size value defaults to "320x240"
  3675. (used for a randomly generated initial grid).
  3676. @item stitch
  3677. If set to 1, stitch the left and right grid edges together, and the
  3678. top and bottom edges also. Defaults to 1.
  3679. @item mold
  3680. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  3681. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  3682. value from 0 to 255.
  3683. @item life_color
  3684. Set the color of living (or new born) cells.
  3685. @item death_color
  3686. Set the color of dead cells. If @option{mold} is set, this is the first color
  3687. used to represent a dead cell.
  3688. @item mold_color
  3689. Set mold color, for definitely dead and moldy cells.
  3690. @end table
  3691. @subsection Examples
  3692. @itemize
  3693. @item
  3694. Read a grid from @file{pattern}, and center it on a grid of size
  3695. 300x300 pixels:
  3696. @example
  3697. life=f=pattern:s=300x300
  3698. @end example
  3699. @item
  3700. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  3701. @example
  3702. life=ratio=2/3:s=200x200
  3703. @end example
  3704. @item
  3705. Specify a custom rule for evolving a randomly generated grid:
  3706. @example
  3707. life=rule=S14/B34
  3708. @end example
  3709. @item
  3710. Full example with slow death effect (mold) using @command{ffplay}:
  3711. @example
  3712. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  3713. @end example
  3714. @end itemize
  3715. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  3716. The @code{color} source provides an uniformly colored input.
  3717. The @code{nullsrc} source returns unprocessed video frames. It is
  3718. mainly useful to be employed in analysis / debugging tools, or as the
  3719. source for filters which ignore the input data.
  3720. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  3721. detecting RGB vs BGR issues. You should see a red, green and blue
  3722. stripe from top to bottom.
  3723. The @code{smptebars} source generates a color bars pattern, based on
  3724. the SMPTE Engineering Guideline EG 1-1990.
  3725. The @code{testsrc} source generates a test video pattern, showing a
  3726. color pattern, a scrolling gradient and a timestamp. This is mainly
  3727. intended for testing purposes.
  3728. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  3729. separated by ":". The description of the accepted options follows.
  3730. @table @option
  3731. @item color, c
  3732. Specify the color of the source, only used in the @code{color}
  3733. source. It can be the name of a color (case insensitive match) or a
  3734. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  3735. default value is "black".
  3736. @item size, s
  3737. Specify the size of the sourced video, it may be a string of the form
  3738. @var{width}x@var{height}, or the name of a size abbreviation. The
  3739. default value is "320x240".
  3740. @item rate, r
  3741. Specify the frame rate of the sourced video, as the number of frames
  3742. generated per second. It has to be a string in the format
  3743. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3744. number or a valid video frame rate abbreviation. The default value is
  3745. "25".
  3746. @item sar
  3747. Set the sample aspect ratio of the sourced video.
  3748. @item duration, d
  3749. Set the video duration of the sourced video. The accepted syntax is:
  3750. @example
  3751. [-]HH[:MM[:SS[.m...]]]
  3752. [-]S+[.m...]
  3753. @end example
  3754. See also the function @code{av_parse_time()}.
  3755. If not specified, or the expressed duration is negative, the video is
  3756. supposed to be generated forever.
  3757. @item decimals, n
  3758. Set the number of decimals to show in the timestamp, only used in the
  3759. @code{testsrc} source.
  3760. The displayed timestamp value will correspond to the original
  3761. timestamp value multiplied by the power of 10 of the specified
  3762. value. Default value is 0.
  3763. @end table
  3764. For example the following:
  3765. @example
  3766. testsrc=duration=5.3:size=qcif:rate=10
  3767. @end example
  3768. will generate a video with a duration of 5.3 seconds, with size
  3769. 176x144 and a frame rate of 10 frames per second.
  3770. The following graph description will generate a red source
  3771. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  3772. frames per second.
  3773. @example
  3774. color=c=red@@0.2:s=qcif:r=10
  3775. @end example
  3776. If the input content is to be ignored, @code{nullsrc} can be used. The
  3777. following command generates noise in the luminance plane by employing
  3778. the @code{geq} filter:
  3779. @example
  3780. nullsrc=s=256x256, geq=random(1)*255:128:128
  3781. @end example
  3782. @c man end VIDEO SOURCES
  3783. @chapter Video Sinks
  3784. @c man begin VIDEO SINKS
  3785. Below is a description of the currently available video sinks.
  3786. @section buffersink
  3787. Buffer video frames, and make them available to the end of the filter
  3788. graph.
  3789. This sink is mainly intended for a programmatic use, in particular
  3790. through the interface defined in @file{libavfilter/buffersink.h}.
  3791. It does not require a string parameter in input, but you need to
  3792. specify a pointer to a list of supported pixel formats terminated by
  3793. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  3794. when initializing this sink.
  3795. @section nullsink
  3796. Null video sink, do absolutely nothing with the input video. It is
  3797. mainly useful as a template and to be employed in analysis / debugging
  3798. tools.
  3799. @c man end VIDEO SINKS
  3800. @chapter Multimedia Filters
  3801. @c man begin MULTIMEDIA FILTERS
  3802. Below is a description of the currently available multimedia filters.
  3803. @section aselect, select
  3804. Select frames to pass in output.
  3805. These filters accept a single option @option{expr} or @option{e}
  3806. specifying the select expression, which can be specified either by
  3807. specyfing @code{expr=VALUE} or specifying the expression
  3808. alone.
  3809. The select expression is evaluated for each input frame. If the
  3810. evaluation result is a non-zero value, the frame is selected and
  3811. passed to the output, otherwise it is discarded.
  3812. The expression can contain the following constants:
  3813. @table @option
  3814. @item n
  3815. the sequential number of the filtered frame, starting from 0
  3816. @item selected_n
  3817. the sequential number of the selected frame, starting from 0
  3818. @item prev_selected_n
  3819. the sequential number of the last selected frame, NAN if undefined
  3820. @item TB
  3821. timebase of the input timestamps
  3822. @item pts
  3823. the PTS (Presentation TimeStamp) of the filtered video frame,
  3824. expressed in @var{TB} units, NAN if undefined
  3825. @item t
  3826. the PTS (Presentation TimeStamp) of the filtered video frame,
  3827. expressed in seconds, NAN if undefined
  3828. @item prev_pts
  3829. the PTS of the previously filtered video frame, NAN if undefined
  3830. @item prev_selected_pts
  3831. the PTS of the last previously filtered video frame, NAN if undefined
  3832. @item prev_selected_t
  3833. the PTS of the last previously selected video frame, NAN if undefined
  3834. @item start_pts
  3835. the PTS of the first video frame in the video, NAN if undefined
  3836. @item start_t
  3837. the time of the first video frame in the video, NAN if undefined
  3838. @item pict_type @emph{(video only)}
  3839. the type of the filtered frame, can assume one of the following
  3840. values:
  3841. @table @option
  3842. @item I
  3843. @item P
  3844. @item B
  3845. @item S
  3846. @item SI
  3847. @item SP
  3848. @item BI
  3849. @end table
  3850. @item interlace_type @emph{(video only)}
  3851. the frame interlace type, can assume one of the following values:
  3852. @table @option
  3853. @item PROGRESSIVE
  3854. the frame is progressive (not interlaced)
  3855. @item TOPFIRST
  3856. the frame is top-field-first
  3857. @item BOTTOMFIRST
  3858. the frame is bottom-field-first
  3859. @end table
  3860. @item consumed_sample_n @emph{(audio only)}
  3861. the number of selected samples before the current frame
  3862. @item samples_n @emph{(audio only)}
  3863. the number of samples in the current frame
  3864. @item sample_rate @emph{(audio only)}
  3865. the input sample rate
  3866. @item key
  3867. 1 if the filtered frame is a key-frame, 0 otherwise
  3868. @item pos
  3869. the position in the file of the filtered frame, -1 if the information
  3870. is not available (e.g. for synthetic video)
  3871. @item scene @emph{(video only)}
  3872. value between 0 and 1 to indicate a new scene; a low value reflects a low
  3873. probability for the current frame to introduce a new scene, while a higher
  3874. value means the current frame is more likely to be one (see the example below)
  3875. @end table
  3876. The default value of the select expression is "1".
  3877. @subsection Examples
  3878. @itemize
  3879. @item
  3880. Select all frames in input:
  3881. @example
  3882. select
  3883. @end example
  3884. The example above is the same as:
  3885. @example
  3886. select=1
  3887. @end example
  3888. @item
  3889. Skip all frames:
  3890. @example
  3891. select=0
  3892. @end example
  3893. @item
  3894. Select only I-frames:
  3895. @example
  3896. select='eq(pict_type\,I)'
  3897. @end example
  3898. @item
  3899. Select one frame every 100:
  3900. @example
  3901. select='not(mod(n\,100))'
  3902. @end example
  3903. @item
  3904. Select only frames contained in the 10-20 time interval:
  3905. @example
  3906. select='gte(t\,10)*lte(t\,20)'
  3907. @end example
  3908. @item
  3909. Select only I frames contained in the 10-20 time interval:
  3910. @example
  3911. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  3912. @end example
  3913. @item
  3914. Select frames with a minimum distance of 10 seconds:
  3915. @example
  3916. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  3917. @end example
  3918. @item
  3919. Use aselect to select only audio frames with samples number > 100:
  3920. @example
  3921. aselect='gt(samples_n\,100)'
  3922. @end example
  3923. @item
  3924. Create a mosaic of the first scenes:
  3925. @example
  3926. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  3927. @end example
  3928. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  3929. choice.
  3930. @end itemize
  3931. @section asendcmd, sendcmd
  3932. Send commands to filters in the filtergraph.
  3933. These filters read commands to be sent to other filters in the
  3934. filtergraph.
  3935. @code{asendcmd} must be inserted between two audio filters,
  3936. @code{sendcmd} must be inserted between two video filters, but apart
  3937. from that they act the same way.
  3938. The specification of commands can be provided in the filter arguments
  3939. with the @var{commands} option, or in a file specified by the
  3940. @var{filename} option.
  3941. These filters accept the following options:
  3942. @table @option
  3943. @item commands, c
  3944. Set the commands to be read and sent to the other filters.
  3945. @item filename, f
  3946. Set the filename of the commands to be read and sent to the other
  3947. filters.
  3948. @end table
  3949. @subsection Commands syntax
  3950. A commands description consists of a sequence of interval
  3951. specifications, comprising a list of commands to be executed when a
  3952. particular event related to that interval occurs. The occurring event
  3953. is typically the current frame time entering or leaving a given time
  3954. interval.
  3955. An interval is specified by the following syntax:
  3956. @example
  3957. @var{START}[-@var{END}] @var{COMMANDS};
  3958. @end example
  3959. The time interval is specified by the @var{START} and @var{END} times.
  3960. @var{END} is optional and defaults to the maximum time.
  3961. The current frame time is considered within the specified interval if
  3962. it is included in the interval [@var{START}, @var{END}), that is when
  3963. the time is greater or equal to @var{START} and is lesser than
  3964. @var{END}.
  3965. @var{COMMANDS} consists of a sequence of one or more command
  3966. specifications, separated by ",", relating to that interval. The
  3967. syntax of a command specification is given by:
  3968. @example
  3969. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  3970. @end example
  3971. @var{FLAGS} is optional and specifies the type of events relating to
  3972. the time interval which enable sending the specified command, and must
  3973. be a non-null sequence of identifier flags separated by "+" or "|" and
  3974. enclosed between "[" and "]".
  3975. The following flags are recognized:
  3976. @table @option
  3977. @item enter
  3978. The command is sent when the current frame timestamp enters the
  3979. specified interval. In other words, the command is sent when the
  3980. previous frame timestamp was not in the given interval, and the
  3981. current is.
  3982. @item leave
  3983. The command is sent when the current frame timestamp leaves the
  3984. specified interval. In other words, the command is sent when the
  3985. previous frame timestamp was in the given interval, and the
  3986. current is not.
  3987. @end table
  3988. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  3989. assumed.
  3990. @var{TARGET} specifies the target of the command, usually the name of
  3991. the filter class or a specific filter instance name.
  3992. @var{COMMAND} specifies the name of the command for the target filter.
  3993. @var{ARG} is optional and specifies the optional list of argument for
  3994. the given @var{COMMAND}.
  3995. Between one interval specification and another, whitespaces, or
  3996. sequences of characters starting with @code{#} until the end of line,
  3997. are ignored and can be used to annotate comments.
  3998. A simplified BNF description of the commands specification syntax
  3999. follows:
  4000. @example
  4001. @var{COMMAND_FLAG} ::= "enter" | "leave"
  4002. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  4003. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  4004. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  4005. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  4006. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  4007. @end example
  4008. @subsection Examples
  4009. @itemize
  4010. @item
  4011. Specify audio tempo change at second 4:
  4012. @example
  4013. asendcmd=c='4.0 atempo tempo 1.5',atempo
  4014. @end example
  4015. @item
  4016. Specify a list of drawtext and hue commands in a file.
  4017. @example
  4018. # show text in the interval 5-10
  4019. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  4020. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  4021. # desaturate the image in the interval 15-20
  4022. 15.0-20.0 [enter] hue reinit s=0,
  4023. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  4024. [leave] hue reinit s=1,
  4025. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  4026. # apply an exponential saturation fade-out effect, starting from time 25
  4027. 25 [enter] hue s=exp(t-25)
  4028. @end example
  4029. A filtergraph allowing to read and process the above command list
  4030. stored in a file @file{test.cmd}, can be specified with:
  4031. @example
  4032. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  4033. @end example
  4034. @end itemize
  4035. @anchor{setpts}
  4036. @section asetpts, setpts
  4037. Change the PTS (presentation timestamp) of the input frames.
  4038. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  4039. Accept in input an expression evaluated through the eval API, which
  4040. can contain the following constants:
  4041. @table @option
  4042. @item FRAME_RATE
  4043. frame rate, only defined for constant frame-rate video
  4044. @item PTS
  4045. the presentation timestamp in input
  4046. @item N
  4047. the count of the input frame, starting from 0.
  4048. @item NB_CONSUMED_SAMPLES
  4049. the number of consumed samples, not including the current frame (only
  4050. audio)
  4051. @item NB_SAMPLES
  4052. the number of samples in the current frame (only audio)
  4053. @item SAMPLE_RATE
  4054. audio sample rate
  4055. @item STARTPTS
  4056. the PTS of the first frame
  4057. @item STARTT
  4058. the time in seconds of the first frame
  4059. @item INTERLACED
  4060. tell if the current frame is interlaced
  4061. @item T
  4062. the time in seconds of the current frame
  4063. @item TB
  4064. the time base
  4065. @item POS
  4066. original position in the file of the frame, or undefined if undefined
  4067. for the current frame
  4068. @item PREV_INPTS
  4069. previous input PTS
  4070. @item PREV_INT
  4071. previous input time in seconds
  4072. @item PREV_OUTPTS
  4073. previous output PTS
  4074. @item PREV_OUTT
  4075. previous output time in seconds
  4076. @end table
  4077. @subsection Examples
  4078. @itemize
  4079. @item
  4080. Start counting PTS from zero
  4081. @example
  4082. setpts=PTS-STARTPTS
  4083. @end example
  4084. @item
  4085. Apply fast motion effect:
  4086. @example
  4087. setpts=0.5*PTS
  4088. @end example
  4089. @item
  4090. Apply slow motion effect:
  4091. @example
  4092. setpts=2.0*PTS
  4093. @end example
  4094. @item
  4095. Set fixed rate of 25 frames per second:
  4096. @example
  4097. setpts=N/(25*TB)
  4098. @end example
  4099. @item
  4100. Set fixed rate 25 fps with some jitter:
  4101. @example
  4102. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4103. @end example
  4104. @item
  4105. Apply an offset of 10 seconds to the input PTS:
  4106. @example
  4107. setpts=PTS+10/TB
  4108. @end example
  4109. @end itemize
  4110. @section ebur128
  4111. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4112. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4113. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4114. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4115. The filter also has a video output (see the @var{video} option) with a real
  4116. time graph to observe the loudness evolution. The graphic contains the logged
  4117. message mentioned above, so it is not printed anymore when this option is set,
  4118. unless the verbose logging is set. The main graphing area contains the
  4119. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4120. the momentary loudness (400 milliseconds).
  4121. More information about the Loudness Recommendation EBU R128 on
  4122. @url{http://tech.ebu.ch/loudness}.
  4123. The filter accepts the following named parameters:
  4124. @table @option
  4125. @item video
  4126. Activate the video output. The audio stream is passed unchanged whether this
  4127. option is set or no. The video stream will be the first output stream if
  4128. activated. Default is @code{0}.
  4129. @item size
  4130. Set the video size. This option is for video only. Default and minimum
  4131. resolution is @code{640x480}.
  4132. @item meter
  4133. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4134. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4135. other integer value between this range is allowed.
  4136. @end table
  4137. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4138. @example
  4139. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4140. @end example
  4141. Run an analysis with @command{ffmpeg}:
  4142. @example
  4143. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4144. @end example
  4145. @section settb, asettb
  4146. Set the timebase to use for the output frames timestamps.
  4147. It is mainly useful for testing timebase configuration.
  4148. It accepts in input an arithmetic expression representing a rational.
  4149. The expression can contain the constants "AVTB" (the
  4150. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4151. audio only).
  4152. The default value for the input is "intb".
  4153. @subsection Examples
  4154. @itemize
  4155. @item
  4156. Set the timebase to 1/25:
  4157. @example
  4158. settb=1/25
  4159. @end example
  4160. @item
  4161. Set the timebase to 1/10:
  4162. @example
  4163. settb=0.1
  4164. @end example
  4165. @item
  4166. Set the timebase to 1001/1000:
  4167. @example
  4168. settb=1+0.001
  4169. @end example
  4170. @item
  4171. Set the timebase to 2*intb:
  4172. @example
  4173. settb=2*intb
  4174. @end example
  4175. @item
  4176. Set the default timebase value:
  4177. @example
  4178. settb=AVTB
  4179. @end example
  4180. @end itemize
  4181. @section concat
  4182. Concatenate audio and video streams, joining them together one after the
  4183. other.
  4184. The filter works on segments of synchronized video and audio streams. All
  4185. segments must have the same number of streams of each type, and that will
  4186. also be the number of streams at output.
  4187. The filter accepts the following named parameters:
  4188. @table @option
  4189. @item n
  4190. Set the number of segments. Default is 2.
  4191. @item v
  4192. Set the number of output video streams, that is also the number of video
  4193. streams in each segment. Default is 1.
  4194. @item a
  4195. Set the number of output audio streams, that is also the number of video
  4196. streams in each segment. Default is 0.
  4197. @item unsafe
  4198. Activate unsafe mode: do not fail if segments have a different format.
  4199. @end table
  4200. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4201. @var{a} audio outputs.
  4202. There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first
  4203. segment, in the same order as the outputs, then the inputs for the second
  4204. segment, etc.
  4205. Related streams do not always have exactly the same duration, for various
  4206. reasons including codec frame size or sloppy authoring. For that reason,
  4207. related synchronized streams (e.g. a video and its audio track) should be
  4208. concatenated at once. The concat filter will use the duration of the longest
  4209. stream in each segment (except the last one), and if necessary pad shorter
  4210. audio streams with silence.
  4211. For this filter to work correctly, all segments must start at timestamp 0.
  4212. All corresponding streams must have the same parameters in all segments; the
  4213. filtering system will automatically select a common pixel format for video
  4214. streams, and a common sample format, sample rate and channel layout for
  4215. audio streams, but other settings, such as resolution, must be converted
  4216. explicitly by the user.
  4217. Different frame rates are acceptable but will result in variable frame rate
  4218. at output; be sure to configure the output file to handle it.
  4219. Examples:
  4220. @itemize
  4221. @item
  4222. Concatenate an opening, an episode and an ending, all in bilingual version
  4223. (video in stream 0, audio in streams 1 and 2):
  4224. @example
  4225. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4226. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4227. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4228. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4229. @end example
  4230. @item
  4231. Concatenate two parts, handling audio and video separately, using the
  4232. (a)movie sources, and adjusting the resolution:
  4233. @example
  4234. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4235. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4236. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4237. @end example
  4238. Note that a desync will happen at the stitch if the audio and video streams
  4239. do not have exactly the same duration in the first file.
  4240. @end itemize
  4241. @section showspectrum
  4242. Convert input audio to a video output, representing the audio frequency
  4243. spectrum.
  4244. The filter accepts the following named parameters:
  4245. @table @option
  4246. @item size, s
  4247. Specify the video size for the output. Default value is @code{640x480}.
  4248. @item slide
  4249. Specify if the spectrum should slide along the window. Default value is
  4250. @code{0}.
  4251. @end table
  4252. The usage is very similar to the showwaves filter; see the examples in that
  4253. section.
  4254. @section showwaves
  4255. Convert input audio to a video output, representing the samples waves.
  4256. The filter accepts the following named parameters:
  4257. @table @option
  4258. @item n
  4259. Set the number of samples which are printed on the same column. A
  4260. larger value will decrease the frame rate. Must be a positive
  4261. integer. This option can be set only if the value for @var{rate}
  4262. is not explicitly specified.
  4263. @item rate, r
  4264. Set the (approximate) output frame rate. This is done by setting the
  4265. option @var{n}. Default value is "25".
  4266. @item size, s
  4267. Specify the video size for the output. Default value is "600x240".
  4268. @end table
  4269. Some examples follow.
  4270. @itemize
  4271. @item
  4272. Output the input file audio and the corresponding video representation
  4273. at the same time:
  4274. @example
  4275. amovie=a.mp3,asplit[out0],showwaves[out1]
  4276. @end example
  4277. @item
  4278. Create a synthetic signal and show it with showwaves, forcing a
  4279. framerate of 30 frames per second:
  4280. @example
  4281. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4282. @end example
  4283. @end itemize
  4284. @c man end MULTIMEDIA FILTERS
  4285. @chapter Multimedia Sources
  4286. @c man begin MULTIMEDIA SOURCES
  4287. Below is a description of the currently available multimedia sources.
  4288. @section amovie
  4289. This is the same as @ref{movie} source, except it selects an audio
  4290. stream by default.
  4291. @anchor{movie}
  4292. @section movie
  4293. Read audio and/or video stream(s) from a movie container.
  4294. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4295. @var{movie_name} is the name of the resource to read (not necessarily
  4296. a file but also a device or a stream accessed through some protocol),
  4297. and @var{options} is an optional sequence of @var{key}=@var{value}
  4298. pairs, separated by ":".
  4299. The description of the accepted options follows.
  4300. @table @option
  4301. @item format_name, f
  4302. Specifies the format assumed for the movie to read, and can be either
  4303. the name of a container or an input device. If not specified the
  4304. format is guessed from @var{movie_name} or by probing.
  4305. @item seek_point, sp
  4306. Specifies the seek point in seconds, the frames will be output
  4307. starting from this seek point, the parameter is evaluated with
  4308. @code{av_strtod} so the numerical value may be suffixed by an IS
  4309. postfix. Default value is "0".
  4310. @item streams, s
  4311. Specifies the streams to read. Several streams can be specified,
  4312. separated by "+". The source will then have as many outputs, in the
  4313. same order. The syntax is explained in the ``Stream specifiers''
  4314. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4315. respectively the default (best suited) video and audio stream. Default
  4316. is "dv", or "da" if the filter is called as "amovie".
  4317. @item stream_index, si
  4318. Specifies the index of the video stream to read. If the value is -1,
  4319. the best suited video stream will be automatically selected. Default
  4320. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4321. audio instead of video.
  4322. @item loop
  4323. Specifies how many times to read the stream in sequence.
  4324. If the value is less than 1, the stream will be read again and again.
  4325. Default value is "1".
  4326. Note that when the movie is looped the source timestamps are not
  4327. changed, so it will generate non monotonically increasing timestamps.
  4328. @end table
  4329. This filter allows to overlay a second video on top of main input of
  4330. a filtergraph as shown in this graph:
  4331. @example
  4332. input -----------> deltapts0 --> overlay --> output
  4333. ^
  4334. |
  4335. movie --> scale--> deltapts1 -------+
  4336. @end example
  4337. Some examples follow.
  4338. @itemize
  4339. @item
  4340. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4341. on top of the input labelled as "in":
  4342. @example
  4343. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4344. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4345. @end example
  4346. @item
  4347. Read from a video4linux2 device, and overlay it on top of the input
  4348. labelled as "in":
  4349. @example
  4350. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4351. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4352. @end example
  4353. @item
  4354. Read the first video stream and the audio stream with id 0x81 from
  4355. dvd.vob; the video is connected to the pad named "video" and the audio is
  4356. connected to the pad named "audio":
  4357. @example
  4358. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4359. @end example
  4360. @end itemize
  4361. @c man end MULTIMEDIA SOURCES