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.

5642 lines
157KB

  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 following syntax:
  1399. @example
  1400. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}:@var{thickness}
  1401. @end example
  1402. Some examples follow:
  1403. @itemize
  1404. @item
  1405. Draw a black box around the edge of the input image:
  1406. @example
  1407. drawbox
  1408. @end example
  1409. @item
  1410. Draw a box with color red and an opacity of 50%:
  1411. @example
  1412. drawbox=10:20:200:60:red@@0.5
  1413. @end example
  1414. The previous example can be specified as:
  1415. @example
  1416. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  1417. @end example
  1418. @item
  1419. Fill the box with pink color:
  1420. @example
  1421. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  1422. @end example
  1423. @end itemize
  1424. @anchor{drawtext}
  1425. @section drawtext
  1426. Draw text string or text from specified file on top of video using the
  1427. libfreetype library.
  1428. To enable compilation of this filter you need to configure FFmpeg with
  1429. @code{--enable-libfreetype}.
  1430. @subsection Syntax
  1431. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1432. separated by ":".
  1433. The description of the accepted parameters follows.
  1434. @table @option
  1435. @item box
  1436. Used to draw a box around text using background color.
  1437. Value should be either 1 (enable) or 0 (disable).
  1438. The default value of @var{box} is 0.
  1439. @item boxcolor
  1440. The color to be used for drawing box around text.
  1441. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1442. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1443. The default value of @var{boxcolor} is "white".
  1444. @item draw
  1445. Set an expression which specifies if the text should be drawn. If the
  1446. expression evaluates to 0, the text is not drawn. This is useful for
  1447. specifying that the text should be drawn only when specific conditions
  1448. are met.
  1449. Default value is "1".
  1450. See below for the list of accepted constants and functions.
  1451. @item expansion
  1452. Select how the @var{text} is expanded. Can be either @code{none},
  1453. @code{strftime} (default for compatibity reasons but deprecated) or
  1454. @code{normal}. See the @ref{drawtext_expansion, Text expansion} section
  1455. below for details.
  1456. @item fix_bounds
  1457. If true, check and fix text coords to avoid clipping.
  1458. @item fontcolor
  1459. The color to be used for drawing fonts.
  1460. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1461. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1462. The default value of @var{fontcolor} is "black".
  1463. @item fontfile
  1464. The font file to be used for drawing text. Path must be included.
  1465. This parameter is mandatory.
  1466. @item fontsize
  1467. The font size to be used for drawing text.
  1468. The default value of @var{fontsize} is 16.
  1469. @item ft_load_flags
  1470. Flags to be used for loading the fonts.
  1471. The flags map the corresponding flags supported by libfreetype, and are
  1472. a combination of the following values:
  1473. @table @var
  1474. @item default
  1475. @item no_scale
  1476. @item no_hinting
  1477. @item render
  1478. @item no_bitmap
  1479. @item vertical_layout
  1480. @item force_autohint
  1481. @item crop_bitmap
  1482. @item pedantic
  1483. @item ignore_global_advance_width
  1484. @item no_recurse
  1485. @item ignore_transform
  1486. @item monochrome
  1487. @item linear_design
  1488. @item no_autohint
  1489. @item end table
  1490. @end table
  1491. Default value is "render".
  1492. For more information consult the documentation for the FT_LOAD_*
  1493. libfreetype flags.
  1494. @item shadowcolor
  1495. The color to be used for drawing a shadow behind the drawn text. It
  1496. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1497. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1498. The default value of @var{shadowcolor} is "black".
  1499. @item shadowx, shadowy
  1500. The x and y offsets for the text shadow position with respect to the
  1501. position of the text. They can be either positive or negative
  1502. values. Default value for both is "0".
  1503. @item tabsize
  1504. The size in number of spaces to use for rendering the tab.
  1505. Default value is 4.
  1506. @item timecode
  1507. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1508. format. It can be used with or without text parameter. @var{timecode_rate}
  1509. option must be specified.
  1510. @item timecode_rate, rate, r
  1511. Set the timecode frame rate (timecode only).
  1512. @item text
  1513. The text string to be drawn. The text must be a sequence of UTF-8
  1514. encoded characters.
  1515. This parameter is mandatory if no file is specified with the parameter
  1516. @var{textfile}.
  1517. @item textfile
  1518. A text file containing text to be drawn. The text must be a sequence
  1519. of UTF-8 encoded characters.
  1520. This parameter is mandatory if no text string is specified with the
  1521. parameter @var{text}.
  1522. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1523. @item reload
  1524. If set to 1, the @var{textfile} will be reloaded before each frame.
  1525. Be sure to update it atomically, or it may be read partially, or even fail.
  1526. @item x, y
  1527. The expressions which specify the offsets where text will be drawn
  1528. within the video frame. They are relative to the top/left border of the
  1529. output image.
  1530. The default value of @var{x} and @var{y} is "0".
  1531. See below for the list of accepted constants and functions.
  1532. @end table
  1533. The parameters for @var{x} and @var{y} are expressions containing the
  1534. following constants and functions:
  1535. @table @option
  1536. @item dar
  1537. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1538. @item hsub, vsub
  1539. horizontal and vertical chroma subsample values. For example for the
  1540. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1541. @item line_h, lh
  1542. the height of each text line
  1543. @item main_h, h, H
  1544. the input height
  1545. @item main_w, w, W
  1546. the input width
  1547. @item max_glyph_a, ascent
  1548. the maximum distance from the baseline to the highest/upper grid
  1549. coordinate used to place a glyph outline point, for all the rendered
  1550. glyphs.
  1551. It is a positive value, due to the grid's orientation with the Y axis
  1552. upwards.
  1553. @item max_glyph_d, descent
  1554. the maximum distance from the baseline to the lowest grid coordinate
  1555. used to place a glyph outline point, for all the rendered glyphs.
  1556. This is a negative value, due to the grid's orientation, with the Y axis
  1557. upwards.
  1558. @item max_glyph_h
  1559. maximum glyph height, that is the maximum height for all the glyphs
  1560. contained in the rendered text, it is equivalent to @var{ascent} -
  1561. @var{descent}.
  1562. @item max_glyph_w
  1563. maximum glyph width, that is the maximum width for all the glyphs
  1564. contained in the rendered text
  1565. @item n
  1566. the number of input frame, starting from 0
  1567. @item rand(min, max)
  1568. return a random number included between @var{min} and @var{max}
  1569. @item sar
  1570. input sample aspect ratio
  1571. @item t
  1572. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1573. @item text_h, th
  1574. the height of the rendered text
  1575. @item text_w, tw
  1576. the width of the rendered text
  1577. @item x, y
  1578. the x and y offset coordinates where the text is drawn.
  1579. These parameters allow the @var{x} and @var{y} expressions to refer
  1580. each other, so you can for example specify @code{y=x/dar}.
  1581. @end table
  1582. If libavfilter was built with @code{--enable-fontconfig}, then
  1583. @option{fontfile} can be a fontconfig pattern or omitted.
  1584. @anchor{drawtext_expansion}
  1585. @subsection Text expansion
  1586. If @option{expansion} is set to @code{strftime} (which is the default for
  1587. now), the filter recognizes strftime() sequences in the provided text and
  1588. expands them accordingly. Check the documentation of strftime(). This
  1589. feature is deprecated.
  1590. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  1591. If @option{expansion} is set to @code{normal} (which will be the default),
  1592. the following expansion mechanism is used.
  1593. The backslash character '\', followed by any character, always expands to
  1594. the second character.
  1595. Sequence of the form @code{%@{...@}} are expanded. The text between the
  1596. braces is a function name, possibly followed by arguments separated by ':'.
  1597. If the arguments contain special characters or delimiters (':' or '@}'),
  1598. they should be escaped.
  1599. Note that they probably must also be escaped as the value for the
  1600. @option{text} option in the filter argument string and as the filter
  1601. argument in the filter graph description, and possibly also for the shell,
  1602. that makes up to four levels of escaping; using a text file avoids these
  1603. problems.
  1604. The following functions are available:
  1605. @table @command
  1606. @item expr, e
  1607. The expression evaluation result.
  1608. It must take one argument specifying the expression to be evaluated,
  1609. which accepts the same constants and functions as the @var{x} and
  1610. @var{y} values. Note that not all constants should be used, for
  1611. example the text size is not known when evaluating the expression, so
  1612. the constants @var{text_w} and @var{text_h} will have an undefined
  1613. value.
  1614. @item gmtime
  1615. The time at which the filter is running, expressed in UTC.
  1616. It can accept an argument: a strftime() format string.
  1617. @item localtime
  1618. The time at which the filter is running, expressed in the local time zone.
  1619. It can accept an argument: a strftime() format string.
  1620. @item n, frame_num
  1621. The frame number, starting from 0.
  1622. @item pts
  1623. The timestamp of the current frame, in seconds, with microsecond accuracy.
  1624. @end table
  1625. @subsection Examples
  1626. Some examples follow.
  1627. @itemize
  1628. @item
  1629. Draw "Test Text" with font FreeSerif, using the default values for the
  1630. optional parameters.
  1631. @example
  1632. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1633. @end example
  1634. @item
  1635. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1636. and y=50 (counting from the top-left corner of the screen), text is
  1637. yellow with a red box around it. Both the text and the box have an
  1638. opacity of 20%.
  1639. @example
  1640. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1641. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1642. @end example
  1643. Note that the double quotes are not necessary if spaces are not used
  1644. within the parameter list.
  1645. @item
  1646. Show the text at the center of the video frame:
  1647. @example
  1648. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1649. @end example
  1650. @item
  1651. Show a text line sliding from right to left in the last row of the video
  1652. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1653. with no newlines.
  1654. @example
  1655. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1656. @end example
  1657. @item
  1658. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1659. @example
  1660. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1661. @end example
  1662. @item
  1663. Draw a single green letter "g", at the center of the input video.
  1664. The glyph baseline is placed at half screen height.
  1665. @example
  1666. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1667. @end example
  1668. @item
  1669. Show text for 1 second every 3 seconds:
  1670. @example
  1671. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  1672. @end example
  1673. @item
  1674. Use fontconfig to set the font. Note that the colons need to be escaped.
  1675. @example
  1676. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  1677. @end example
  1678. @item
  1679. Print the date of a real-time encoding (see strftime(3)):
  1680. @example
  1681. drawtext='fontfile=FreeSans.ttf:expansion=normal:text=%@{localtime:%a %b %d %Y@}'
  1682. @end example
  1683. @end itemize
  1684. For more information about libfreetype, check:
  1685. @url{http://www.freetype.org/}.
  1686. For more information about fontconfig, check:
  1687. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1688. @section edgedetect
  1689. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  1690. This filter accepts the following optional named parameters:
  1691. @table @option
  1692. @item low, high
  1693. Set low and high threshold values used by the Canny thresholding
  1694. algorithm.
  1695. The high threshold selects the "strong" edge pixels, which are then
  1696. connected through 8-connectivity with the "weak" edge pixels selected
  1697. by the low threshold.
  1698. @var{low} and @var{high} threshold values must be choosen in the range
  1699. [0,1], and @var{low} should be lesser or equal to @var{high}.
  1700. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  1701. is @code{50/255}.
  1702. @end table
  1703. Example:
  1704. @example
  1705. edgedetect=low=0.1:high=0.4
  1706. @end example
  1707. @section fade
  1708. Apply fade-in/out effect to input video.
  1709. It accepts the parameters:
  1710. @var{type}:@var{start_frame}:@var{nb_frames}[:@var{options}]
  1711. @var{type} specifies if the effect type, can be either "in" for
  1712. fade-in, or "out" for a fade-out effect.
  1713. @var{start_frame} specifies the number of the start frame for starting
  1714. to apply the fade effect.
  1715. @var{nb_frames} specifies the number of frames for which the fade
  1716. effect has to last. At the end of the fade-in effect the output video
  1717. will have the same intensity as the input video, at the end of the
  1718. fade-out transition the output video will be completely black.
  1719. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1720. separated by ":". The description of the accepted options follows.
  1721. @table @option
  1722. @item type, t
  1723. See @var{type}.
  1724. @item start_frame, s
  1725. See @var{start_frame}.
  1726. @item nb_frames, n
  1727. See @var{nb_frames}.
  1728. @item alpha
  1729. If set to 1, fade only alpha channel, if one exists on the input.
  1730. Default value is 0.
  1731. @end table
  1732. A few usage examples follow, usable too as test scenarios.
  1733. @example
  1734. # fade in first 30 frames of video
  1735. fade=in:0:30
  1736. # fade out last 45 frames of a 200-frame video
  1737. fade=out:155:45
  1738. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  1739. fade=in:0:25, fade=out:975:25
  1740. # make first 5 frames black, then fade in from frame 5-24
  1741. fade=in:5:20
  1742. # fade in alpha over first 25 frames of video
  1743. fade=in:0:25:alpha=1
  1744. @end example
  1745. @section field
  1746. Extract a single field from an interlaced image using stride
  1747. arithmetic to avoid wasting CPU time. The output frames are marked as
  1748. non-interlaced.
  1749. This filter accepts the following named options:
  1750. @table @option
  1751. @item type
  1752. Specify whether to extract the top (if the value is @code{0} or
  1753. @code{top}) or the bottom field (if the value is @code{1} or
  1754. @code{bottom}).
  1755. @end table
  1756. If the option key is not specified, the first value sets the @var{type}
  1757. option. For example:
  1758. @example
  1759. field=bottom
  1760. @end example
  1761. is equivalent to:
  1762. @example
  1763. field=type=bottom
  1764. @end example
  1765. @section fieldorder
  1766. Transform the field order of the input video.
  1767. It accepts one parameter which specifies the required field order that
  1768. the input interlaced video will be transformed to. The parameter can
  1769. assume one of the following values:
  1770. @table @option
  1771. @item 0 or bff
  1772. output bottom field first
  1773. @item 1 or tff
  1774. output top field first
  1775. @end table
  1776. Default value is "tff".
  1777. Transformation is achieved by shifting the picture content up or down
  1778. by one line, and filling the remaining line with appropriate picture content.
  1779. This method is consistent with most broadcast field order converters.
  1780. If the input video is not flagged as being interlaced, or it is already
  1781. flagged as being of the required output field order then this filter does
  1782. not alter the incoming video.
  1783. This filter is very useful when converting to or from PAL DV material,
  1784. which is bottom field first.
  1785. For example:
  1786. @example
  1787. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1788. @end example
  1789. @section fifo
  1790. Buffer input images and send them when they are requested.
  1791. This filter is mainly useful when auto-inserted by the libavfilter
  1792. framework.
  1793. The filter does not take parameters.
  1794. @section format
  1795. Convert the input video to one of the specified pixel formats.
  1796. Libavfilter will try to pick one that is supported for the input to
  1797. the next filter.
  1798. The filter accepts a list of pixel format names, separated by ":",
  1799. for example "yuv420p:monow:rgb24".
  1800. Some examples follow:
  1801. @example
  1802. # convert the input video to the format "yuv420p"
  1803. format=yuv420p
  1804. # convert the input video to any of the formats in the list
  1805. format=yuv420p:yuv444p:yuv410p
  1806. @end example
  1807. @section fps
  1808. Convert the video to specified constant framerate by duplicating or dropping
  1809. frames as necessary.
  1810. This filter accepts the following named parameters:
  1811. @table @option
  1812. @item fps
  1813. Desired output framerate. The default is @code{25}.
  1814. @item round
  1815. Rounding method.
  1816. Possible values are:
  1817. @table @option
  1818. @item zero
  1819. zero round towards 0
  1820. @item inf
  1821. round away from 0
  1822. @item down
  1823. round towards -infinity
  1824. @item up
  1825. round towards +infinity
  1826. @item near
  1827. round to nearest
  1828. @end table
  1829. The default is @code{near}.
  1830. @end table
  1831. Alternatively, the options can be specified as a flat string:
  1832. @var{fps}[:@var{round}].
  1833. See also the @ref{setpts} filter.
  1834. @section framestep
  1835. Select one frame every N.
  1836. This filter accepts in input a string representing a positive
  1837. integer. Default argument is @code{1}.
  1838. @anchor{frei0r}
  1839. @section frei0r
  1840. Apply a frei0r effect to the input video.
  1841. To enable compilation of this filter you need to install the frei0r
  1842. header and configure FFmpeg with @code{--enable-frei0r}.
  1843. The filter supports the syntax:
  1844. @example
  1845. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1846. @end example
  1847. @var{filter_name} is the name of the frei0r effect to load. If the
  1848. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1849. is searched in each one of the directories specified by the colon (or
  1850. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  1851. otherwise in the standard frei0r paths, which are in this order:
  1852. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  1853. @file{/usr/lib/frei0r-1/}.
  1854. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1855. for the frei0r effect.
  1856. A frei0r effect parameter can be a boolean (whose values are specified
  1857. with "y" and "n"), a double, a color (specified by the syntax
  1858. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1859. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1860. description), a position (specified by the syntax @var{X}/@var{Y},
  1861. @var{X} and @var{Y} being float numbers) and a string.
  1862. The number and kind of parameters depend on the loaded effect. If an
  1863. effect parameter is not specified the default value is set.
  1864. Some examples follow:
  1865. @itemize
  1866. @item
  1867. Apply the distort0r effect, set the first two double parameters:
  1868. @example
  1869. frei0r=distort0r:0.5:0.01
  1870. @end example
  1871. @item
  1872. Apply the colordistance effect, take a color as first parameter:
  1873. @example
  1874. frei0r=colordistance:0.2/0.3/0.4
  1875. frei0r=colordistance:violet
  1876. frei0r=colordistance:0x112233
  1877. @end example
  1878. @item
  1879. Apply the perspective effect, specify the top left and top right image
  1880. positions:
  1881. @example
  1882. frei0r=perspective:0.2/0.2:0.8/0.2
  1883. @end example
  1884. @end itemize
  1885. For more information see:
  1886. @url{http://frei0r.dyne.org}
  1887. @section geq
  1888. The filter takes one, two or three equations as parameter, separated by ':'.
  1889. The first equation is mandatory and applies to the luma plane. The two
  1890. following are respectively for chroma blue and chroma red planes.
  1891. The filter syntax allows named parameters:
  1892. @table @option
  1893. @item lum_expr
  1894. the luminance expression
  1895. @item cb_expr
  1896. the chrominance blue expression
  1897. @item cr_expr
  1898. the chrominance red expression
  1899. @end table
  1900. If one of the chrominance expression is not defined, it falls back on the other
  1901. one. If none of them are specified, they will evaluate the luminance
  1902. expression.
  1903. The expressions can use the following variables and functions:
  1904. @table @option
  1905. @item N
  1906. The sequential number of the filtered frame, starting from @code{0}.
  1907. @item X, Y
  1908. The coordinates of the current sample.
  1909. @item W, H
  1910. The width and height of the image.
  1911. @item SW, SH
  1912. Width and height scale depending on the currently filtered plane. It is the
  1913. ratio between the corresponding luma plane number of pixels and the current
  1914. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1915. @code{0.5,0.5} for chroma planes.
  1916. @item T
  1917. Time of the current frame, expressed in seconds.
  1918. @item p(x, y)
  1919. Return the value of the pixel at location (@var{x},@var{y}) of the current
  1920. plane.
  1921. @item lum(x, y)
  1922. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  1923. plane.
  1924. @item cb(x, y)
  1925. Return the value of the pixel at location (@var{x},@var{y}) of the
  1926. blue-difference chroma plane.
  1927. @item cr(x, y)
  1928. Return the value of the pixel at location (@var{x},@var{y}) of the
  1929. red-difference chroma plane.
  1930. @end table
  1931. For functions, if @var{x} and @var{y} are outside the area, the value will be
  1932. automatically clipped to the closer edge.
  1933. Some examples follow:
  1934. @itemize
  1935. @item
  1936. Flip the image horizontally:
  1937. @example
  1938. geq=p(W-X\,Y)
  1939. @end example
  1940. @item
  1941. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  1942. wavelength of 100 pixels:
  1943. @example
  1944. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  1945. @end example
  1946. @item
  1947. Generate a fancy enigmatic moving light:
  1948. @example
  1949. 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
  1950. @end example
  1951. @end itemize
  1952. @section gradfun
  1953. Fix the banding artifacts that are sometimes introduced into nearly flat
  1954. regions by truncation to 8bit color depth.
  1955. Interpolate the gradients that should go where the bands are, and
  1956. dither them.
  1957. This filter is designed for playback only. Do not use it prior to
  1958. lossy compression, because compression tends to lose the dither and
  1959. bring back the bands.
  1960. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  1961. separated by ":". A description of the accepted options follows.
  1962. @table @option
  1963. @item strength
  1964. The maximum amount by which the filter will change
  1965. any one pixel. Also the threshold for detecting nearly flat
  1966. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  1967. is @code{1.2}.
  1968. @item radius
  1969. The neighborhood to fit the gradient to. A larger
  1970. radius makes for smoother gradients, but also prevents the filter from
  1971. modifying the pixels near detailed regions. Acceptable values are
  1972. @code{8-32}, default value is @code{16}.
  1973. @end table
  1974. Alternatively, the options can be specified as a flat string:
  1975. @var{strength}[:@var{radius}]
  1976. @subsection Examples
  1977. @itemize
  1978. @item
  1979. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  1980. @example
  1981. gradfun=3.5:8
  1982. @end example
  1983. @item
  1984. Specify radius, omitting the strength (which will fall-back to the default
  1985. value):
  1986. @example
  1987. gradfun=radius=8
  1988. @end example
  1989. @end itemize
  1990. @section hflip
  1991. Flip the input video horizontally.
  1992. For example to horizontally flip the input video with @command{ffmpeg}:
  1993. @example
  1994. ffmpeg -i in.avi -vf "hflip" out.avi
  1995. @end example
  1996. @section hqdn3d
  1997. High precision/quality 3d denoise filter. This filter aims to reduce
  1998. image noise producing smooth images and making still images really
  1999. still. It should enhance compressibility.
  2000. It accepts the following optional parameters:
  2001. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2002. @table @option
  2003. @item luma_spatial
  2004. a non-negative float number which specifies spatial luma strength,
  2005. defaults to 4.0
  2006. @item chroma_spatial
  2007. a non-negative float number which specifies spatial chroma strength,
  2008. defaults to 3.0*@var{luma_spatial}/4.0
  2009. @item luma_tmp
  2010. a float number which specifies luma temporal strength, defaults to
  2011. 6.0*@var{luma_spatial}/4.0
  2012. @item chroma_tmp
  2013. a float number which specifies chroma temporal strength, defaults to
  2014. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2015. @end table
  2016. @section hue
  2017. Modify the hue and/or the saturation of the input.
  2018. This filter accepts the following optional named options:
  2019. @table @option
  2020. @item h
  2021. Specify the hue angle as a number of degrees. It accepts a float
  2022. number or an expression, and defaults to 0.0.
  2023. @item H
  2024. Specify the hue angle as a number of degrees. It accepts a float
  2025. number or an expression, and defaults to 0.0.
  2026. @item s
  2027. Specify the saturation in the [-10,10] range. It accepts a float number and
  2028. defaults to 1.0.
  2029. @end table
  2030. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2031. following constants:
  2032. @table @option
  2033. @item n
  2034. frame count of the input frame starting from 0
  2035. @item pts
  2036. presentation timestamp of the input frame expressed in time base units
  2037. @item r
  2038. frame rate of the input video, NAN if the input frame rate is unknown
  2039. @item t
  2040. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2041. @item tb
  2042. time base of the input video
  2043. @end table
  2044. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2045. In this case @var{hue} is expressed in degrees.
  2046. Some examples follow:
  2047. @itemize
  2048. @item
  2049. Set the hue to 90 degrees and the saturation to 1.0:
  2050. @example
  2051. hue=h=90:s=1
  2052. @end example
  2053. @item
  2054. Same command but expressing the hue in radians:
  2055. @example
  2056. hue=H=PI/2:s=1
  2057. @end example
  2058. @item
  2059. Same command without named options, hue must be expressed in degrees:
  2060. @example
  2061. hue=90:1
  2062. @end example
  2063. @item
  2064. Note that "h:s" syntax does not support expressions for the values of
  2065. h and s, so the following example will issue an error:
  2066. @example
  2067. hue=PI/2:1
  2068. @end example
  2069. @item
  2070. Rotate hue and make the saturation swing between 0
  2071. and 2 over a period of 1 second:
  2072. @example
  2073. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2074. @end example
  2075. @item
  2076. Apply a 3 seconds saturation fade-in effect starting at 0:
  2077. @example
  2078. hue="s=min(t/3\,1)"
  2079. @end example
  2080. The general fade-in expression can be written as:
  2081. @example
  2082. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2083. @end example
  2084. @item
  2085. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2086. @example
  2087. hue="s=max(0\, min(1\, (8-t)/3))"
  2088. @end example
  2089. The general fade-out expression can be written as:
  2090. @example
  2091. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2092. @end example
  2093. @end itemize
  2094. @subsection Commands
  2095. This filter supports the following command:
  2096. @table @option
  2097. @item reinit
  2098. Modify the hue and/or the saturation of the input video.
  2099. The command accepts the same named options and syntax than when calling the
  2100. filter from the command-line.
  2101. If a parameter is omitted, it is kept at its current value.
  2102. @end table
  2103. @section idet
  2104. Interlaceing detect filter. This filter tries to detect if the input is
  2105. interlaced or progressive. Top or bottom field first.
  2106. @section lut, lutrgb, lutyuv
  2107. Compute a look-up table for binding each pixel component input value
  2108. to an output value, and apply it to input video.
  2109. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2110. to an RGB input video.
  2111. These filters accept in input a ":"-separated list of options, which
  2112. specify the expressions used for computing the lookup table for the
  2113. corresponding pixel component values.
  2114. The @var{lut} filter requires either YUV or RGB pixel formats in
  2115. input, and accepts the options:
  2116. @table @option
  2117. @item @var{c0} (first pixel component)
  2118. @item @var{c1} (second pixel component)
  2119. @item @var{c2} (third pixel component)
  2120. @item @var{c3} (fourth pixel component, corresponds to the alpha component)
  2121. @end table
  2122. The exact component associated to each option depends on the format in
  2123. input.
  2124. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2125. accepts the options:
  2126. @table @option
  2127. @item @var{r} (red component)
  2128. @item @var{g} (green component)
  2129. @item @var{b} (blue component)
  2130. @item @var{a} (alpha component)
  2131. @end table
  2132. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2133. accepts the options:
  2134. @table @option
  2135. @item @var{y} (Y/luminance component)
  2136. @item @var{u} (U/Cb component)
  2137. @item @var{v} (V/Cr component)
  2138. @item @var{a} (alpha component)
  2139. @end table
  2140. The expressions can contain the following constants and functions:
  2141. @table @option
  2142. @item w, h
  2143. the input width and height
  2144. @item val
  2145. input value for the pixel component
  2146. @item clipval
  2147. the input value clipped in the @var{minval}-@var{maxval} range
  2148. @item maxval
  2149. maximum value for the pixel component
  2150. @item minval
  2151. minimum value for the pixel component
  2152. @item negval
  2153. the negated value for the pixel component value clipped in the
  2154. @var{minval}-@var{maxval} range , it corresponds to the expression
  2155. "maxval-clipval+minval"
  2156. @item clip(val)
  2157. the computed value in @var{val} clipped in the
  2158. @var{minval}-@var{maxval} range
  2159. @item gammaval(gamma)
  2160. the computed gamma correction value of the pixel component value
  2161. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2162. expression
  2163. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2164. @end table
  2165. All expressions default to "val".
  2166. Some examples follow:
  2167. @example
  2168. # negate input video
  2169. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2170. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2171. # the above is the same as
  2172. lutrgb="r=negval:g=negval:b=negval"
  2173. lutyuv="y=negval:u=negval:v=negval"
  2174. # negate luminance
  2175. lutyuv=y=negval
  2176. # remove chroma components, turns the video into a graytone image
  2177. lutyuv="u=128:v=128"
  2178. # apply a luma burning effect
  2179. lutyuv="y=2*val"
  2180. # remove green and blue components
  2181. lutrgb="g=0:b=0"
  2182. # set a constant alpha channel value on input
  2183. format=rgba,lutrgb=a="maxval-minval/2"
  2184. # correct luminance gamma by a 0.5 factor
  2185. lutyuv=y=gammaval(0.5)
  2186. @end example
  2187. @section mp
  2188. Apply an MPlayer filter to the input video.
  2189. This filter provides a wrapper around most of the filters of
  2190. MPlayer/MEncoder.
  2191. This wrapper is considered experimental. Some of the wrapped filters
  2192. may not work properly and we may drop support for them, as they will
  2193. be implemented natively into FFmpeg. Thus you should avoid
  2194. depending on them when writing portable scripts.
  2195. The filters accepts the parameters:
  2196. @var{filter_name}[:=]@var{filter_params}
  2197. @var{filter_name} is the name of a supported MPlayer filter,
  2198. @var{filter_params} is a string containing the parameters accepted by
  2199. the named filter.
  2200. The list of the currently supported filters follows:
  2201. @table @var
  2202. @item detc
  2203. @item dint
  2204. @item divtc
  2205. @item down3dright
  2206. @item dsize
  2207. @item eq2
  2208. @item eq
  2209. @item fil
  2210. @item fspp
  2211. @item harddup
  2212. @item il
  2213. @item ilpack
  2214. @item ivtc
  2215. @item kerndeint
  2216. @item mcdeint
  2217. @item noise
  2218. @item ow
  2219. @item perspective
  2220. @item phase
  2221. @item pp7
  2222. @item pullup
  2223. @item qp
  2224. @item sab
  2225. @item softpulldown
  2226. @item softskip
  2227. @item spp
  2228. @item telecine
  2229. @item tinterlace
  2230. @item unsharp
  2231. @item uspp
  2232. @end table
  2233. The parameter syntax and behavior for the listed filters are the same
  2234. of the corresponding MPlayer filters. For detailed instructions check
  2235. the "VIDEO FILTERS" section in the MPlayer manual.
  2236. Some examples follow:
  2237. @itemize
  2238. @item
  2239. Adjust gamma, brightness, contrast:
  2240. @example
  2241. mp=eq2=1.0:2:0.5
  2242. @end example
  2243. @item
  2244. Add temporal noise to input video:
  2245. @example
  2246. mp=noise=20t
  2247. @end example
  2248. @end itemize
  2249. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2250. @section negate
  2251. Negate input video.
  2252. This filter accepts an integer in input, if non-zero it negates the
  2253. alpha component (if available). The default value in input is 0.
  2254. @section noformat
  2255. Force libavfilter not to use any of the specified pixel formats for the
  2256. input to the next filter.
  2257. The filter accepts a list of pixel format names, separated by ":",
  2258. for example "yuv420p:monow:rgb24".
  2259. Some examples follow:
  2260. @example
  2261. # force libavfilter to use a format different from "yuv420p" for the
  2262. # input to the vflip filter
  2263. noformat=yuv420p,vflip
  2264. # convert the input video to any of the formats not contained in the list
  2265. noformat=yuv420p:yuv444p:yuv410p
  2266. @end example
  2267. @section null
  2268. Pass the video source unchanged to the output.
  2269. @section ocv
  2270. Apply video transform using libopencv.
  2271. To enable this filter install libopencv library and headers and
  2272. configure FFmpeg with @code{--enable-libopencv}.
  2273. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2274. @var{filter_name} is the name of the libopencv filter to apply.
  2275. @var{filter_params} specifies the parameters to pass to the libopencv
  2276. filter. If not specified the default values are assumed.
  2277. Refer to the official libopencv documentation for more precise
  2278. information:
  2279. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2280. Follows the list of supported libopencv filters.
  2281. @anchor{dilate}
  2282. @subsection dilate
  2283. Dilate an image by using a specific structuring element.
  2284. This filter corresponds to the libopencv function @code{cvDilate}.
  2285. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2286. @var{struct_el} represents a structuring element, and has the syntax:
  2287. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2288. @var{cols} and @var{rows} represent the number of columns and rows of
  2289. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2290. point, and @var{shape} the shape for the structuring element, and
  2291. can be one of the values "rect", "cross", "ellipse", "custom".
  2292. If the value for @var{shape} is "custom", it must be followed by a
  2293. string of the form "=@var{filename}". The file with name
  2294. @var{filename} is assumed to represent a binary image, with each
  2295. printable character corresponding to a bright pixel. When a custom
  2296. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2297. or columns and rows of the read file are assumed instead.
  2298. The default value for @var{struct_el} is "3x3+0x0/rect".
  2299. @var{nb_iterations} specifies the number of times the transform is
  2300. applied to the image, and defaults to 1.
  2301. Follow some example:
  2302. @example
  2303. # use the default values
  2304. ocv=dilate
  2305. # dilate using a structuring element with a 5x5 cross, iterate two times
  2306. ocv=dilate=5x5+2x2/cross:2
  2307. # read the shape from the file diamond.shape, iterate two times
  2308. # the file diamond.shape may contain a pattern of characters like this:
  2309. # *
  2310. # ***
  2311. # *****
  2312. # ***
  2313. # *
  2314. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2315. ocv=0x0+2x2/custom=diamond.shape:2
  2316. @end example
  2317. @subsection erode
  2318. Erode an image by using a specific structuring element.
  2319. This filter corresponds to the libopencv function @code{cvErode}.
  2320. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2321. with the same syntax and semantics as the @ref{dilate} filter.
  2322. @subsection smooth
  2323. Smooth the input video.
  2324. The filter takes the following parameters:
  2325. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2326. @var{type} is the type of smooth filter to apply, and can be one of
  2327. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2328. "bilateral". The default value is "gaussian".
  2329. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2330. parameters whose meanings depend on smooth type. @var{param1} and
  2331. @var{param2} accept integer positive values or 0, @var{param3} and
  2332. @var{param4} accept float values.
  2333. The default value for @var{param1} is 3, the default value for the
  2334. other parameters is 0.
  2335. These parameters correspond to the parameters assigned to the
  2336. libopencv function @code{cvSmooth}.
  2337. @anchor{overlay}
  2338. @section overlay
  2339. Overlay one video on top of another.
  2340. It takes two inputs and one output, the first input is the "main"
  2341. video on which the second input is overlayed.
  2342. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2343. separated by ":". If the key of the first options is omitted, the
  2344. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2345. A description of the accepted options follows.
  2346. @table @option
  2347. @item x, y
  2348. Set the expression for the x and y coordinates of the overlayed video
  2349. on the main video. Default value is 0.
  2350. The @var{x} and @var{y} expressions can contain the following
  2351. parameters:
  2352. @table @option
  2353. @item main_w, main_h
  2354. main input width and height
  2355. @item W, H
  2356. same as @var{main_w} and @var{main_h}
  2357. @item overlay_w, overlay_h
  2358. overlay input width and height
  2359. @item w, h
  2360. same as @var{overlay_w} and @var{overlay_h}
  2361. @end table
  2362. @item rgb
  2363. If set to 1, force the filter to accept inputs in the RGB
  2364. color space. Default value is 0.
  2365. @end table
  2366. Be aware that frames are taken from each input video in timestamp
  2367. order, hence, if their initial timestamps differ, it is a a good idea
  2368. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2369. have them begin in the same zero timestamp, as it does the example for
  2370. the @var{movie} filter.
  2371. You can chain together more overlays but you should test the
  2372. efficiency of such approach.
  2373. @subsection Examples
  2374. @itemize
  2375. @item
  2376. Draw the overlay at 10 pixels from the bottom right corner of the main
  2377. video:
  2378. @example
  2379. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2380. @end example
  2381. Using named options the example above becomes:
  2382. @example
  2383. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2384. @end example
  2385. @item
  2386. Insert a transparent PNG logo in the bottom left corner of the input,
  2387. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2388. @example
  2389. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2390. @end example
  2391. @item
  2392. Insert 2 different transparent PNG logos (second logo on bottom
  2393. right corner) using the @command{ffmpeg} tool:
  2394. @example
  2395. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2396. @end example
  2397. @item
  2398. Add a transparent color layer on top of the main video, WxH specifies
  2399. the size of the main input to the overlay filter:
  2400. @example
  2401. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2402. @end example
  2403. @item
  2404. Play an original video and a filtered version (here with the deshake
  2405. filter) side by side using the @command{ffplay} tool:
  2406. @example
  2407. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2408. @end example
  2409. The above command is the same as:
  2410. @example
  2411. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2412. @end example
  2413. @item
  2414. Chain several overlays in cascade:
  2415. @example
  2416. nullsrc=s=200x200 [bg];
  2417. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2418. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2419. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2420. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2421. [in3] null, [mid2] overlay=100:100 [out0]
  2422. @end example
  2423. @end itemize
  2424. @section pad
  2425. Add paddings to the input image, and places the original input at the
  2426. given coordinates @var{x}, @var{y}.
  2427. It accepts the following parameters:
  2428. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2429. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  2430. expressions containing the following constants:
  2431. @table @option
  2432. @item in_w, in_h
  2433. the input video width and height
  2434. @item iw, ih
  2435. same as @var{in_w} and @var{in_h}
  2436. @item out_w, out_h
  2437. the output width and height, that is the size of the padded area as
  2438. specified by the @var{width} and @var{height} expressions
  2439. @item ow, oh
  2440. same as @var{out_w} and @var{out_h}
  2441. @item x, y
  2442. x and y offsets as specified by the @var{x} and @var{y}
  2443. expressions, or NAN if not yet specified
  2444. @item a
  2445. same as @var{iw} / @var{ih}
  2446. @item sar
  2447. input sample aspect ratio
  2448. @item dar
  2449. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2450. @item hsub, vsub
  2451. horizontal and vertical chroma subsample values. For example for the
  2452. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2453. @end table
  2454. Follows the description of the accepted parameters.
  2455. @table @option
  2456. @item width, height
  2457. Specify the size of the output image with the paddings added. If the
  2458. value for @var{width} or @var{height} is 0, the corresponding input size
  2459. is used for the output.
  2460. The @var{width} expression can reference the value set by the
  2461. @var{height} expression, and vice versa.
  2462. The default value of @var{width} and @var{height} is 0.
  2463. @item x, y
  2464. Specify the offsets where to place the input image in the padded area
  2465. with respect to the top/left border of the output image.
  2466. The @var{x} expression can reference the value set by the @var{y}
  2467. expression, and vice versa.
  2468. The default value of @var{x} and @var{y} is 0.
  2469. @item color
  2470. Specify the color of the padded area, it can be the name of a color
  2471. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2472. The default value of @var{color} is "black".
  2473. @end table
  2474. @subsection Examples
  2475. @itemize
  2476. @item
  2477. Add paddings with color "violet" to the input video. Output video
  2478. size is 640x480, the top-left corner of the input video is placed at
  2479. column 0, row 40:
  2480. @example
  2481. pad=640:480:0:40:violet
  2482. @end example
  2483. @item
  2484. Pad the input to get an output with dimensions increased by 3/2,
  2485. and put the input video at the center of the padded area:
  2486. @example
  2487. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  2488. @end example
  2489. @item
  2490. Pad the input to get a squared output with size equal to the maximum
  2491. value between the input width and height, and put the input video at
  2492. the center of the padded area:
  2493. @example
  2494. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  2495. @end example
  2496. @item
  2497. Pad the input to get a final w/h ratio of 16:9:
  2498. @example
  2499. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  2500. @end example
  2501. @item
  2502. In case of anamorphic video, in order to set the output display aspect
  2503. correctly, it is necessary to use @var{sar} in the expression,
  2504. according to the relation:
  2505. @example
  2506. (ih * X / ih) * sar = output_dar
  2507. X = output_dar / sar
  2508. @end example
  2509. Thus the previous example needs to be modified to:
  2510. @example
  2511. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  2512. @end example
  2513. @item
  2514. Double output size and put the input video in the bottom-right
  2515. corner of the output padded area:
  2516. @example
  2517. pad="2*iw:2*ih:ow-iw:oh-ih"
  2518. @end example
  2519. @end itemize
  2520. @section pixdesctest
  2521. Pixel format descriptor test filter, mainly useful for internal
  2522. testing. The output video should be equal to the input video.
  2523. For example:
  2524. @example
  2525. format=monow, pixdesctest
  2526. @end example
  2527. can be used to test the monowhite pixel format descriptor definition.
  2528. @section pp
  2529. Enable the specified chain of postprocessing subfilters using libpostproc. This
  2530. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  2531. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  2532. Each subfilter and some options have a short and a long name that can be used
  2533. interchangeably, i.e. dr/dering are the same.
  2534. All subfilters share common options to determine their scope:
  2535. @table @option
  2536. @item a/autoq
  2537. Honor the quality commands for this subfilter.
  2538. @item c/chrom
  2539. Do chrominance filtering, too (default).
  2540. @item y/nochrom
  2541. Do luminance filtering only (no chrominance).
  2542. @item n/noluma
  2543. Do chrominance filtering only (no luminance).
  2544. @end table
  2545. These options can be appended after the subfilter name, separated by a ':'.
  2546. Available subfilters are:
  2547. @table @option
  2548. @item hb/hdeblock[:difference[:flatness]]
  2549. Horizontal deblocking filter
  2550. @table @option
  2551. @item difference
  2552. Difference factor where higher values mean more deblocking (default: @code{32}).
  2553. @item flatness
  2554. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2555. @end table
  2556. @item vb/vdeblock[:difference[:flatness]]
  2557. Vertical deblocking filter
  2558. @table @option
  2559. @item difference
  2560. Difference factor where higher values mean more deblocking (default: @code{32}).
  2561. @item flatness
  2562. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2563. @end table
  2564. @item ha/hadeblock[:difference[:flatness]]
  2565. Accurate horizontal deblocking filter
  2566. @table @option
  2567. @item difference
  2568. Difference factor where higher values mean more deblocking (default: @code{32}).
  2569. @item flatness
  2570. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2571. @end table
  2572. @item va/vadeblock[:difference[:flatness]]
  2573. Accurate vertical deblocking filter
  2574. @table @option
  2575. @item difference
  2576. Difference factor where higher values mean more deblocking (default: @code{32}).
  2577. @item flatness
  2578. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2579. @end table
  2580. @end table
  2581. The horizontal and vertical deblocking filters share the difference and
  2582. flatness values so you cannot set different horizontal and vertical
  2583. thresholds.
  2584. @table @option
  2585. @item h1/x1hdeblock
  2586. Experimental horizontal deblocking filter
  2587. @item v1/x1vdeblock
  2588. Experimental vertical deblocking filter
  2589. @item dr/dering
  2590. Deringing filter
  2591. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  2592. @table @option
  2593. @item threshold1
  2594. larger -> stronger filtering
  2595. @item threshold2
  2596. larger -> stronger filtering
  2597. @item threshold3
  2598. larger -> stronger filtering
  2599. @end table
  2600. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  2601. @table @option
  2602. @item f/fullyrange
  2603. Stretch luminance to @code{0-255}.
  2604. @end table
  2605. @item lb/linblenddeint
  2606. Linear blend deinterlacing filter that deinterlaces the given block by
  2607. filtering all lines with a @code{(1 2 1)} filter.
  2608. @item li/linipoldeint
  2609. Linear interpolating deinterlacing filter that deinterlaces the given block by
  2610. linearly interpolating every second line.
  2611. @item ci/cubicipoldeint
  2612. Cubic interpolating deinterlacing filter deinterlaces the given block by
  2613. cubically interpolating every second line.
  2614. @item md/mediandeint
  2615. Median deinterlacing filter that deinterlaces the given block by applying a
  2616. median filter to every second line.
  2617. @item fd/ffmpegdeint
  2618. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  2619. second line with a @code{(-1 4 2 4 -1)} filter.
  2620. @item l5/lowpass5
  2621. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  2622. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  2623. @item fq/forceQuant[:quantizer]
  2624. Overrides the quantizer table from the input with the constant quantizer you
  2625. specify.
  2626. @table @option
  2627. @item quantizer
  2628. Quantizer to use
  2629. @end table
  2630. @item de/default
  2631. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  2632. @item fa/fast
  2633. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  2634. @item ac
  2635. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  2636. @end table
  2637. @subsection Examples
  2638. @itemize
  2639. @item
  2640. Apply horizontal and vertical deblocking, deringing and automatic
  2641. brightness/contrast:
  2642. @example
  2643. pp=hb/vb/dr/al
  2644. @end example
  2645. @item
  2646. Apply default filters without brightness/contrast correction:
  2647. @example
  2648. pp=de/-al
  2649. @end example
  2650. @item
  2651. Apply default filters and temporal denoiser:
  2652. @example
  2653. pp=default/tmpnoise:1:2:3
  2654. @end example
  2655. @item
  2656. Apply deblocking on luminance only, and switch vertical deblocking on or off
  2657. automatically depending on available CPU time:
  2658. @example
  2659. pp=hb:y/vb:a
  2660. @end example
  2661. @end itemize
  2662. @section removelogo
  2663. Suppress a TV station logo, using an image file to determine which
  2664. pixels comprise the logo. It works by filling in the pixels that
  2665. comprise the logo with neighboring pixels.
  2666. This filter requires one argument which specifies the filter bitmap
  2667. file, which can be any image format supported by libavformat. The
  2668. width and height of the image file must match those of the video
  2669. stream being processed.
  2670. Pixels in the provided bitmap image with a value of zero are not
  2671. considered part of the logo, non-zero pixels are considered part of
  2672. the logo. If you use white (255) for the logo and black (0) for the
  2673. rest, you will be safe. For making the filter bitmap, it is
  2674. recommended to take a screen capture of a black frame with the logo
  2675. visible, and then using a threshold filter followed by the erode
  2676. filter once or twice.
  2677. If needed, little splotches can be fixed manually. Remember that if
  2678. logo pixels are not covered, the filter quality will be much
  2679. reduced. Marking too many pixels as part of the logo does not hurt as
  2680. much, but it will increase the amount of blurring needed to cover over
  2681. the image and will destroy more information than necessary, and extra
  2682. pixels will slow things down on a large logo.
  2683. @section scale
  2684. Scale (resize) the input video, using the libswscale library.
  2685. The scale filter forces the output display aspect ratio to be the same
  2686. of the input, by changing the output sample aspect ratio.
  2687. This filter accepts a list of named options in the form of
  2688. @var{key}=@var{value} pairs separated by ":". If the key for the first
  2689. two options is not specified, the assumed keys for the first two
  2690. values are @code{w} and @code{h}. If the first option has no key and
  2691. can be interpreted like a video size specification, it will be used
  2692. to set the video size.
  2693. A description of the accepted options follows.
  2694. @table @option
  2695. @item width, w
  2696. Set the video width expression, default value is @code{iw}. See below
  2697. for the list of accepted constants.
  2698. @item height, h
  2699. Set the video heiht expression, default value is @code{ih}.
  2700. See below for the list of accepted constants.
  2701. @item interl
  2702. Set the interlacing. It accepts the following values:
  2703. @table @option
  2704. @item 1
  2705. force interlaced aware scaling
  2706. @item 0
  2707. do not apply interlaced scaling
  2708. @item -1
  2709. select interlaced aware scaling depending on whether the source frames
  2710. are flagged as interlaced or not
  2711. @end table
  2712. Default value is @code{0}.
  2713. @item flags
  2714. Set libswscale scaling flags. If not explictly specified the filter
  2715. applies a bilinear scaling algorithm.
  2716. @item size, s
  2717. Set the video size, the value must be a valid abbreviation or in the
  2718. form @var{width}x@var{height}.
  2719. @end table
  2720. The values of the @var{w} and @var{h} options are expressions
  2721. containing the following constants:
  2722. @table @option
  2723. @item in_w, in_h
  2724. the input width and height
  2725. @item iw, ih
  2726. same as @var{in_w} and @var{in_h}
  2727. @item out_w, out_h
  2728. the output (cropped) width and height
  2729. @item ow, oh
  2730. same as @var{out_w} and @var{out_h}
  2731. @item a
  2732. same as @var{iw} / @var{ih}
  2733. @item sar
  2734. input sample aspect ratio
  2735. @item dar
  2736. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2737. @item hsub, vsub
  2738. horizontal and vertical chroma subsample values. For example for the
  2739. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2740. @end table
  2741. If the input image format is different from the format requested by
  2742. the next filter, the scale filter will convert the input to the
  2743. requested format.
  2744. If the value for @var{width} or @var{height} is 0, the respective input
  2745. size is used for the output.
  2746. If the value for @var{width} or @var{height} is -1, the scale filter will
  2747. use, for the respective output size, a value that maintains the aspect
  2748. ratio of the input image.
  2749. @subsection Examples
  2750. @itemize
  2751. @item
  2752. Scale the input video to a size of 200x100:
  2753. @example
  2754. scale=200:100
  2755. @end example
  2756. This is equivalent to:
  2757. @example
  2758. scale=w=200:h=100
  2759. @end example
  2760. or:
  2761. @example
  2762. scale=200x100
  2763. @end example
  2764. @item
  2765. Specify a size abbreviation for the output size:
  2766. @example
  2767. scale=qcif
  2768. @end example
  2769. which can also be written as:
  2770. @example
  2771. scale=size=qcif
  2772. @end example
  2773. @item
  2774. Scale the input to 2x:
  2775. @example
  2776. scale=2*iw:2*ih
  2777. @end example
  2778. @item
  2779. The above is the same as:
  2780. @example
  2781. scale=2*in_w:2*in_h
  2782. @end example
  2783. @item
  2784. Scale the input to 2x with forced interlaced scaling:
  2785. @example
  2786. scale=2*iw:2*ih:interl=1
  2787. @end example
  2788. @item
  2789. Scale the input to half size:
  2790. @example
  2791. scale=iw/2:ih/2
  2792. @end example
  2793. @item
  2794. Increase the width, and set the height to the same size:
  2795. @example
  2796. scale=3/2*iw:ow
  2797. @end example
  2798. @item
  2799. Seek for Greek harmony:
  2800. @example
  2801. scale=iw:1/PHI*iw
  2802. scale=ih*PHI:ih
  2803. @end example
  2804. @item
  2805. Increase the height, and set the width to 3/2 of the height:
  2806. @example
  2807. scale=3/2*oh:3/5*ih
  2808. @end example
  2809. @item
  2810. Increase the size, but make the size a multiple of the chroma:
  2811. @example
  2812. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  2813. @end example
  2814. @item
  2815. Increase the width to a maximum of 500 pixels, keep the same input
  2816. aspect ratio:
  2817. @example
  2818. scale='min(500\, iw*3/2):-1'
  2819. @end example
  2820. @end itemize
  2821. @section setdar, setsar
  2822. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  2823. output video.
  2824. This is done by changing the specified Sample (aka Pixel) Aspect
  2825. Ratio, according to the following equation:
  2826. @example
  2827. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  2828. @end example
  2829. Keep in mind that the @code{setdar} filter does not modify the pixel
  2830. dimensions of the video frame. Also the display aspect ratio set by
  2831. this filter may be changed by later filters in the filterchain,
  2832. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  2833. applied.
  2834. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  2835. the filter output video.
  2836. Note that as a consequence of the application of this filter, the
  2837. output display aspect ratio will change according to the equation
  2838. above.
  2839. Keep in mind that the sample aspect ratio set by the @code{setsar}
  2840. filter may be changed by later filters in the filterchain, e.g. if
  2841. another "setsar" or a "setdar" filter is applied.
  2842. The @code{setdar} and @code{setsar} filters accept a string in the
  2843. form @var{num}:@var{den} expressing an aspect ratio, or the following
  2844. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  2845. separated by ":".
  2846. @table @option
  2847. @item max
  2848. Set the maximum integer value to use for expressing numerator and
  2849. denominator when reducing the expressed aspect ratio to a rational.
  2850. Default value is @code{100}.
  2851. @item r, ratio:
  2852. Set the aspect ratio used by the filter.
  2853. The parameter can be a floating point number string, an expression, or
  2854. a string of the form @var{num}:@var{den}, where @var{num} and
  2855. @var{den} are the numerator and denominator of the aspect ratio. If
  2856. the parameter is not specified, it is assumed the value "0".
  2857. In case the form "@var{num}:@var{den}" the @code{:} character should
  2858. be escaped.
  2859. @end table
  2860. If the keys are omitted in the named options list, the specifed values
  2861. are assumed to be @var{ratio} and @var{max} in that order.
  2862. For example to change the display aspect ratio to 16:9, specify:
  2863. @example
  2864. setdar='16:9'
  2865. @end example
  2866. The example above is equivalent to:
  2867. @example
  2868. setdar=1.77777
  2869. @end example
  2870. To change the sample aspect ratio to 10:11, specify:
  2871. @example
  2872. setsar='10:11'
  2873. @end example
  2874. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  2875. 1000 in the aspect ratio reduction, use the command:
  2876. @example
  2877. setdar=ratio='16:9':max=1000
  2878. @end example
  2879. @section setfield
  2880. Force field for the output video frame.
  2881. The @code{setfield} filter marks the interlace type field for the
  2882. output frames. It does not change the input frame, but only sets the
  2883. corresponding property, which affects how the frame is treated by
  2884. following filters (e.g. @code{fieldorder} or @code{yadif}).
  2885. This filter accepts a single option @option{mode}, which can be
  2886. specified either by setting @code{mode=VALUE} or setting the value
  2887. alone. Available values are:
  2888. @table @samp
  2889. @item auto
  2890. Keep the same field property.
  2891. @item bff
  2892. Mark the frame as bottom-field-first.
  2893. @item tff
  2894. Mark the frame as top-field-first.
  2895. @item prog
  2896. Mark the frame as progressive.
  2897. @end table
  2898. @section showinfo
  2899. Show a line containing various information for each input video frame.
  2900. The input video is not modified.
  2901. The shown line contains a sequence of key/value pairs of the form
  2902. @var{key}:@var{value}.
  2903. A description of each shown parameter follows:
  2904. @table @option
  2905. @item n
  2906. sequential number of the input frame, starting from 0
  2907. @item pts
  2908. Presentation TimeStamp of the input frame, expressed as a number of
  2909. time base units. The time base unit depends on the filter input pad.
  2910. @item pts_time
  2911. Presentation TimeStamp of the input frame, expressed as a number of
  2912. seconds
  2913. @item pos
  2914. position of the frame in the input stream, -1 if this information in
  2915. unavailable and/or meaningless (for example in case of synthetic video)
  2916. @item fmt
  2917. pixel format name
  2918. @item sar
  2919. sample aspect ratio of the input frame, expressed in the form
  2920. @var{num}/@var{den}
  2921. @item s
  2922. size of the input frame, expressed in the form
  2923. @var{width}x@var{height}
  2924. @item i
  2925. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  2926. for bottom field first)
  2927. @item iskey
  2928. 1 if the frame is a key frame, 0 otherwise
  2929. @item type
  2930. picture type of the input frame ("I" for an I-frame, "P" for a
  2931. P-frame, "B" for a B-frame, "?" for unknown type).
  2932. Check also the documentation of the @code{AVPictureType} enum and of
  2933. the @code{av_get_picture_type_char} function defined in
  2934. @file{libavutil/avutil.h}.
  2935. @item checksum
  2936. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  2937. @item plane_checksum
  2938. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  2939. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  2940. @end table
  2941. @section smartblur
  2942. Blur the input video without impacting the outlines.
  2943. The filter accepts the following parameters:
  2944. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  2945. Parameters prefixed by @var{luma} indicate that they work on the
  2946. luminance of the pixels whereas parameters prefixed by @var{chroma}
  2947. refer to the chrominance of the pixels.
  2948. If the chroma parameters are not set, the luma parameters are used for
  2949. either the luminance and the chrominance of the pixels.
  2950. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  2951. range [0.1,5.0] that specifies the variance of the gaussian filter
  2952. used to blur the image (slower if larger).
  2953. @var{luma_strength} or @var{chroma_strength} must be a float number in
  2954. the range [-1.0,1.0] that configures the blurring. A value included in
  2955. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  2956. will sharpen the image.
  2957. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  2958. the range [-30,30] that is used as a coefficient to determine whether
  2959. a pixel should be blurred or not. A value of 0 will filter all the
  2960. image, a value included in [0,30] will filter flat areas and a value
  2961. included in [-30,0] will filter edges.
  2962. @anchor{subtitles}
  2963. @section subtitles
  2964. Draw subtitles on top of input video using the libass library.
  2965. To enable compilation of this filter you need to configure FFmpeg with
  2966. @code{--enable-libass}. This filter also requires a build with libavcodec and
  2967. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  2968. Alpha) subtitles format.
  2969. This filter accepts the following named options, expressed as a
  2970. sequence of @var{key}=@var{value} pairs, separated by ":".
  2971. @table @option
  2972. @item filename, f
  2973. Set the filename of the subtitle file to read. It must be specified.
  2974. @item original_size
  2975. Specify the size of the original video, the video for which the ASS file
  2976. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  2977. necessary to correctly scale the fonts if the aspect ratio has been changed.
  2978. @end table
  2979. If the first key is not specified, it is assumed that the first value
  2980. specifies the @option{filename}.
  2981. For example, to render the file @file{sub.srt} on top of the input
  2982. video, use the command:
  2983. @example
  2984. subtitles=sub.srt
  2985. @end example
  2986. which is equivalent to:
  2987. @example
  2988. subtitles=filename=sub.srt
  2989. @end example
  2990. @section split
  2991. Split input video into several identical outputs.
  2992. The filter accepts a single parameter which specifies the number of outputs. If
  2993. unspecified, it defaults to 2.
  2994. For example
  2995. @example
  2996. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  2997. @end example
  2998. will create 5 copies of the input video.
  2999. For example:
  3000. @example
  3001. [in] split [splitout1][splitout2];
  3002. [splitout1] crop=100:100:0:0 [cropout];
  3003. [splitout2] pad=200:200:100:100 [padout];
  3004. @end example
  3005. will create two separate outputs from the same input, one cropped and
  3006. one padded.
  3007. @section super2xsai
  3008. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3009. Interpolate) pixel art scaling algorithm.
  3010. Useful for enlarging pixel art images without reducing sharpness.
  3011. @section swapuv
  3012. Swap U & V plane.
  3013. @section thumbnail
  3014. Select the most representative frame in a given sequence of consecutive frames.
  3015. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3016. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3017. the next batch of @var{N} frames until the end.
  3018. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3019. value will result in a higher memory usage, so a high value is not recommended.
  3020. The following example extract one picture each 50 frames:
  3021. @example
  3022. thumbnail=50
  3023. @end example
  3024. Complete example of a thumbnail creation with @command{ffmpeg}:
  3025. @example
  3026. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3027. @end example
  3028. @section tile
  3029. Tile several successive frames together.
  3030. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3031. separated by ":". A description of the accepted options follows.
  3032. @table @option
  3033. @item layout
  3034. Set the grid size (i.e. the number of lines and columns) in the form
  3035. "@var{w}x@var{h}".
  3036. @item margin
  3037. Set the outer border margin in pixels.
  3038. @item padding
  3039. Set the inner border thickness (i.e. the number of pixels between frames). For
  3040. more advanced padding options (such as having different values for the edges),
  3041. refer to the pad video filter.
  3042. @item nb_frames
  3043. Set the maximum number of frames to render in the given area. It must be less
  3044. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3045. the area will be used.
  3046. @end table
  3047. Alternatively, the options can be specified as a flat string:
  3048. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3049. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  3050. nokey}) in a movie:
  3051. @example
  3052. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3053. @end example
  3054. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3055. duplicating each output frame to accomodate the originally detected frame
  3056. rate.
  3057. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3058. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3059. mixed flat and named options:
  3060. @example
  3061. tile=3x2:nb_frames=5:padding=7:margin=2
  3062. @end example
  3063. @section tinterlace
  3064. Perform various types of temporal field interlacing.
  3065. Frames are counted starting from 1, so the first input frame is
  3066. considered odd.
  3067. This filter accepts options in the form of @var{key}=@var{value} pairs
  3068. separated by ":".
  3069. Alternatively, the @var{mode} option can be specified as a value alone,
  3070. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3071. pairs.
  3072. A description of the accepted options follows.
  3073. @table @option
  3074. @item mode
  3075. Specify the mode of the interlacing. This option can also be specified
  3076. as a value alone. See below for a list of values for this option.
  3077. Available values are:
  3078. @table @samp
  3079. @item merge, 0
  3080. Move odd frames into the upper field, even into the lower field,
  3081. generating a double height frame at half framerate.
  3082. @item drop_odd, 1
  3083. Only output even frames, odd frames are dropped, generating a frame with
  3084. unchanged height at half framerate.
  3085. @item drop_even, 2
  3086. Only output odd frames, even frames are dropped, generating a frame with
  3087. unchanged height at half framerate.
  3088. @item pad, 3
  3089. Expand each frame to full height, but pad alternate lines with black,
  3090. generating a frame with double height at the same input framerate.
  3091. @item interleave_top, 4
  3092. Interleave the upper field from odd frames with the lower field from
  3093. even frames, generating a frame with unchanged height at half framerate.
  3094. @item interleave_bottom, 5
  3095. Interleave the lower field from odd frames with the upper field from
  3096. even frames, generating a frame with unchanged height at half framerate.
  3097. @item interlacex2, 6
  3098. Double frame rate with unchanged height. Frames are inserted each
  3099. containing the second temporal field from the previous input frame and
  3100. the first temporal field from the next input frame. This mode relies on
  3101. the top_field_first flag. Useful for interlaced video displays with no
  3102. field synchronisation.
  3103. @end table
  3104. Numeric values are deprecated but are accepted for backward
  3105. compatibility reasons.
  3106. Default mode is @code{merge}.
  3107. @item flags
  3108. Specify flags influencing the filter process.
  3109. Available value for @var{flags} is:
  3110. @table @option
  3111. @item low_pass_filter, vlfp
  3112. Enable vertical low-pass filtering in the filter.
  3113. Vertical low-pass filtering is required when creating an interlaced
  3114. destination from a progressive source which contains high-frequency
  3115. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3116. patterning.
  3117. Vertical low-pass filtering can only be enabled for @option{mode}
  3118. @var{interleave_top} and @var{interleave_bottom}.
  3119. @end table
  3120. @end table
  3121. @section transpose
  3122. Transpose rows with columns in the input video and optionally flip it.
  3123. The filter accepts parameters as a list of @var{key}=@var{value}
  3124. pairs, separated by ':'. If the key of the first options is omitted,
  3125. the arguments are interpreted according to the syntax
  3126. @var{dir}:@var{passthrough}.
  3127. @table @option
  3128. @item dir
  3129. Specify the transposition direction. Can assume the following values:
  3130. @table @samp
  3131. @item 0, 4
  3132. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3133. @example
  3134. L.R L.l
  3135. . . -> . .
  3136. l.r R.r
  3137. @end example
  3138. @item 1, 5
  3139. Rotate by 90 degrees clockwise, that is:
  3140. @example
  3141. L.R l.L
  3142. . . -> . .
  3143. l.r r.R
  3144. @end example
  3145. @item 2, 6
  3146. Rotate by 90 degrees counterclockwise, that is:
  3147. @example
  3148. L.R R.r
  3149. . . -> . .
  3150. l.r L.l
  3151. @end example
  3152. @item 3, 7
  3153. Rotate by 90 degrees clockwise and vertically flip, that is:
  3154. @example
  3155. L.R r.R
  3156. . . -> . .
  3157. l.r l.L
  3158. @end example
  3159. @end table
  3160. For values between 4-7, the transposition is only done if the input
  3161. video geometry is portrait and not landscape. These values are
  3162. deprecated, the @code{passthrough} option should be used instead.
  3163. @item passthrough
  3164. Do not apply the transposition if the input geometry matches the one
  3165. specified by the specified value. It accepts the following values:
  3166. @table @samp
  3167. @item none
  3168. Always apply transposition.
  3169. @item portrait
  3170. Preserve portrait geometry (when @var{height} >= @var{width}).
  3171. @item landscape
  3172. Preserve landscape geometry (when @var{width} >= @var{height}).
  3173. @end table
  3174. Default value is @code{none}.
  3175. @end table
  3176. For example to rotate by 90 degrees clockwise and preserve portrait
  3177. layout:
  3178. @example
  3179. transpose=dir=1:passthrough=portrait
  3180. @end example
  3181. The command above can also be specified as:
  3182. @example
  3183. transpose=1:portrait
  3184. @end example
  3185. @section unsharp
  3186. Sharpen or blur the input video.
  3187. It accepts the following parameters:
  3188. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3189. Negative values for the amount will blur the input video, while positive
  3190. values will sharpen. All parameters are optional and default to the
  3191. equivalent of the string '5:5:1.0:5:5:0.0'.
  3192. @table @option
  3193. @item luma_msize_x
  3194. Set the luma matrix horizontal size. It can be an integer between 3
  3195. and 13, default value is 5.
  3196. @item luma_msize_y
  3197. Set the luma matrix vertical size. It can be an integer between 3
  3198. and 13, default value is 5.
  3199. @item luma_amount
  3200. Set the luma effect strength. It can be a float number between -2.0
  3201. and 5.0, default value is 1.0.
  3202. @item chroma_msize_x
  3203. Set the chroma matrix horizontal size. It can be an integer between 3
  3204. and 13, default value is 5.
  3205. @item chroma_msize_y
  3206. Set the chroma matrix vertical size. It can be an integer between 3
  3207. and 13, default value is 5.
  3208. @item chroma_amount
  3209. Set the chroma effect strength. It can be a float number between -2.0
  3210. and 5.0, default value is 0.0.
  3211. @end table
  3212. @example
  3213. # Strong luma sharpen effect parameters
  3214. unsharp=7:7:2.5
  3215. # Strong blur of both luma and chroma parameters
  3216. unsharp=7:7:-2:7:7:-2
  3217. # Use the default values with @command{ffmpeg}
  3218. ffmpeg -i in.avi -vf "unsharp" out.mp4
  3219. @end example
  3220. @section vflip
  3221. Flip the input video vertically.
  3222. @example
  3223. ffmpeg -i in.avi -vf "vflip" out.avi
  3224. @end example
  3225. @section yadif
  3226. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3227. filter").
  3228. It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}.
  3229. @var{mode} specifies the interlacing mode to adopt, accepts one of the
  3230. following values:
  3231. @table @option
  3232. @item 0
  3233. output 1 frame for each frame
  3234. @item 1
  3235. output 1 frame for each field
  3236. @item 2
  3237. like 0 but skips spatial interlacing check
  3238. @item 3
  3239. like 1 but skips spatial interlacing check
  3240. @end table
  3241. Default value is 0.
  3242. @var{parity} specifies the picture field parity assumed for the input
  3243. interlaced video, accepts one of the following values:
  3244. @table @option
  3245. @item 0
  3246. assume top field first
  3247. @item 1
  3248. assume bottom field first
  3249. @item -1
  3250. enable automatic detection
  3251. @end table
  3252. Default value is -1.
  3253. If interlacing is unknown or decoder does not export this information,
  3254. top field first will be assumed.
  3255. @var{auto} specifies if deinterlacer should trust the interlaced flag
  3256. and only deinterlace frames marked as interlaced
  3257. @table @option
  3258. @item 0
  3259. deinterlace all frames
  3260. @item 1
  3261. only deinterlace frames marked as interlaced
  3262. @end table
  3263. Default value is 0.
  3264. @c man end VIDEO FILTERS
  3265. @chapter Video Sources
  3266. @c man begin VIDEO SOURCES
  3267. Below is a description of the currently available video sources.
  3268. @section buffer
  3269. Buffer video frames, and make them available to the filter chain.
  3270. This source is mainly intended for a programmatic use, in particular
  3271. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3272. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3273. separated by ":". A description of the accepted options follows.
  3274. @table @option
  3275. @item video_size
  3276. Specify the size (width and height) of the buffered video frames.
  3277. @item pix_fmt
  3278. A string representing the pixel format of the buffered video frames.
  3279. It may be a number corresponding to a pixel format, or a pixel format
  3280. name.
  3281. @item time_base
  3282. Specify the timebase assumed by the timestamps of the buffered frames.
  3283. @item time_base
  3284. Specify the frame rate expected for the video stream.
  3285. @item pixel_aspect
  3286. Specify the sample aspect ratio assumed by the video frames.
  3287. @item sws_param
  3288. Specify the optional parameters to be used for the scale filter which
  3289. is automatically inserted when an input change is detected in the
  3290. input size or format.
  3291. @end table
  3292. For example:
  3293. @example
  3294. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3295. @end example
  3296. will instruct the source to accept video frames with size 320x240 and
  3297. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3298. square pixels (1:1 sample aspect ratio).
  3299. Since the pixel format with name "yuv410p" corresponds to the number 6
  3300. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3301. this example corresponds to:
  3302. @example
  3303. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3304. @end example
  3305. Alternatively, the options can be specified as a flat string, but this
  3306. syntax is deprecated:
  3307. @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}]
  3308. @section cellauto
  3309. Create a pattern generated by an elementary cellular automaton.
  3310. The initial state of the cellular automaton can be defined through the
  3311. @option{filename}, and @option{pattern} options. If such options are
  3312. not specified an initial state is created randomly.
  3313. At each new frame a new row in the video is filled with the result of
  3314. the cellular automaton next generation. The behavior when the whole
  3315. frame is filled is defined by the @option{scroll} option.
  3316. This source accepts a list of options in the form of
  3317. @var{key}=@var{value} pairs separated by ":". A description of the
  3318. accepted options follows.
  3319. @table @option
  3320. @item filename, f
  3321. Read the initial cellular automaton state, i.e. the starting row, from
  3322. the specified file.
  3323. In the file, each non-whitespace character is considered an alive
  3324. cell, a newline will terminate the row, and further characters in the
  3325. file will be ignored.
  3326. @item pattern, p
  3327. Read the initial cellular automaton state, i.e. the starting row, from
  3328. the specified string.
  3329. Each non-whitespace character in the string is considered an alive
  3330. cell, a newline will terminate the row, and further characters in the
  3331. string will be ignored.
  3332. @item rate, r
  3333. Set the video rate, that is the number of frames generated per second.
  3334. Default is 25.
  3335. @item random_fill_ratio, ratio
  3336. Set the random fill ratio for the initial cellular automaton row. It
  3337. is a floating point number value ranging from 0 to 1, defaults to
  3338. 1/PHI.
  3339. This option is ignored when a file or a pattern is specified.
  3340. @item random_seed, seed
  3341. Set the seed for filling randomly the initial row, must be an integer
  3342. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3343. set to -1, the filter will try to use a good random seed on a best
  3344. effort basis.
  3345. @item rule
  3346. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3347. Default value is 110.
  3348. @item size, s
  3349. Set the size of the output video.
  3350. If @option{filename} or @option{pattern} is specified, the size is set
  3351. by default to the width of the specified initial state row, and the
  3352. height is set to @var{width} * PHI.
  3353. If @option{size} is set, it must contain the width of the specified
  3354. pattern string, and the specified pattern will be centered in the
  3355. larger row.
  3356. If a filename or a pattern string is not specified, the size value
  3357. defaults to "320x518" (used for a randomly generated initial state).
  3358. @item scroll
  3359. If set to 1, scroll the output upward when all the rows in the output
  3360. have been already filled. If set to 0, the new generated row will be
  3361. written over the top row just after the bottom row is filled.
  3362. Defaults to 1.
  3363. @item start_full, full
  3364. If set to 1, completely fill the output with generated rows before
  3365. outputting the first frame.
  3366. This is the default behavior, for disabling set the value to 0.
  3367. @item stitch
  3368. If set to 1, stitch the left and right row edges together.
  3369. This is the default behavior, for disabling set the value to 0.
  3370. @end table
  3371. @subsection Examples
  3372. @itemize
  3373. @item
  3374. Read the initial state from @file{pattern}, and specify an output of
  3375. size 200x400.
  3376. @example
  3377. cellauto=f=pattern:s=200x400
  3378. @end example
  3379. @item
  3380. Generate a random initial row with a width of 200 cells, with a fill
  3381. ratio of 2/3:
  3382. @example
  3383. cellauto=ratio=2/3:s=200x200
  3384. @end example
  3385. @item
  3386. Create a pattern generated by rule 18 starting by a single alive cell
  3387. centered on an initial row with width 100:
  3388. @example
  3389. cellauto=p=@@:s=100x400:full=0:rule=18
  3390. @end example
  3391. @item
  3392. Specify a more elaborated initial pattern:
  3393. @example
  3394. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3395. @end example
  3396. @end itemize
  3397. @section mandelbrot
  3398. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3399. point specified with @var{start_x} and @var{start_y}.
  3400. This source accepts a list of options in the form of
  3401. @var{key}=@var{value} pairs separated by ":". A description of the
  3402. accepted options follows.
  3403. @table @option
  3404. @item end_pts
  3405. Set the terminal pts value. Default value is 400.
  3406. @item end_scale
  3407. Set the terminal scale value.
  3408. Must be a floating point value. Default value is 0.3.
  3409. @item inner
  3410. Set the inner coloring mode, that is the algorithm used to draw the
  3411. Mandelbrot fractal internal region.
  3412. It shall assume one of the following values:
  3413. @table @option
  3414. @item black
  3415. Set black mode.
  3416. @item convergence
  3417. Show time until convergence.
  3418. @item mincol
  3419. Set color based on point closest to the origin of the iterations.
  3420. @item period
  3421. Set period mode.
  3422. @end table
  3423. Default value is @var{mincol}.
  3424. @item bailout
  3425. Set the bailout value. Default value is 10.0.
  3426. @item maxiter
  3427. Set the maximum of iterations performed by the rendering
  3428. algorithm. Default value is 7189.
  3429. @item outer
  3430. Set outer coloring mode.
  3431. It shall assume one of following values:
  3432. @table @option
  3433. @item iteration_count
  3434. Set iteration cound mode.
  3435. @item normalized_iteration_count
  3436. set normalized iteration count mode.
  3437. @end table
  3438. Default value is @var{normalized_iteration_count}.
  3439. @item rate, r
  3440. Set frame rate, expressed as number of frames per second. Default
  3441. value is "25".
  3442. @item size, s
  3443. Set frame size. Default value is "640x480".
  3444. @item start_scale
  3445. Set the initial scale value. Default value is 3.0.
  3446. @item start_x
  3447. Set the initial x position. Must be a floating point value between
  3448. -100 and 100. Default value is -0.743643887037158704752191506114774.
  3449. @item start_y
  3450. Set the initial y position. Must be a floating point value between
  3451. -100 and 100. Default value is -0.131825904205311970493132056385139.
  3452. @end table
  3453. @section mptestsrc
  3454. Generate various test patterns, as generated by the MPlayer test filter.
  3455. The size of the generated video is fixed, and is 256x256.
  3456. This source is useful in particular for testing encoding features.
  3457. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  3458. separated by ":". The description of the accepted options follows.
  3459. @table @option
  3460. @item rate, r
  3461. Specify the frame rate of the sourced video, as the number of frames
  3462. generated per second. It has to be a string in the format
  3463. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3464. number or a valid video frame rate abbreviation. The default value is
  3465. "25".
  3466. @item duration, d
  3467. Set the video duration of the sourced video. The accepted syntax is:
  3468. @example
  3469. [-]HH:MM:SS[.m...]
  3470. [-]S+[.m...]
  3471. @end example
  3472. See also the function @code{av_parse_time()}.
  3473. If not specified, or the expressed duration is negative, the video is
  3474. supposed to be generated forever.
  3475. @item test, t
  3476. Set the number or the name of the test to perform. Supported tests are:
  3477. @table @option
  3478. @item dc_luma
  3479. @item dc_chroma
  3480. @item freq_luma
  3481. @item freq_chroma
  3482. @item amp_luma
  3483. @item amp_chroma
  3484. @item cbp
  3485. @item mv
  3486. @item ring1
  3487. @item ring2
  3488. @item all
  3489. @end table
  3490. Default value is "all", which will cycle through the list of all tests.
  3491. @end table
  3492. For example the following:
  3493. @example
  3494. testsrc=t=dc_luma
  3495. @end example
  3496. will generate a "dc_luma" test pattern.
  3497. @section frei0r_src
  3498. Provide a frei0r source.
  3499. To enable compilation of this filter you need to install the frei0r
  3500. header and configure FFmpeg with @code{--enable-frei0r}.
  3501. The source supports the syntax:
  3502. @example
  3503. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  3504. @end example
  3505. @var{size} is the size of the video to generate, may be a string of the
  3506. form @var{width}x@var{height} or a frame size abbreviation.
  3507. @var{rate} is the rate of the video to generate, may be a string of
  3508. the form @var{num}/@var{den} or a frame rate abbreviation.
  3509. @var{src_name} is the name to the frei0r source to load. For more
  3510. information regarding frei0r and how to set the parameters read the
  3511. section @ref{frei0r} in the description of the video filters.
  3512. For example, to generate a frei0r partik0l source with size 200x200
  3513. and frame rate 10 which is overlayed on the overlay filter main input:
  3514. @example
  3515. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  3516. @end example
  3517. @section life
  3518. Generate a life pattern.
  3519. This source is based on a generalization of John Conway's life game.
  3520. The sourced input represents a life grid, each pixel represents a cell
  3521. which can be in one of two possible states, alive or dead. Every cell
  3522. interacts with its eight neighbours, which are the cells that are
  3523. horizontally, vertically, or diagonally adjacent.
  3524. At each interaction the grid evolves according to the adopted rule,
  3525. which specifies the number of neighbor alive cells which will make a
  3526. cell stay alive or born. The @option{rule} option allows to specify
  3527. the rule to adopt.
  3528. This source accepts a list of options in the form of
  3529. @var{key}=@var{value} pairs separated by ":". A description of the
  3530. accepted options follows.
  3531. @table @option
  3532. @item filename, f
  3533. Set the file from which to read the initial grid state. In the file,
  3534. each non-whitespace character is considered an alive cell, and newline
  3535. is used to delimit the end of each row.
  3536. If this option is not specified, the initial grid is generated
  3537. randomly.
  3538. @item rate, r
  3539. Set the video rate, that is the number of frames generated per second.
  3540. Default is 25.
  3541. @item random_fill_ratio, ratio
  3542. Set the random fill ratio for the initial random grid. It is a
  3543. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  3544. It is ignored when a file is specified.
  3545. @item random_seed, seed
  3546. Set the seed for filling the initial random grid, must be an integer
  3547. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3548. set to -1, the filter will try to use a good random seed on a best
  3549. effort basis.
  3550. @item rule
  3551. Set the life rule.
  3552. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  3553. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  3554. @var{NS} specifies the number of alive neighbor cells which make a
  3555. live cell stay alive, and @var{NB} the number of alive neighbor cells
  3556. which make a dead cell to become alive (i.e. to "born").
  3557. "s" and "b" can be used in place of "S" and "B", respectively.
  3558. Alternatively a rule can be specified by an 18-bits integer. The 9
  3559. high order bits are used to encode the next cell state if it is alive
  3560. for each number of neighbor alive cells, the low order bits specify
  3561. the rule for "borning" new cells. Higher order bits encode for an
  3562. higher number of neighbor cells.
  3563. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  3564. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  3565. Default value is "S23/B3", which is the original Conway's game of life
  3566. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  3567. cells, and will born a new cell if there are three alive cells around
  3568. a dead cell.
  3569. @item size, s
  3570. Set the size of the output video.
  3571. If @option{filename} is specified, the size is set by default to the
  3572. same size of the input file. If @option{size} is set, it must contain
  3573. the size specified in the input file, and the initial grid defined in
  3574. that file is centered in the larger resulting area.
  3575. If a filename is not specified, the size value defaults to "320x240"
  3576. (used for a randomly generated initial grid).
  3577. @item stitch
  3578. If set to 1, stitch the left and right grid edges together, and the
  3579. top and bottom edges also. Defaults to 1.
  3580. @item mold
  3581. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  3582. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  3583. value from 0 to 255.
  3584. @item life_color
  3585. Set the color of living (or new born) cells.
  3586. @item death_color
  3587. Set the color of dead cells. If @option{mold} is set, this is the first color
  3588. used to represent a dead cell.
  3589. @item mold_color
  3590. Set mold color, for definitely dead and moldy cells.
  3591. @end table
  3592. @subsection Examples
  3593. @itemize
  3594. @item
  3595. Read a grid from @file{pattern}, and center it on a grid of size
  3596. 300x300 pixels:
  3597. @example
  3598. life=f=pattern:s=300x300
  3599. @end example
  3600. @item
  3601. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  3602. @example
  3603. life=ratio=2/3:s=200x200
  3604. @end example
  3605. @item
  3606. Specify a custom rule for evolving a randomly generated grid:
  3607. @example
  3608. life=rule=S14/B34
  3609. @end example
  3610. @item
  3611. Full example with slow death effect (mold) using @command{ffplay}:
  3612. @example
  3613. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  3614. @end example
  3615. @end itemize
  3616. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  3617. The @code{color} source provides an uniformly colored input.
  3618. The @code{nullsrc} source returns unprocessed video frames. It is
  3619. mainly useful to be employed in analysis / debugging tools, or as the
  3620. source for filters which ignore the input data.
  3621. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  3622. detecting RGB vs BGR issues. You should see a red, green and blue
  3623. stripe from top to bottom.
  3624. The @code{smptebars} source generates a color bars pattern, based on
  3625. the SMPTE Engineering Guideline EG 1-1990.
  3626. The @code{testsrc} source generates a test video pattern, showing a
  3627. color pattern, a scrolling gradient and a timestamp. This is mainly
  3628. intended for testing purposes.
  3629. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  3630. separated by ":". The description of the accepted options follows.
  3631. @table @option
  3632. @item color, c
  3633. Specify the color of the source, only used in the @code{color}
  3634. source. It can be the name of a color (case insensitive match) or a
  3635. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  3636. default value is "black".
  3637. @item size, s
  3638. Specify the size of the sourced video, it may be a string of the form
  3639. @var{width}x@var{height}, or the name of a size abbreviation. The
  3640. default value is "320x240".
  3641. @item rate, r
  3642. Specify the frame rate of the sourced video, as the number of frames
  3643. generated per second. It has to be a string in the format
  3644. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3645. number or a valid video frame rate abbreviation. The default value is
  3646. "25".
  3647. @item sar
  3648. Set the sample aspect ratio of the sourced video.
  3649. @item duration, d
  3650. Set the video duration of the sourced video. The accepted syntax is:
  3651. @example
  3652. [-]HH[:MM[:SS[.m...]]]
  3653. [-]S+[.m...]
  3654. @end example
  3655. See also the function @code{av_parse_time()}.
  3656. If not specified, or the expressed duration is negative, the video is
  3657. supposed to be generated forever.
  3658. @item decimals, n
  3659. Set the number of decimals to show in the timestamp, only used in the
  3660. @code{testsrc} source.
  3661. The displayed timestamp value will correspond to the original
  3662. timestamp value multiplied by the power of 10 of the specified
  3663. value. Default value is 0.
  3664. @end table
  3665. For example the following:
  3666. @example
  3667. testsrc=duration=5.3:size=qcif:rate=10
  3668. @end example
  3669. will generate a video with a duration of 5.3 seconds, with size
  3670. 176x144 and a frame rate of 10 frames per second.
  3671. The following graph description will generate a red source
  3672. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  3673. frames per second.
  3674. @example
  3675. color=c=red@@0.2:s=qcif:r=10
  3676. @end example
  3677. If the input content is to be ignored, @code{nullsrc} can be used. The
  3678. following command generates noise in the luminance plane by employing
  3679. the @code{geq} filter:
  3680. @example
  3681. nullsrc=s=256x256, geq=random(1)*255:128:128
  3682. @end example
  3683. @c man end VIDEO SOURCES
  3684. @chapter Video Sinks
  3685. @c man begin VIDEO SINKS
  3686. Below is a description of the currently available video sinks.
  3687. @section buffersink
  3688. Buffer video frames, and make them available to the end of the filter
  3689. graph.
  3690. This sink is mainly intended for a programmatic use, in particular
  3691. through the interface defined in @file{libavfilter/buffersink.h}.
  3692. It does not require a string parameter in input, but you need to
  3693. specify a pointer to a list of supported pixel formats terminated by
  3694. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  3695. when initializing this sink.
  3696. @section nullsink
  3697. Null video sink, do absolutely nothing with the input video. It is
  3698. mainly useful as a template and to be employed in analysis / debugging
  3699. tools.
  3700. @c man end VIDEO SINKS
  3701. @chapter Multimedia Filters
  3702. @c man begin MULTIMEDIA FILTERS
  3703. Below is a description of the currently available multimedia filters.
  3704. @section aselect, select
  3705. Select frames to pass in output.
  3706. These filters accept a single option @option{expr} or @option{e}
  3707. specifying the select expression, which can be specified either by
  3708. specyfing @code{expr=VALUE} or specifying the expression
  3709. alone.
  3710. The select expression is evaluated for each input frame. If the
  3711. evaluation result is a non-zero value, the frame is selected and
  3712. passed to the output, otherwise it is discarded.
  3713. The expression can contain the following constants:
  3714. @table @option
  3715. @item n
  3716. the sequential number of the filtered frame, starting from 0
  3717. @item selected_n
  3718. the sequential number of the selected frame, starting from 0
  3719. @item prev_selected_n
  3720. the sequential number of the last selected frame, NAN if undefined
  3721. @item TB
  3722. timebase of the input timestamps
  3723. @item pts
  3724. the PTS (Presentation TimeStamp) of the filtered video frame,
  3725. expressed in @var{TB} units, NAN if undefined
  3726. @item t
  3727. the PTS (Presentation TimeStamp) of the filtered video frame,
  3728. expressed in seconds, NAN if undefined
  3729. @item prev_pts
  3730. the PTS of the previously filtered video frame, NAN if undefined
  3731. @item prev_selected_pts
  3732. the PTS of the last previously filtered video frame, NAN if undefined
  3733. @item prev_selected_t
  3734. the PTS of the last previously selected video frame, NAN if undefined
  3735. @item start_pts
  3736. the PTS of the first video frame in the video, NAN if undefined
  3737. @item start_t
  3738. the time of the first video frame in the video, NAN if undefined
  3739. @item pict_type @emph{(video only)}
  3740. the type of the filtered frame, can assume one of the following
  3741. values:
  3742. @table @option
  3743. @item I
  3744. @item P
  3745. @item B
  3746. @item S
  3747. @item SI
  3748. @item SP
  3749. @item BI
  3750. @end table
  3751. @item interlace_type @emph{(video only)}
  3752. the frame interlace type, can assume one of the following values:
  3753. @table @option
  3754. @item PROGRESSIVE
  3755. the frame is progressive (not interlaced)
  3756. @item TOPFIRST
  3757. the frame is top-field-first
  3758. @item BOTTOMFIRST
  3759. the frame is bottom-field-first
  3760. @end table
  3761. @item consumed_sample_n @emph{(audio only)}
  3762. the number of selected samples before the current frame
  3763. @item samples_n @emph{(audio only)}
  3764. the number of samples in the current frame
  3765. @item sample_rate @emph{(audio only)}
  3766. the input sample rate
  3767. @item key
  3768. 1 if the filtered frame is a key-frame, 0 otherwise
  3769. @item pos
  3770. the position in the file of the filtered frame, -1 if the information
  3771. is not available (e.g. for synthetic video)
  3772. @item scene @emph{(video only)}
  3773. value between 0 and 1 to indicate a new scene; a low value reflects a low
  3774. probability for the current frame to introduce a new scene, while a higher
  3775. value means the current frame is more likely to be one (see the example below)
  3776. @end table
  3777. The default value of the select expression is "1".
  3778. @subsection Examples
  3779. @itemize
  3780. @item
  3781. Select all frames in input:
  3782. @example
  3783. select
  3784. @end example
  3785. The example above is the same as:
  3786. @example
  3787. select=1
  3788. @end example
  3789. @item
  3790. Skip all frames:
  3791. @example
  3792. select=0
  3793. @end example
  3794. @item
  3795. Select only I-frames:
  3796. @example
  3797. select='eq(pict_type\,I)'
  3798. @end example
  3799. @item
  3800. Select one frame every 100:
  3801. @example
  3802. select='not(mod(n\,100))'
  3803. @end example
  3804. @item
  3805. Select only frames contained in the 10-20 time interval:
  3806. @example
  3807. select='gte(t\,10)*lte(t\,20)'
  3808. @end example
  3809. @item
  3810. Select only I frames contained in the 10-20 time interval:
  3811. @example
  3812. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  3813. @end example
  3814. @item
  3815. Select frames with a minimum distance of 10 seconds:
  3816. @example
  3817. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  3818. @end example
  3819. @item
  3820. Use aselect to select only audio frames with samples number > 100:
  3821. @example
  3822. aselect='gt(samples_n\,100)'
  3823. @end example
  3824. @item
  3825. Create a mosaic of the first scenes:
  3826. @example
  3827. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  3828. @end example
  3829. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  3830. choice.
  3831. @end itemize
  3832. @section asendcmd, sendcmd
  3833. Send commands to filters in the filtergraph.
  3834. These filters read commands to be sent to other filters in the
  3835. filtergraph.
  3836. @code{asendcmd} must be inserted between two audio filters,
  3837. @code{sendcmd} must be inserted between two video filters, but apart
  3838. from that they act the same way.
  3839. The specification of commands can be provided in the filter arguments
  3840. with the @var{commands} option, or in a file specified by the
  3841. @var{filename} option.
  3842. These filters accept the following options:
  3843. @table @option
  3844. @item commands, c
  3845. Set the commands to be read and sent to the other filters.
  3846. @item filename, f
  3847. Set the filename of the commands to be read and sent to the other
  3848. filters.
  3849. @end table
  3850. @subsection Commands syntax
  3851. A commands description consists of a sequence of interval
  3852. specifications, comprising a list of commands to be executed when a
  3853. particular event related to that interval occurs. The occurring event
  3854. is typically the current frame time entering or leaving a given time
  3855. interval.
  3856. An interval is specified by the following syntax:
  3857. @example
  3858. @var{START}[-@var{END}] @var{COMMANDS};
  3859. @end example
  3860. The time interval is specified by the @var{START} and @var{END} times.
  3861. @var{END} is optional and defaults to the maximum time.
  3862. The current frame time is considered within the specified interval if
  3863. it is included in the interval [@var{START}, @var{END}), that is when
  3864. the time is greater or equal to @var{START} and is lesser than
  3865. @var{END}.
  3866. @var{COMMANDS} consists of a sequence of one or more command
  3867. specifications, separated by ",", relating to that interval. The
  3868. syntax of a command specification is given by:
  3869. @example
  3870. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  3871. @end example
  3872. @var{FLAGS} is optional and specifies the type of events relating to
  3873. the time interval which enable sending the specified command, and must
  3874. be a non-null sequence of identifier flags separated by "+" or "|" and
  3875. enclosed between "[" and "]".
  3876. The following flags are recognized:
  3877. @table @option
  3878. @item enter
  3879. The command is sent when the current frame timestamp enters the
  3880. specified interval. In other words, the command is sent when the
  3881. previous frame timestamp was not in the given interval, and the
  3882. current is.
  3883. @item leave
  3884. The command is sent when the current frame timestamp leaves the
  3885. specified interval. In other words, the command is sent when the
  3886. previous frame timestamp was in the given interval, and the
  3887. current is not.
  3888. @end table
  3889. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  3890. assumed.
  3891. @var{TARGET} specifies the target of the command, usually the name of
  3892. the filter class or a specific filter instance name.
  3893. @var{COMMAND} specifies the name of the command for the target filter.
  3894. @var{ARG} is optional and specifies the optional list of argument for
  3895. the given @var{COMMAND}.
  3896. Between one interval specification and another, whitespaces, or
  3897. sequences of characters starting with @code{#} until the end of line,
  3898. are ignored and can be used to annotate comments.
  3899. A simplified BNF description of the commands specification syntax
  3900. follows:
  3901. @example
  3902. @var{COMMAND_FLAG} ::= "enter" | "leave"
  3903. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  3904. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  3905. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  3906. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  3907. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  3908. @end example
  3909. @subsection Examples
  3910. @itemize
  3911. @item
  3912. Specify audio tempo change at second 4:
  3913. @example
  3914. asendcmd=c='4.0 atempo tempo 1.5',atempo
  3915. @end example
  3916. @item
  3917. Specify a list of drawtext and hue commands in a file.
  3918. @example
  3919. # show text in the interval 5-10
  3920. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  3921. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  3922. # desaturate the image in the interval 15-20
  3923. 15.0-20.0 [enter] hue reinit s=0,
  3924. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  3925. [leave] hue reinit s=1,
  3926. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  3927. # apply an exponential saturation fade-out effect, starting from time 25
  3928. 25 [enter] hue s=exp(t-25)
  3929. @end example
  3930. A filtergraph allowing to read and process the above command list
  3931. stored in a file @file{test.cmd}, can be specified with:
  3932. @example
  3933. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  3934. @end example
  3935. @end itemize
  3936. @anchor{setpts}
  3937. @section asetpts, setpts
  3938. Change the PTS (presentation timestamp) of the input frames.
  3939. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  3940. Accept in input an expression evaluated through the eval API, which
  3941. can contain the following constants:
  3942. @table @option
  3943. @item FRAME_RATE
  3944. frame rate, only defined for constant frame-rate video
  3945. @item PTS
  3946. the presentation timestamp in input
  3947. @item N
  3948. the count of the input frame, starting from 0.
  3949. @item NB_CONSUMED_SAMPLES
  3950. the number of consumed samples, not including the current frame (only
  3951. audio)
  3952. @item NB_SAMPLES
  3953. the number of samples in the current frame (only audio)
  3954. @item SAMPLE_RATE
  3955. audio sample rate
  3956. @item STARTPTS
  3957. the PTS of the first frame
  3958. @item STARTT
  3959. the time in seconds of the first frame
  3960. @item INTERLACED
  3961. tell if the current frame is interlaced
  3962. @item T
  3963. the time in seconds of the current frame
  3964. @item TB
  3965. the time base
  3966. @item POS
  3967. original position in the file of the frame, or undefined if undefined
  3968. for the current frame
  3969. @item PREV_INPTS
  3970. previous input PTS
  3971. @item PREV_INT
  3972. previous input time in seconds
  3973. @item PREV_OUTPTS
  3974. previous output PTS
  3975. @item PREV_OUTT
  3976. previous output time in seconds
  3977. @end table
  3978. @subsection Examples
  3979. @itemize
  3980. @item
  3981. Start counting PTS from zero
  3982. @example
  3983. setpts=PTS-STARTPTS
  3984. @end example
  3985. @item
  3986. Apply fast motion effect:
  3987. @example
  3988. setpts=0.5*PTS
  3989. @end example
  3990. @item
  3991. Apply slow motion effect:
  3992. @example
  3993. setpts=2.0*PTS
  3994. @end example
  3995. @item
  3996. Set fixed rate of 25 frames per second:
  3997. @example
  3998. setpts=N/(25*TB)
  3999. @end example
  4000. @item
  4001. Set fixed rate 25 fps with some jitter:
  4002. @example
  4003. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4004. @end example
  4005. @item
  4006. Apply an offset of 10 seconds to the input PTS:
  4007. @example
  4008. setpts=PTS+10/TB
  4009. @end example
  4010. @end itemize
  4011. @section ebur128
  4012. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4013. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4014. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4015. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4016. The filter also has a video output (see the @var{video} option) with a real
  4017. time graph to observe the loudness evolution. The graphic contains the logged
  4018. message mentioned above, so it is not printed anymore when this option is set,
  4019. unless the verbose logging is set. The main graphing area contains the
  4020. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4021. the momentary loudness (400 milliseconds).
  4022. More information about the Loudness Recommendation EBU R128 on
  4023. @url{http://tech.ebu.ch/loudness}.
  4024. The filter accepts the following named parameters:
  4025. @table @option
  4026. @item video
  4027. Activate the video output. The audio stream is passed unchanged whether this
  4028. option is set or no. The video stream will be the first output stream if
  4029. activated. Default is @code{0}.
  4030. @item size
  4031. Set the video size. This option is for video only. Default and minimum
  4032. resolution is @code{640x480}.
  4033. @item meter
  4034. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4035. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4036. other integer value between this range is allowed.
  4037. @end table
  4038. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4039. @example
  4040. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4041. @end example
  4042. Run an analysis with @command{ffmpeg}:
  4043. @example
  4044. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4045. @end example
  4046. @section settb, asettb
  4047. Set the timebase to use for the output frames timestamps.
  4048. It is mainly useful for testing timebase configuration.
  4049. It accepts in input an arithmetic expression representing a rational.
  4050. The expression can contain the constants "AVTB" (the
  4051. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4052. audio only).
  4053. The default value for the input is "intb".
  4054. @subsection Examples
  4055. @itemize
  4056. @item
  4057. Set the timebase to 1/25:
  4058. @example
  4059. settb=1/25
  4060. @end example
  4061. @item
  4062. Set the timebase to 1/10:
  4063. @example
  4064. settb=0.1
  4065. @end example
  4066. @item
  4067. Set the timebase to 1001/1000:
  4068. @example
  4069. settb=1+0.001
  4070. @end example
  4071. @item
  4072. Set the timebase to 2*intb:
  4073. @example
  4074. settb=2*intb
  4075. @end example
  4076. @item
  4077. Set the default timebase value:
  4078. @example
  4079. settb=AVTB
  4080. @end example
  4081. @end itemize
  4082. @section concat
  4083. Concatenate audio and video streams, joining them together one after the
  4084. other.
  4085. The filter works on segments of synchronized video and audio streams. All
  4086. segments must have the same number of streams of each type, and that will
  4087. also be the number of streams at output.
  4088. The filter accepts the following named parameters:
  4089. @table @option
  4090. @item n
  4091. Set the number of segments. Default is 2.
  4092. @item v
  4093. Set the number of output video streams, that is also the number of video
  4094. streams in each segment. Default is 1.
  4095. @item a
  4096. Set the number of output audio streams, that is also the number of video
  4097. streams in each segment. Default is 0.
  4098. @item unsafe
  4099. Activate unsafe mode: do not fail if segments have a different format.
  4100. @end table
  4101. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4102. @var{a} audio outputs.
  4103. There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first
  4104. segment, in the same order as the outputs, then the inputs for the second
  4105. segment, etc.
  4106. Related streams do not always have exactly the same duration, for various
  4107. reasons including codec frame size or sloppy authoring. For that reason,
  4108. related synchronized streams (e.g. a video and its audio track) should be
  4109. concatenated at once. The concat filter will use the duration of the longest
  4110. stream in each segment (except the last one), and if necessary pad shorter
  4111. audio streams with silence.
  4112. For this filter to work correctly, all segments must start at timestamp 0.
  4113. All corresponding streams must have the same parameters in all segments; the
  4114. filtering system will automatically select a common pixel format for video
  4115. streams, and a common sample format, sample rate and channel layout for
  4116. audio streams, but other settings, such as resolution, must be converted
  4117. explicitly by the user.
  4118. Different frame rates are acceptable but will result in variable frame rate
  4119. at output; be sure to configure the output file to handle it.
  4120. Examples:
  4121. @itemize
  4122. @item
  4123. Concatenate an opening, an episode and an ending, all in bilingual version
  4124. (video in stream 0, audio in streams 1 and 2):
  4125. @example
  4126. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4127. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4128. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4129. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4130. @end example
  4131. @item
  4132. Concatenate two parts, handling audio and video separately, using the
  4133. (a)movie sources, and adjusting the resolution:
  4134. @example
  4135. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4136. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4137. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4138. @end example
  4139. Note that a desync will happen at the stitch if the audio and video streams
  4140. do not have exactly the same duration in the first file.
  4141. @end itemize
  4142. @section showspectrum
  4143. Convert input audio to a video output, representing the audio frequency
  4144. spectrum.
  4145. The filter accepts the following named parameters:
  4146. @table @option
  4147. @item size, s
  4148. Specify the video size for the output. Default value is @code{640x480}.
  4149. @item slide
  4150. Specify if the spectrum should slide along the window. Default value is
  4151. @code{0}.
  4152. @end table
  4153. The usage is very similar to the showwaves filter; see the examples in that
  4154. section.
  4155. @section showwaves
  4156. Convert input audio to a video output, representing the samples waves.
  4157. The filter accepts the following named parameters:
  4158. @table @option
  4159. @item n
  4160. Set the number of samples which are printed on the same column. A
  4161. larger value will decrease the frame rate. Must be a positive
  4162. integer. This option can be set only if the value for @var{rate}
  4163. is not explicitly specified.
  4164. @item rate, r
  4165. Set the (approximate) output frame rate. This is done by setting the
  4166. option @var{n}. Default value is "25".
  4167. @item size, s
  4168. Specify the video size for the output. Default value is "600x240".
  4169. @end table
  4170. Some examples follow.
  4171. @itemize
  4172. @item
  4173. Output the input file audio and the corresponding video representation
  4174. at the same time:
  4175. @example
  4176. amovie=a.mp3,asplit[out0],showwaves[out1]
  4177. @end example
  4178. @item
  4179. Create a synthetic signal and show it with showwaves, forcing a
  4180. framerate of 30 frames per second:
  4181. @example
  4182. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4183. @end example
  4184. @end itemize
  4185. @c man end MULTIMEDIA FILTERS
  4186. @chapter Multimedia Sources
  4187. @c man begin MULTIMEDIA SOURCES
  4188. Below is a description of the currently available multimedia sources.
  4189. @section amovie
  4190. This is the same as @ref{movie} source, except it selects an audio
  4191. stream by default.
  4192. @anchor{movie}
  4193. @section movie
  4194. Read audio and/or video stream(s) from a movie container.
  4195. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4196. @var{movie_name} is the name of the resource to read (not necessarily
  4197. a file but also a device or a stream accessed through some protocol),
  4198. and @var{options} is an optional sequence of @var{key}=@var{value}
  4199. pairs, separated by ":".
  4200. The description of the accepted options follows.
  4201. @table @option
  4202. @item format_name, f
  4203. Specifies the format assumed for the movie to read, and can be either
  4204. the name of a container or an input device. If not specified the
  4205. format is guessed from @var{movie_name} or by probing.
  4206. @item seek_point, sp
  4207. Specifies the seek point in seconds, the frames will be output
  4208. starting from this seek point, the parameter is evaluated with
  4209. @code{av_strtod} so the numerical value may be suffixed by an IS
  4210. postfix. Default value is "0".
  4211. @item streams, s
  4212. Specifies the streams to read. Several streams can be specified,
  4213. separated by "+". The source will then have as many outputs, in the
  4214. same order. The syntax is explained in the ``Stream specifiers''
  4215. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4216. respectively the default (best suited) video and audio stream. Default
  4217. is "dv", or "da" if the filter is called as "amovie".
  4218. @item stream_index, si
  4219. Specifies the index of the video stream to read. If the value is -1,
  4220. the best suited video stream will be automatically selected. Default
  4221. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4222. audio instead of video.
  4223. @item loop
  4224. Specifies how many times to read the stream in sequence.
  4225. If the value is less than 1, the stream will be read again and again.
  4226. Default value is "1".
  4227. Note that when the movie is looped the source timestamps are not
  4228. changed, so it will generate non monotonically increasing timestamps.
  4229. @end table
  4230. This filter allows to overlay a second video on top of main input of
  4231. a filtergraph as shown in this graph:
  4232. @example
  4233. input -----------> deltapts0 --> overlay --> output
  4234. ^
  4235. |
  4236. movie --> scale--> deltapts1 -------+
  4237. @end example
  4238. Some examples follow.
  4239. @itemize
  4240. @item
  4241. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4242. on top of the input labelled as "in":
  4243. @example
  4244. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4245. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4246. @end example
  4247. @item
  4248. Read from a video4linux2 device, and overlay it on top of the input
  4249. labelled as "in":
  4250. @example
  4251. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4252. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4253. @end example
  4254. @item
  4255. Read the first video stream and the audio stream with id 0x81 from
  4256. dvd.vob; the video is connected to the pad named "video" and the audio is
  4257. connected to the pad named "audio":
  4258. @example
  4259. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4260. @end example
  4261. @end itemize
  4262. @c man end MULTIMEDIA SOURCES