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.

5434 lines
152KB

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