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.

3675 lines
103KB

  1. @chapter Filtergraph description
  2. @c man begin FILTERGRAPH DESCRIPTION
  3. A filtergraph is a directed graph of connected filters. It can contain
  4. cycles, and there can be multiple links between a pair of
  5. filters. Each link has one input pad on one side connecting it to one
  6. filter from which it takes its input, and one output pad on the other
  7. side connecting it to the one filter accepting its output.
  8. Each filter in a filtergraph is an instance of a filter class
  9. registered in the application, which defines the features and the
  10. number of input and output pads of the filter.
  11. A filter with no input pads is called a "source", a filter with no
  12. output pads is called a "sink".
  13. @anchor{Filtergraph syntax}
  14. @section Filtergraph syntax
  15. A filtergraph can be represented using a textual representation, which is
  16. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  17. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  18. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  19. @file{libavfilter/avfiltergraph.h}.
  20. A filterchain consists of a sequence of connected filters, each one
  21. connected to the previous one in the sequence. A filterchain is
  22. represented by a list of ","-separated filter descriptions.
  23. A filtergraph consists of a sequence of filterchains. A sequence of
  24. filterchains is represented by a list of ";"-separated filterchain
  25. descriptions.
  26. A filter is represented by a string of the form:
  27. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  28. @var{filter_name} is the name of the filter class of which the
  29. described filter is an instance of, and has to be the name of one of
  30. the filter classes registered in the program.
  31. The name of the filter class is optionally followed by a string
  32. "=@var{arguments}".
  33. @var{arguments} is a string which contains the parameters used to
  34. initialize the filter instance, and are described in the filter
  35. descriptions below.
  36. The list of arguments can be quoted using the character "'" as initial
  37. and ending mark, and the character '\' for escaping the characters
  38. within the quoted text; otherwise the argument string is considered
  39. terminated when the next special character (belonging to the set
  40. "[]=;,") is encountered.
  41. The name and arguments of the filter are optionally preceded and
  42. followed by a list of link labels.
  43. A link label allows to name a link and associate it to a filter output
  44. or input pad. The preceding labels @var{in_link_1}
  45. ... @var{in_link_N}, are associated to the filter input pads,
  46. the following labels @var{out_link_1} ... @var{out_link_M}, are
  47. associated to the output pads.
  48. When two link labels with the same name are found in the
  49. filtergraph, a link between the corresponding input and output pad is
  50. created.
  51. If an output pad is not labelled, it is linked by default to the first
  52. unlabelled input pad of the next filter in the filterchain.
  53. For example in the filterchain:
  54. @example
  55. nullsrc, split[L1], [L2]overlay, nullsink
  56. @end example
  57. the split filter instance has two output pads, and the overlay filter
  58. instance two input pads. The first output pad of split is labelled
  59. "L1", the first input pad of overlay is labelled "L2", and the second
  60. output pad of split is linked to the second input pad of overlay,
  61. which are both unlabelled.
  62. In a complete filterchain all the unlabelled filter input and output
  63. pads must be connected. A filtergraph is considered valid if all the
  64. filter input and output pads of all the filterchains are connected.
  65. Libavfilter will automatically insert scale filters where format
  66. conversion is required. It is possible to specify swscale flags
  67. for those automatically inserted scalers by prepending
  68. @code{sws_flags=@var{flags};}
  69. to the filtergraph description.
  70. Follows a BNF description for the filtergraph syntax:
  71. @example
  72. @var{NAME} ::= sequence of alphanumeric characters and '_'
  73. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  74. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  75. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  76. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  77. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  78. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  79. @end example
  80. @c man end FILTERGRAPH DESCRIPTION
  81. @chapter Audio Filters
  82. @c man begin AUDIO FILTERS
  83. When you configure your FFmpeg build, you can disable any of the
  84. existing filters using @code{--disable-filters}.
  85. The configure output will show the audio filters included in your
  86. build.
  87. Below is a description of the currently available audio filters.
  88. @section aconvert
  89. Convert the input audio format to the specified formats.
  90. The filter accepts a string of the form:
  91. "@var{sample_format}:@var{channel_layout}".
  92. @var{sample_format} specifies the sample format, and can be a string or the
  93. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  94. suffix for a planar sample format.
  95. @var{channel_layout} specifies the channel layout, and can be a string
  96. or the corresponding number value defined in @file{libavutil/audioconvert.h}.
  97. The special parameter "auto", signifies that the filter will
  98. automatically select the output format depending on the output filter.
  99. Some examples follow.
  100. @itemize
  101. @item
  102. Convert input to float, planar, stereo:
  103. @example
  104. aconvert=fltp:stereo
  105. @end example
  106. @item
  107. Convert input to unsigned 8-bit, automatically select out channel layout:
  108. @example
  109. aconvert=u8:auto
  110. @end example
  111. @end itemize
  112. @section aformat
  113. Convert the input audio to one of the specified formats. The framework will
  114. negotiate the most appropriate format to minimize conversions.
  115. The filter accepts three lists of formats, separated by ":", in the form:
  116. "@var{sample_formats}:@var{channel_layouts}".
  117. Elements in each list are separated by "," which has to be escaped in the
  118. filtergraph specification.
  119. The special parameter "all", in place of a list of elements, signifies all
  120. supported formats.
  121. Some examples follow:
  122. @example
  123. aformat=u8\\,s16:mono
  124. aformat=s16:mono\\,stereo
  125. @end example
  126. @section amerge
  127. Merge two audio streams into a single multi-channel stream.
  128. This filter does not need any argument.
  129. If the channel layouts of the inputs are disjoint, and therefore compatible,
  130. the channel layout of the output will be set accordingly and the channels
  131. will be reordered as necessary. If the channel layouts of the inputs are not
  132. disjoint, the output will have all the channels of the first input then all
  133. the channels of the second input, in that order, and the channel layout of
  134. the output will be the default value corresponding to the total number of
  135. channels.
  136. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  137. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  138. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  139. first input, b1 is the first channel of the second input).
  140. On the other hand, if both input are in stereo, the output channels will be
  141. in the default order: a1, a2, b1, b2, and the channel layout will be
  142. arbitrarily set to 4.0, which may or may not be the expected value.
  143. Both inputs must have the same sample rate, and format.
  144. If inputs do not have the same duration, the output will stop with the
  145. shortest.
  146. Example: merge two mono files into a stereo stream:
  147. @example
  148. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  149. @end example
  150. If you need to do multiple merges (for instance multiple mono audio streams in
  151. a single video media), you can do:
  152. @example
  153. ffmpeg -f lavfi -i "
  154. amovie=input.mkv:si=0 [a0];
  155. amovie=input.mkv:si=1 [a1];
  156. amovie=input.mkv:si=2 [a2];
  157. amovie=input.mkv:si=3 [a3];
  158. amovie=input.mkv:si=4 [a4];
  159. amovie=input.mkv:si=5 [a5];
  160. [a0][a1] amerge [x0];
  161. [x0][a2] amerge [x1];
  162. [x1][a3] amerge [x2];
  163. [x2][a4] amerge [x3];
  164. [x3][a5] amerge" -c:a pcm_s16le output.mkv
  165. @end example
  166. @section aformat
  167. Convert the input audio to one of the specified formats. The framework will
  168. negotiate the most appropriate format to minimize conversions.
  169. The filter accepts the following named parameters:
  170. @table @option
  171. @item sample_fmts
  172. A comma-separated list of requested sample formats.
  173. @item sample_rates
  174. A comma-separated list of requested sample rates.
  175. @item channel_layouts
  176. A comma-separated list of requested channel layouts.
  177. @end table
  178. If a parameter is omitted, all values are allowed.
  179. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  180. @example
  181. aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
  182. @end example
  183. @section anull
  184. Pass the audio source unchanged to the output.
  185. @section aresample
  186. Resample the input audio to the specified sample rate.
  187. The filter accepts exactly one parameter, the output sample rate. If not
  188. specified then the filter will automatically convert between its input
  189. and output sample rates.
  190. For example, to resample the input audio to 44100Hz:
  191. @example
  192. aresample=44100
  193. @end example
  194. @section ashowinfo
  195. Show a line containing various information for each input audio frame.
  196. The input audio is not modified.
  197. The shown line contains a sequence of key/value pairs of the form
  198. @var{key}:@var{value}.
  199. A description of each shown parameter follows:
  200. @table @option
  201. @item n
  202. sequential number of the input frame, starting from 0
  203. @item pts
  204. presentation TimeStamp of the input frame, expressed as a number of
  205. time base units. The time base unit depends on the filter input pad, and
  206. is usually 1/@var{sample_rate}.
  207. @item pts_time
  208. presentation TimeStamp of the input frame, expressed as a number of
  209. seconds
  210. @item pos
  211. position of the frame in the input stream, -1 if this information in
  212. unavailable and/or meaningless (for example in case of synthetic audio)
  213. @item fmt
  214. sample format name
  215. @item chlayout
  216. channel layout description
  217. @item nb_samples
  218. number of samples (per each channel) contained in the filtered frame
  219. @item rate
  220. sample rate for the audio frame
  221. @item checksum
  222. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  223. @item plane_checksum
  224. Adler-32 checksum (printed in hexadecimal) for each input frame plane,
  225. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5}
  226. @var{c6} @var{c7}]"
  227. @end table
  228. @section asplit
  229. Pass on the input audio to two outputs. Both outputs are identical to
  230. the input audio.
  231. For example:
  232. @example
  233. [in] asplit[out0], showaudio[out1]
  234. @end example
  235. will create two separate outputs from the same input, one cropped and
  236. one padded.
  237. @section astreamsync
  238. Forward two audio streams and control the order the buffers are forwarded.
  239. The argument to the filter is an expression deciding which stream should be
  240. forwarded next: if the result is negative, the first stream is forwarded; if
  241. the result is positive or zero, the second stream is forwarded. It can use
  242. the following variables:
  243. @table @var
  244. @item b1 b2
  245. number of buffers forwarded so far on each stream
  246. @item s1 s2
  247. number of samples forwarded so far on each stream
  248. @item t1 t2
  249. current timestamp of each stream
  250. @end table
  251. The default value is @code{t1-t2}, which means to always forward the stream
  252. that has a smaller timestamp.
  253. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  254. input, while avoiding too much of a desynchronization:
  255. @example
  256. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  257. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  258. [a2] [b2] amerge
  259. @end example
  260. @section earwax
  261. Make audio easier to listen to on headphones.
  262. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  263. so that when listened to on headphones the stereo image is moved from
  264. inside your head (standard for headphones) to outside and in front of
  265. the listener (standard for speakers).
  266. Ported from SoX.
  267. @section pan
  268. Mix channels with specific gain levels. The filter accepts the output
  269. channel layout followed by a set of channels definitions.
  270. This filter is also designed to remap efficiently the channels of an audio
  271. stream.
  272. The filter accepts parameters of the form:
  273. "@var{l}:@var{outdef}:@var{outdef}:..."
  274. @table @option
  275. @item l
  276. output channel layout or number of channels
  277. @item outdef
  278. output channel specification, of the form:
  279. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  280. @item out_name
  281. output channel to define, either a channel name (FL, FR, etc.) or a channel
  282. number (c0, c1, etc.)
  283. @item gain
  284. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  285. @item in_name
  286. input channel to use, see out_name for details; it is not possible to mix
  287. named and numbered input channels
  288. @end table
  289. If the `=' in a channel specification is replaced by `<', then the gains for
  290. that specification will be renormalized so that the total is 1, thus
  291. avoiding clipping noise.
  292. @subsection Mixing examples
  293. For example, if you want to down-mix from stereo to mono, but with a bigger
  294. factor for the left channel:
  295. @example
  296. pan=1:c0=0.9*c0+0.1*c1
  297. @end example
  298. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  299. 7-channels surround:
  300. @example
  301. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  302. @end example
  303. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  304. that should be preferred (see "-ac" option) unless you have very specific
  305. needs.
  306. @subsection Remapping examples
  307. The channel remapping will be effective if, and only if:
  308. @itemize
  309. @item gain coefficients are zeroes or ones,
  310. @item only one input per channel output,
  311. @end itemize
  312. If all these conditions are satisfied, the filter will notify the user ("Pure
  313. channel mapping detected"), and use an optimized and lossless method to do the
  314. remapping.
  315. For example, if you have a 5.1 source and want a stereo audio stream by
  316. dropping the extra channels:
  317. @example
  318. pan="stereo: c0=FL : c1=FR"
  319. @end example
  320. Given the same source, you can also switch front left and front right channels
  321. and keep the input channel layout:
  322. @example
  323. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  324. @end example
  325. If the input is a stereo audio stream, you can mute the front left channel (and
  326. still keep the stereo channel layout) with:
  327. @example
  328. pan="stereo:c1=c1"
  329. @end example
  330. Still with a stereo audio stream input, you can copy the right channel in both
  331. front left and right:
  332. @example
  333. pan="stereo: c0=FR : c1=FR"
  334. @end example
  335. @section silencedetect
  336. Detect silence in an audio stream.
  337. This filter logs a message when it detects that the input audio volume is less
  338. or equal to a noise tolerance value for a duration greater or equal to the
  339. minimum detected noise duration.
  340. The printed times and duration are expressed in seconds.
  341. @table @option
  342. @item duration, d
  343. Set silence duration until notification (default is 2 seconds).
  344. @item noise, n
  345. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  346. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  347. @end table
  348. Detect 5 seconds of silence with -50dB noise tolerance:
  349. @example
  350. silencedetect=n=-50dB:d=5
  351. @end example
  352. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  353. tolerance in @file{silence.mp3}:
  354. @example
  355. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  356. @end example
  357. @section volume
  358. Adjust the input audio volume.
  359. The filter accepts exactly one parameter @var{vol}, which expresses
  360. how the audio volume will be increased or decreased.
  361. Output values are clipped to the maximum value.
  362. If @var{vol} is expressed as a decimal number, the output audio
  363. volume is given by the relation:
  364. @example
  365. @var{output_volume} = @var{vol} * @var{input_volume}
  366. @end example
  367. If @var{vol} is expressed as a decimal number followed by the string
  368. "dB", the value represents the requested change in decibels of the
  369. input audio power, and the output audio volume is given by the
  370. relation:
  371. @example
  372. @var{output_volume} = 10^(@var{vol}/20) * @var{input_volume}
  373. @end example
  374. Otherwise @var{vol} is considered an expression and its evaluated
  375. value is used for computing the output audio volume according to the
  376. first relation.
  377. Default value for @var{vol} is 1.0.
  378. @subsection Examples
  379. @itemize
  380. @item
  381. Half the input audio volume:
  382. @example
  383. volume=0.5
  384. @end example
  385. The above example is equivalent to:
  386. @example
  387. volume=1/2
  388. @end example
  389. @item
  390. Decrease input audio power by 12 decibels:
  391. @example
  392. volume=-12dB
  393. @end example
  394. @end itemize
  395. @section asyncts
  396. Synchronize audio data with timestamps by squeezing/stretching it and/or
  397. dropping samples/adding silence when needed.
  398. The filter accepts the following named parameters:
  399. @table @option
  400. @item compensate
  401. Enable stretching/squeezing the data to make it match the timestamps.
  402. @item min_delta
  403. Minimum difference between timestamps and audio data (in seconds) to trigger
  404. adding/dropping samples.
  405. @item max_comp
  406. Maximum compensation in samples per second.
  407. @end table
  408. @section resample
  409. Convert the audio sample format, sample rate and channel layout. This filter is
  410. not meant to be used directly.
  411. @c man end AUDIO FILTERS
  412. @chapter Audio Sources
  413. @c man begin AUDIO SOURCES
  414. Below is a description of the currently available audio sources.
  415. @section abuffer
  416. Buffer audio frames, and make them available to the filter chain.
  417. This source is mainly intended for a programmatic use, in particular
  418. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  419. It accepts the following mandatory parameters:
  420. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  421. @table @option
  422. @item sample_rate
  423. The sample rate of the incoming audio buffers.
  424. @item sample_fmt
  425. The sample format of the incoming audio buffers.
  426. Either a sample format name or its corresponging integer representation from
  427. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  428. @item channel_layout
  429. The channel layout of the incoming audio buffers.
  430. Either a channel layout name from channel_layout_map in
  431. @file{libavutil/audioconvert.c} or its corresponding integer representation
  432. from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h}
  433. @end table
  434. For example:
  435. @example
  436. abuffer=44100:s16p:stereo
  437. @end example
  438. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  439. Since the sample format with name "s16p" corresponds to the number
  440. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  441. equivalent to:
  442. @example
  443. abuffer=44100:6:0x3
  444. @end example
  445. @section aevalsrc
  446. Generate an audio signal specified by an expression.
  447. This source accepts in input one or more expressions (one for each
  448. channel), which are evaluated and used to generate a corresponding
  449. audio signal.
  450. It accepts the syntax: @var{exprs}[::@var{options}].
  451. @var{exprs} is a list of expressions separated by ":", one for each
  452. separate channel. In case the @var{channel_layout} is not
  453. specified, the selected channel layout depends on the number of
  454. provided expressions.
  455. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  456. separated by ":".
  457. The description of the accepted options follows.
  458. @table @option
  459. @item channel_layout, c
  460. Set the channel layout. The number of channels in the specified layout
  461. must be equal to the number of specified expressions.
  462. @item duration, d
  463. Set the minimum duration of the sourced audio. See the function
  464. @code{av_parse_time()} for the accepted format.
  465. Note that the resulting duration may be greater than the specified
  466. duration, as the generated audio is always cut at the end of a
  467. complete frame.
  468. If not specified, or the expressed duration is negative, the audio is
  469. supposed to be generated forever.
  470. @item nb_samples, n
  471. Set the number of samples per channel per each output frame,
  472. default to 1024.
  473. @item sample_rate, s
  474. Specify the sample rate, default to 44100.
  475. @end table
  476. Each expression in @var{exprs} can contain the following constants:
  477. @table @option
  478. @item n
  479. number of the evaluated sample, starting from 0
  480. @item t
  481. time of the evaluated sample expressed in seconds, starting from 0
  482. @item s
  483. sample rate
  484. @end table
  485. @subsection Examples
  486. @itemize
  487. @item
  488. Generate silence:
  489. @example
  490. aevalsrc=0
  491. @end example
  492. @item
  493. Generate a sin signal with frequency of 440 Hz, set sample rate to
  494. 8000 Hz:
  495. @example
  496. aevalsrc="sin(440*2*PI*t)::s=8000"
  497. @end example
  498. @item
  499. Generate a two channels signal, specify the channel layout (Front
  500. Center + Back Center) explicitly:
  501. @example
  502. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  503. @end example
  504. @item
  505. Generate white noise:
  506. @example
  507. aevalsrc="-2+random(0)"
  508. @end example
  509. @item
  510. Generate an amplitude modulated signal:
  511. @example
  512. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  513. @end example
  514. @item
  515. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  516. @example
  517. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  518. @end example
  519. @end itemize
  520. @section amovie
  521. Read an audio stream from a movie container.
  522. It accepts the syntax: @var{movie_name}[:@var{options}] where
  523. @var{movie_name} is the name of the resource to read (not necessarily
  524. a file but also a device or a stream accessed through some protocol),
  525. and @var{options} is an optional sequence of @var{key}=@var{value}
  526. pairs, separated by ":".
  527. The description of the accepted options follows.
  528. @table @option
  529. @item format_name, f
  530. Specify the format assumed for the movie to read, and can be either
  531. the name of a container or an input device. If not specified the
  532. format is guessed from @var{movie_name} or by probing.
  533. @item seek_point, sp
  534. Specify the seek point in seconds, the frames will be output
  535. starting from this seek point, the parameter is evaluated with
  536. @code{av_strtod} so the numerical value may be suffixed by an IS
  537. postfix. Default value is "0".
  538. @item stream_index, si
  539. Specify the index of the audio stream to read. If the value is -1,
  540. the best suited audio stream will be automatically selected. Default
  541. value is "-1".
  542. @end table
  543. @section anullsrc
  544. Null audio source, return unprocessed audio frames. It is mainly useful
  545. as a template and to be employed in analysis / debugging tools, or as
  546. the source for filters which ignore the input data (for example the sox
  547. synth filter).
  548. It accepts an optional sequence of @var{key}=@var{value} pairs,
  549. separated by ":".
  550. The description of the accepted options follows.
  551. @table @option
  552. @item sample_rate, s
  553. Specify the sample rate, and defaults to 44100.
  554. @item channel_layout, cl
  555. Specify the channel layout, and can be either an integer or a string
  556. representing a channel layout. The default value of @var{channel_layout}
  557. is "stereo".
  558. Check the channel_layout_map definition in
  559. @file{libavcodec/audioconvert.c} for the mapping between strings and
  560. channel layout values.
  561. @item nb_samples, n
  562. Set the number of samples per requested frames.
  563. @end table
  564. Follow some examples:
  565. @example
  566. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  567. anullsrc=r=48000:cl=4
  568. # same as
  569. anullsrc=r=48000:cl=mono
  570. @end example
  571. @section abuffer
  572. Buffer audio frames, and make them available to the filter chain.
  573. This source is not intended to be part of user-supplied graph descriptions but
  574. for insertion by calling programs through the interface defined in
  575. @file{libavfilter/buffersrc.h}.
  576. It accepts the following named parameters:
  577. @table @option
  578. @item time_base
  579. Timebase which will be used for timestamps of submitted frames. It must be
  580. either a floating-point number or in @var{numerator}/@var{denominator} form.
  581. @item sample_rate
  582. Audio sample rate.
  583. @item sample_fmt
  584. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  585. @item channel_layout
  586. Channel layout of the audio data, in the form that can be accepted by
  587. @code{av_get_channel_layout()}.
  588. @end table
  589. All the parameters need to be explicitly defined.
  590. @c man end AUDIO SOURCES
  591. @chapter Audio Sinks
  592. @c man begin AUDIO SINKS
  593. Below is a description of the currently available audio sinks.
  594. @section abuffersink
  595. Buffer audio frames, and make them available to the end of filter chain.
  596. This sink is mainly intended for programmatic use, in particular
  597. through the interface defined in @file{libavfilter/buffersink.h}.
  598. It requires a pointer to an AVABufferSinkContext structure, which
  599. defines the incoming buffers' formats, to be passed as the opaque
  600. parameter to @code{avfilter_init_filter} for initialization.
  601. @section anullsink
  602. Null audio sink, do absolutely nothing with the input audio. It is
  603. mainly useful as a template and to be employed in analysis / debugging
  604. tools.
  605. @section abuffersink
  606. This sink is intended for programmatic use. Frames that arrive on this sink can
  607. be retrieved by the calling program using the interface defined in
  608. @file{libavfilter/buffersink.h}.
  609. This filter accepts no parameters.
  610. @c man end AUDIO SINKS
  611. @chapter Video Filters
  612. @c man begin VIDEO FILTERS
  613. When you configure your FFmpeg build, you can disable any of the
  614. existing filters using @code{--disable-filters}.
  615. The configure output will show the video filters included in your
  616. build.
  617. Below is a description of the currently available video filters.
  618. @section ass
  619. Draw ASS (Advanced Substation Alpha) subtitles on top of input video
  620. using the libass library.
  621. To enable compilation of this filter you need to configure FFmpeg with
  622. @code{--enable-libass}.
  623. This filter accepts the syntax: @var{ass_filename}[:@var{options}],
  624. where @var{ass_filename} is the filename of the ASS file to read, and
  625. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  626. separated by ":".
  627. A description of the accepted options follows.
  628. @table @option
  629. @item original_size
  630. Specifies the size of the original video, the video for which the ASS file
  631. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  632. necessary to correctly scale the fonts if the aspect ratio has been changed.
  633. @end table
  634. For example, to render the file @file{sub.ass} on top of the input
  635. video, use the command:
  636. @example
  637. ass=sub.ass
  638. @end example
  639. @section bbox
  640. Compute the bounding box for the non-black pixels in the input frame
  641. luminance plane.
  642. This filter computes the bounding box containing all the pixels with a
  643. luminance value greater than the minimum allowed value.
  644. The parameters describing the bounding box are printed on the filter
  645. log.
  646. @section blackdetect
  647. Detect video intervals that are (almost) completely black. Can be
  648. useful to detect chapter transitions, commercials, or invalid
  649. recordings. Output lines contains the time for the start, end and
  650. duration of the detected black interval expressed in seconds.
  651. In order to display the output lines, you need to set the loglevel at
  652. least to the AV_LOG_INFO value.
  653. This filter accepts a list of options in the form of
  654. @var{key}=@var{value} pairs separated by ":". A description of the
  655. accepted options follows.
  656. @table @option
  657. @item black_min_duration, d
  658. Set the minimum detected black duration expressed in seconds. It must
  659. be a non-negative floating point number.
  660. Default value is 2.0.
  661. @item picture_black_ratio_th, pic_th
  662. Set the threshold for considering a picture "black".
  663. Express the minimum value for the ratio:
  664. @example
  665. @var{nb_black_pixels} / @var{nb_pixels}
  666. @end example
  667. for which a picture is considered black.
  668. Default value is 0.98.
  669. @item pixel_black_th, pix_th
  670. Set the threshold for considering a pixel "black".
  671. The threshold expresses the maximum pixel luminance value for which a
  672. pixel is considered "black". The provided value is scaled according to
  673. the following equation:
  674. @example
  675. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  676. @end example
  677. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  678. the input video format, the range is [0-255] for YUV full-range
  679. formats and [16-235] for YUV non full-range formats.
  680. Default value is 0.10.
  681. @end table
  682. The following example sets the maximum pixel threshold to the minimum
  683. value, and detects only black intervals of 2 or more seconds:
  684. @example
  685. blackdetect=d=2:pix_th=0.00
  686. @end example
  687. @section blackframe
  688. Detect frames that are (almost) completely black. Can be useful to
  689. detect chapter transitions or commercials. Output lines consist of
  690. the frame number of the detected frame, the percentage of blackness,
  691. the position in the file if known or -1 and the timestamp in seconds.
  692. In order to display the output lines, you need to set the loglevel at
  693. least to the AV_LOG_INFO value.
  694. The filter accepts the syntax:
  695. @example
  696. blackframe[=@var{amount}:[@var{threshold}]]
  697. @end example
  698. @var{amount} is the percentage of the pixels that have to be below the
  699. threshold, and defaults to 98.
  700. @var{threshold} is the threshold below which a pixel value is
  701. considered black, and defaults to 32.
  702. @section boxblur
  703. Apply boxblur algorithm to the input video.
  704. This filter accepts the parameters:
  705. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  706. Chroma and alpha parameters are optional, if not specified they default
  707. to the corresponding values set for @var{luma_radius} and
  708. @var{luma_power}.
  709. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  710. the radius in pixels of the box used for blurring the corresponding
  711. input plane. They are expressions, and can contain the following
  712. constants:
  713. @table @option
  714. @item w, h
  715. the input width and height in pixels
  716. @item cw, ch
  717. the input chroma image width and height in pixels
  718. @item hsub, vsub
  719. horizontal and vertical chroma subsample values. For example for the
  720. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  721. @end table
  722. The radius must be a non-negative number, and must not be greater than
  723. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  724. and of @code{min(cw,ch)/2} for the chroma planes.
  725. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  726. how many times the boxblur filter is applied to the corresponding
  727. plane.
  728. Some examples follow:
  729. @itemize
  730. @item
  731. Apply a boxblur filter with luma, chroma, and alpha radius
  732. set to 2:
  733. @example
  734. boxblur=2:1
  735. @end example
  736. @item
  737. Set luma radius to 2, alpha and chroma radius to 0
  738. @example
  739. boxblur=2:1:0:0:0:0
  740. @end example
  741. @item
  742. Set luma and chroma radius to a fraction of the video dimension
  743. @example
  744. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  745. @end example
  746. @end itemize
  747. @section colormatrix
  748. The colormatrix filter allows conversion between any of the following color
  749. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  750. and FCC (@var{fcc}).
  751. The syntax of the parameters is @var{source}:@var{destination}:
  752. @example
  753. colormatrix=bt601:smpte240m
  754. @end example
  755. @section copy
  756. Copy the input source unchanged to the output. Mainly useful for
  757. testing purposes.
  758. @section crop
  759. Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}
  760. The @var{keep_aspect} parameter is optional, if specified and set to a
  761. non-zero value will force the output display aspect ratio to be the
  762. same of the input, by changing the output sample aspect ratio.
  763. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  764. expressions containing the following constants:
  765. @table @option
  766. @item x, y
  767. the computed values for @var{x} and @var{y}. They are evaluated for
  768. each new frame.
  769. @item in_w, in_h
  770. the input width and height
  771. @item iw, ih
  772. same as @var{in_w} and @var{in_h}
  773. @item out_w, out_h
  774. the output (cropped) width and height
  775. @item ow, oh
  776. same as @var{out_w} and @var{out_h}
  777. @item a
  778. same as @var{iw} / @var{ih}
  779. @item sar
  780. input sample aspect ratio
  781. @item dar
  782. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  783. @item hsub, vsub
  784. horizontal and vertical chroma subsample values. For example for the
  785. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  786. @item n
  787. the number of input frame, starting from 0
  788. @item pos
  789. the position in the file of the input frame, NAN if unknown
  790. @item t
  791. timestamp expressed in seconds, NAN if the input timestamp is unknown
  792. @end table
  793. The @var{out_w} and @var{out_h} parameters specify the expressions for
  794. the width and height of the output (cropped) video. They are
  795. evaluated just at the configuration of the filter.
  796. The default value of @var{out_w} is "in_w", and the default value of
  797. @var{out_h} is "in_h".
  798. The expression for @var{out_w} may depend on the value of @var{out_h},
  799. and the expression for @var{out_h} may depend on @var{out_w}, but they
  800. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  801. evaluated after @var{out_w} and @var{out_h}.
  802. The @var{x} and @var{y} parameters specify the expressions for the
  803. position of the top-left corner of the output (non-cropped) area. They
  804. are evaluated for each frame. If the evaluated value is not valid, it
  805. is approximated to the nearest valid value.
  806. The default value of @var{x} is "(in_w-out_w)/2", and the default
  807. value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
  808. the center of the input image.
  809. The expression for @var{x} may depend on @var{y}, and the expression
  810. for @var{y} may depend on @var{x}.
  811. Follow some examples:
  812. @example
  813. # crop the central input area with size 100x100
  814. crop=100:100
  815. # crop the central input area with size 2/3 of the input video
  816. "crop=2/3*in_w:2/3*in_h"
  817. # crop the input video central square
  818. crop=in_h
  819. # delimit the rectangle with the top-left corner placed at position
  820. # 100:100 and the right-bottom corner corresponding to the right-bottom
  821. # corner of the input image.
  822. crop=in_w-100:in_h-100:100:100
  823. # crop 10 pixels from the left and right borders, and 20 pixels from
  824. # the top and bottom borders
  825. "crop=in_w-2*10:in_h-2*20"
  826. # keep only the bottom right quarter of the input image
  827. "crop=in_w/2:in_h/2:in_w/2:in_h/2"
  828. # crop height for getting Greek harmony
  829. "crop=in_w:1/PHI*in_w"
  830. # trembling effect
  831. "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)"
  832. # erratic camera effect depending on timestamp
  833. "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)"
  834. # set x depending on the value of y
  835. "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
  836. @end example
  837. @section cropdetect
  838. Auto-detect crop size.
  839. Calculate necessary cropping parameters and prints the recommended
  840. parameters through the logging system. The detected dimensions
  841. correspond to the non-black area of the input video.
  842. It accepts the syntax:
  843. @example
  844. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  845. @end example
  846. @table @option
  847. @item limit
  848. Threshold, which can be optionally specified from nothing (0) to
  849. everything (255), defaults to 24.
  850. @item round
  851. Value which the width/height should be divisible by, defaults to
  852. 16. The offset is automatically adjusted to center the video. Use 2 to
  853. get only even dimensions (needed for 4:2:2 video). 16 is best when
  854. encoding to most video codecs.
  855. @item reset
  856. Counter that determines after how many frames cropdetect will reset
  857. the previously detected largest video area and start over to detect
  858. the current optimal crop area. Defaults to 0.
  859. This can be useful when channel logos distort the video area. 0
  860. indicates never reset and return the largest area encountered during
  861. playback.
  862. @end table
  863. @section delogo
  864. Suppress a TV station logo by a simple interpolation of the surrounding
  865. pixels. Just set a rectangle covering the logo and watch it disappear
  866. (and sometimes something even uglier appear - your mileage may vary).
  867. The filter accepts parameters as a string of the form
  868. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  869. @var{key}=@var{value} pairs, separated by ":".
  870. The description of the accepted parameters follows.
  871. @table @option
  872. @item x, y
  873. Specify the top left corner coordinates of the logo. They must be
  874. specified.
  875. @item w, h
  876. Specify the width and height of the logo to clear. They must be
  877. specified.
  878. @item band, t
  879. Specify the thickness of the fuzzy edge of the rectangle (added to
  880. @var{w} and @var{h}). The default value is 4.
  881. @item show
  882. When set to 1, a green rectangle is drawn on the screen to simplify
  883. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  884. @var{band} is set to 4. The default value is 0.
  885. @end table
  886. Some examples follow.
  887. @itemize
  888. @item
  889. Set a rectangle covering the area with top left corner coordinates 0,0
  890. and size 100x77, setting a band of size 10:
  891. @example
  892. delogo=0:0:100:77:10
  893. @end example
  894. @item
  895. As the previous example, but use named options:
  896. @example
  897. delogo=x=0:y=0:w=100:h=77:band=10
  898. @end example
  899. @end itemize
  900. @section deshake
  901. Attempt to fix small changes in horizontal and/or vertical shift. This
  902. filter helps remove camera shake from hand-holding a camera, bumping a
  903. tripod, moving on a vehicle, etc.
  904. The filter accepts parameters as a string of the form
  905. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  906. A description of the accepted parameters follows.
  907. @table @option
  908. @item x, y, w, h
  909. Specify a rectangular area where to limit the search for motion
  910. vectors.
  911. If desired the search for motion vectors can be limited to a
  912. rectangular area of the frame defined by its top left corner, width
  913. and height. These parameters have the same meaning as the drawbox
  914. filter which can be used to visualise the position of the bounding
  915. box.
  916. This is useful when simultaneous movement of subjects within the frame
  917. might be confused for camera motion by the motion vector search.
  918. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  919. then the full frame is used. This allows later options to be set
  920. without specifying the bounding box for the motion vector search.
  921. Default - search the whole frame.
  922. @item rx, ry
  923. Specify the maximum extent of movement in x and y directions in the
  924. range 0-64 pixels. Default 16.
  925. @item edge
  926. Specify how to generate pixels to fill blanks at the edge of the
  927. frame. An integer from 0 to 3 as follows:
  928. @table @option
  929. @item 0
  930. Fill zeroes at blank locations
  931. @item 1
  932. Original image at blank locations
  933. @item 2
  934. Extruded edge value at blank locations
  935. @item 3
  936. Mirrored edge at blank locations
  937. @end table
  938. The default setting is mirror edge at blank locations.
  939. @item blocksize
  940. Specify the blocksize to use for motion search. Range 4-128 pixels,
  941. default 8.
  942. @item contrast
  943. Specify the contrast threshold for blocks. Only blocks with more than
  944. the specified contrast (difference between darkest and lightest
  945. pixels) will be considered. Range 1-255, default 125.
  946. @item search
  947. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  948. search. Default - exhaustive search.
  949. @item filename
  950. If set then a detailed log of the motion search is written to the
  951. specified file.
  952. @end table
  953. @section drawbox
  954. Draw a colored box on the input image.
  955. It accepts the syntax:
  956. @example
  957. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}
  958. @end example
  959. @table @option
  960. @item x, y
  961. Specify the top left corner coordinates of the box. Default to 0.
  962. @item width, height
  963. Specify the width and height of the box, if 0 they are interpreted as
  964. the input width and height. Default to 0.
  965. @item color
  966. Specify the color of the box to write, it can be the name of a color
  967. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  968. @end table
  969. Follow some examples:
  970. @example
  971. # draw a black box around the edge of the input image
  972. drawbox
  973. # draw a box with color red and an opacity of 50%
  974. drawbox=10:20:200:60:red@@0.5"
  975. @end example
  976. @section drawtext
  977. Draw text string or text from specified file on top of video using the
  978. libfreetype library.
  979. To enable compilation of this filter you need to configure FFmpeg with
  980. @code{--enable-libfreetype}.
  981. The filter also recognizes strftime() sequences in the provided text
  982. and expands them accordingly. Check the documentation of strftime().
  983. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  984. separated by ":".
  985. The description of the accepted parameters follows.
  986. @table @option
  987. @item box
  988. Used to draw a box around text using background color.
  989. Value should be either 1 (enable) or 0 (disable).
  990. The default value of @var{box} is 0.
  991. @item boxcolor
  992. The color to be used for drawing box around text.
  993. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  994. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  995. The default value of @var{boxcolor} is "white".
  996. @item draw
  997. Set an expression which specifies if the text should be drawn. If the
  998. expression evaluates to 0, the text is not drawn. This is useful for
  999. specifying that the text should be drawn only when specific conditions
  1000. are met.
  1001. Default value is "1".
  1002. See below for the list of accepted constants and functions.
  1003. @item fix_bounds
  1004. If true, check and fix text coords to avoid clipping.
  1005. @item fontcolor
  1006. The color to be used for drawing fonts.
  1007. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1008. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1009. The default value of @var{fontcolor} is "black".
  1010. @item fontfile
  1011. The font file to be used for drawing text. Path must be included.
  1012. This parameter is mandatory.
  1013. @item fontsize
  1014. The font size to be used for drawing text.
  1015. The default value of @var{fontsize} is 16.
  1016. @item ft_load_flags
  1017. Flags to be used for loading the fonts.
  1018. The flags map the corresponding flags supported by libfreetype, and are
  1019. a combination of the following values:
  1020. @table @var
  1021. @item default
  1022. @item no_scale
  1023. @item no_hinting
  1024. @item render
  1025. @item no_bitmap
  1026. @item vertical_layout
  1027. @item force_autohint
  1028. @item crop_bitmap
  1029. @item pedantic
  1030. @item ignore_global_advance_width
  1031. @item no_recurse
  1032. @item ignore_transform
  1033. @item monochrome
  1034. @item linear_design
  1035. @item no_autohint
  1036. @item end table
  1037. @end table
  1038. Default value is "render".
  1039. For more information consult the documentation for the FT_LOAD_*
  1040. libfreetype flags.
  1041. @item shadowcolor
  1042. The color to be used for drawing a shadow behind the drawn text. It
  1043. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1044. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1045. The default value of @var{shadowcolor} is "black".
  1046. @item shadowx, shadowy
  1047. The x and y offsets for the text shadow position with respect to the
  1048. position of the text. They can be either positive or negative
  1049. values. Default value for both is "0".
  1050. @item tabsize
  1051. The size in number of spaces to use for rendering the tab.
  1052. Default value is 4.
  1053. @item timecode
  1054. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1055. format. It can be used with or without text parameter. @var{timecode_rate}
  1056. option must be specified.
  1057. @item timecode_rate, rate, r
  1058. Set the timecode frame rate (timecode only).
  1059. @item text
  1060. The text string to be drawn. The text must be a sequence of UTF-8
  1061. encoded characters.
  1062. This parameter is mandatory if no file is specified with the parameter
  1063. @var{textfile}.
  1064. @item textfile
  1065. A text file containing text to be drawn. The text must be a sequence
  1066. of UTF-8 encoded characters.
  1067. This parameter is mandatory if no text string is specified with the
  1068. parameter @var{text}.
  1069. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1070. @item x, y
  1071. The expressions which specify the offsets where text will be drawn
  1072. within the video frame. They are relative to the top/left border of the
  1073. output image.
  1074. The default value of @var{x} and @var{y} is "0".
  1075. See below for the list of accepted constants and functions.
  1076. @end table
  1077. The parameters for @var{x} and @var{y} are expressions containing the
  1078. following constants and functions:
  1079. @table @option
  1080. @item dar
  1081. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1082. @item hsub, vsub
  1083. horizontal and vertical chroma subsample values. For example for the
  1084. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1085. @item line_h, lh
  1086. the height of each text line
  1087. @item main_h, h, H
  1088. the input height
  1089. @item main_w, w, W
  1090. the input width
  1091. @item max_glyph_a, ascent
  1092. the maximum distance from the baseline to the highest/upper grid
  1093. coordinate used to place a glyph outline point, for all the rendered
  1094. glyphs.
  1095. It is a positive value, due to the grid's orientation with the Y axis
  1096. upwards.
  1097. @item max_glyph_d, descent
  1098. the maximum distance from the baseline to the lowest grid coordinate
  1099. used to place a glyph outline point, for all the rendered glyphs.
  1100. This is a negative value, due to the grid's orientation, with the Y axis
  1101. upwards.
  1102. @item max_glyph_h
  1103. maximum glyph height, that is the maximum height for all the glyphs
  1104. contained in the rendered text, it is equivalent to @var{ascent} -
  1105. @var{descent}.
  1106. @item max_glyph_w
  1107. maximum glyph width, that is the maximum width for all the glyphs
  1108. contained in the rendered text
  1109. @item n
  1110. the number of input frame, starting from 0
  1111. @item rand(min, max)
  1112. return a random number included between @var{min} and @var{max}
  1113. @item sar
  1114. input sample aspect ratio
  1115. @item t
  1116. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1117. @item text_h, th
  1118. the height of the rendered text
  1119. @item text_w, tw
  1120. the width of the rendered text
  1121. @item x, y
  1122. the x and y offset coordinates where the text is drawn.
  1123. These parameters allow the @var{x} and @var{y} expressions to refer
  1124. each other, so you can for example specify @code{y=x/dar}.
  1125. @end table
  1126. If libavfilter was built with @code{--enable-fontconfig}, then
  1127. @option{fontfile} can be a fontconfig pattern or omitted.
  1128. Some examples follow.
  1129. @itemize
  1130. @item
  1131. Draw "Test Text" with font FreeSerif, using the default values for the
  1132. optional parameters.
  1133. @example
  1134. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1135. @end example
  1136. @item
  1137. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1138. and y=50 (counting from the top-left corner of the screen), text is
  1139. yellow with a red box around it. Both the text and the box have an
  1140. opacity of 20%.
  1141. @example
  1142. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1143. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1144. @end example
  1145. Note that the double quotes are not necessary if spaces are not used
  1146. within the parameter list.
  1147. @item
  1148. Show the text at the center of the video frame:
  1149. @example
  1150. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1151. @end example
  1152. @item
  1153. Show a text line sliding from right to left in the last row of the video
  1154. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1155. with no newlines.
  1156. @example
  1157. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1158. @end example
  1159. @item
  1160. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1161. @example
  1162. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1163. @end example
  1164. @item
  1165. Draw a single green letter "g", at the center of the input video.
  1166. The glyph baseline is placed at half screen height.
  1167. @example
  1168. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1169. @end example
  1170. @item
  1171. Show text for 1 second every 3 seconds:
  1172. @example
  1173. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\\,3)\\,1):text='blink'"
  1174. @end example
  1175. @item
  1176. Use fontconfig to set the font. Note that the colons need to be escaped.
  1177. @example
  1178. drawtext='fontfile=Linux Libertine O-40\\:style=Semibold:text=FFmpeg'
  1179. @end example
  1180. @end itemize
  1181. For more information about libfreetype, check:
  1182. @url{http://www.freetype.org/}.
  1183. For more information about fontconfig, check:
  1184. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1185. @section fade
  1186. Apply fade-in/out effect to input video.
  1187. It accepts the parameters:
  1188. @var{type}:@var{start_frame}:@var{nb_frames}[:@var{options}]
  1189. @var{type} specifies if the effect type, can be either "in" for
  1190. fade-in, or "out" for a fade-out effect.
  1191. @var{start_frame} specifies the number of the start frame for starting
  1192. to apply the fade effect.
  1193. @var{nb_frames} specifies the number of frames for which the fade
  1194. effect has to last. At the end of the fade-in effect the output video
  1195. will have the same intensity as the input video, at the end of the
  1196. fade-out transition the output video will be completely black.
  1197. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1198. separated by ":". The description of the accepted options follows.
  1199. @table @option
  1200. @item type, t
  1201. See @var{type}.
  1202. @item start_frame, s
  1203. See @var{start_frame}.
  1204. @item nb_frames, n
  1205. See @var{nb_frames}.
  1206. @item alpha
  1207. If set to 1, fade only alpha channel, if one exists on the input.
  1208. Default value is 0.
  1209. @end table
  1210. A few usage examples follow, usable too as test scenarios.
  1211. @example
  1212. # fade in first 30 frames of video
  1213. fade=in:0:30
  1214. # fade out last 45 frames of a 200-frame video
  1215. fade=out:155:45
  1216. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  1217. fade=in:0:25, fade=out:975:25
  1218. # make first 5 frames black, then fade in from frame 5-24
  1219. fade=in:5:20
  1220. # fade in alpha over first 25 frames of video
  1221. fade=in:0:25:alpha=1
  1222. @end example
  1223. @section fieldorder
  1224. Transform the field order of the input video.
  1225. It accepts one parameter which specifies the required field order that
  1226. the input interlaced video will be transformed to. The parameter can
  1227. assume one of the following values:
  1228. @table @option
  1229. @item 0 or bff
  1230. output bottom field first
  1231. @item 1 or tff
  1232. output top field first
  1233. @end table
  1234. Default value is "tff".
  1235. Transformation is achieved by shifting the picture content up or down
  1236. by one line, and filling the remaining line with appropriate picture content.
  1237. This method is consistent with most broadcast field order converters.
  1238. If the input video is not flagged as being interlaced, or it is already
  1239. flagged as being of the required output field order then this filter does
  1240. not alter the incoming video.
  1241. This filter is very useful when converting to or from PAL DV material,
  1242. which is bottom field first.
  1243. For example:
  1244. @example
  1245. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1246. @end example
  1247. @section fifo
  1248. Buffer input images and send them when they are requested.
  1249. This filter is mainly useful when auto-inserted by the libavfilter
  1250. framework.
  1251. The filter does not take parameters.
  1252. @section format
  1253. Convert the input video to one of the specified pixel formats.
  1254. Libavfilter will try to pick one that is supported for the input to
  1255. the next filter.
  1256. The filter accepts a list of pixel format names, separated by ":",
  1257. for example "yuv420p:monow:rgb24".
  1258. Some examples follow:
  1259. @example
  1260. # convert the input video to the format "yuv420p"
  1261. format=yuv420p
  1262. # convert the input video to any of the formats in the list
  1263. format=yuv420p:yuv444p:yuv410p
  1264. @end example
  1265. @anchor{frei0r}
  1266. @section frei0r
  1267. Apply a frei0r effect to the input video.
  1268. To enable compilation of this filter you need to install the frei0r
  1269. header and configure FFmpeg with @code{--enable-frei0r}.
  1270. The filter supports the syntax:
  1271. @example
  1272. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1273. @end example
  1274. @var{filter_name} is the name to the frei0r effect to load. If the
  1275. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1276. is searched in each one of the directories specified by the colon
  1277. separated list in @env{FREIOR_PATH}, otherwise in the standard frei0r
  1278. paths, which are in this order: @file{HOME/.frei0r-1/lib/},
  1279. @file{/usr/local/lib/frei0r-1/}, @file{/usr/lib/frei0r-1/}.
  1280. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1281. for the frei0r effect.
  1282. A frei0r effect parameter can be a boolean (whose values are specified
  1283. with "y" and "n"), a double, a color (specified by the syntax
  1284. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1285. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1286. description), a position (specified by the syntax @var{X}/@var{Y},
  1287. @var{X} and @var{Y} being float numbers) and a string.
  1288. The number and kind of parameters depend on the loaded effect. If an
  1289. effect parameter is not specified the default value is set.
  1290. Some examples follow:
  1291. @example
  1292. # apply the distort0r effect, set the first two double parameters
  1293. frei0r=distort0r:0.5:0.01
  1294. # apply the colordistance effect, takes a color as first parameter
  1295. frei0r=colordistance:0.2/0.3/0.4
  1296. frei0r=colordistance:violet
  1297. frei0r=colordistance:0x112233
  1298. # apply the perspective effect, specify the top left and top right
  1299. # image positions
  1300. frei0r=perspective:0.2/0.2:0.8/0.2
  1301. @end example
  1302. For more information see:
  1303. @url{http://piksel.org/frei0r}
  1304. @section gradfun
  1305. Fix the banding artifacts that are sometimes introduced into nearly flat
  1306. regions by truncation to 8bit color depth.
  1307. Interpolate the gradients that should go where the bands are, and
  1308. dither them.
  1309. This filter is designed for playback only. Do not use it prior to
  1310. lossy compression, because compression tends to lose the dither and
  1311. bring back the bands.
  1312. The filter takes two optional parameters, separated by ':':
  1313. @var{strength}:@var{radius}
  1314. @var{strength} is the maximum amount by which the filter will change
  1315. any one pixel. Also the threshold for detecting nearly flat
  1316. regions. Acceptable values range from .51 to 255, default value is
  1317. 1.2, out-of-range values will be clipped to the valid range.
  1318. @var{radius} is the neighborhood to fit the gradient to. A larger
  1319. radius makes for smoother gradients, but also prevents the filter from
  1320. modifying the pixels near detailed regions. Acceptable values are
  1321. 8-32, default value is 16, out-of-range values will be clipped to the
  1322. valid range.
  1323. @example
  1324. # default parameters
  1325. gradfun=1.2:16
  1326. # omitting radius
  1327. gradfun=1.2
  1328. @end example
  1329. @section hflip
  1330. Flip the input video horizontally.
  1331. For example to horizontally flip the input video with @command{ffmpeg}:
  1332. @example
  1333. ffmpeg -i in.avi -vf "hflip" out.avi
  1334. @end example
  1335. @section hqdn3d
  1336. High precision/quality 3d denoise filter. This filter aims to reduce
  1337. image noise producing smooth images and making still images really
  1338. still. It should enhance compressibility.
  1339. It accepts the following optional parameters:
  1340. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  1341. @table @option
  1342. @item luma_spatial
  1343. a non-negative float number which specifies spatial luma strength,
  1344. defaults to 4.0
  1345. @item chroma_spatial
  1346. a non-negative float number which specifies spatial chroma strength,
  1347. defaults to 3.0*@var{luma_spatial}/4.0
  1348. @item luma_tmp
  1349. a float number which specifies luma temporal strength, defaults to
  1350. 6.0*@var{luma_spatial}/4.0
  1351. @item chroma_tmp
  1352. a float number which specifies chroma temporal strength, defaults to
  1353. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  1354. @end table
  1355. @section idet
  1356. Interlaceing detect filter. This filter tries to detect if the input is
  1357. interlaced or progressive. Top or bottom field first.
  1358. @section lut, lutrgb, lutyuv
  1359. Compute a look-up table for binding each pixel component input value
  1360. to an output value, and apply it to input video.
  1361. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  1362. to an RGB input video.
  1363. These filters accept in input a ":"-separated list of options, which
  1364. specify the expressions used for computing the lookup table for the
  1365. corresponding pixel component values.
  1366. The @var{lut} filter requires either YUV or RGB pixel formats in
  1367. input, and accepts the options:
  1368. @table @option
  1369. @item c0
  1370. first pixel component
  1371. @item c1
  1372. second pixel component
  1373. @item c2
  1374. third pixel component
  1375. @item c3
  1376. fourth pixel component, corresponds to the alpha component
  1377. @end table
  1378. The exact component associated to each option depends on the format in
  1379. input.
  1380. The @var{lutrgb} filter requires RGB pixel formats in input, and
  1381. accepts the options:
  1382. @table @option
  1383. @item r
  1384. red component
  1385. @item g
  1386. green component
  1387. @item b
  1388. blue component
  1389. @item a
  1390. alpha component
  1391. @end table
  1392. The @var{lutyuv} filter requires YUV pixel formats in input, and
  1393. accepts the options:
  1394. @table @option
  1395. @item y
  1396. Y/luminance component
  1397. @item u
  1398. U/Cb component
  1399. @item v
  1400. V/Cr component
  1401. @item a
  1402. alpha component
  1403. @end table
  1404. The expressions can contain the following constants and functions:
  1405. @table @option
  1406. @item w, h
  1407. the input width and height
  1408. @item val
  1409. input value for the pixel component
  1410. @item clipval
  1411. the input value clipped in the @var{minval}-@var{maxval} range
  1412. @item maxval
  1413. maximum value for the pixel component
  1414. @item minval
  1415. minimum value for the pixel component
  1416. @item negval
  1417. the negated value for the pixel component value clipped in the
  1418. @var{minval}-@var{maxval} range , it corresponds to the expression
  1419. "maxval-clipval+minval"
  1420. @item clip(val)
  1421. the computed value in @var{val} clipped in the
  1422. @var{minval}-@var{maxval} range
  1423. @item gammaval(gamma)
  1424. the computed gamma correction value of the pixel component value
  1425. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  1426. expression
  1427. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  1428. @end table
  1429. All expressions default to "val".
  1430. Some examples follow:
  1431. @example
  1432. # negate input video
  1433. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  1434. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  1435. # the above is the same as
  1436. lutrgb="r=negval:g=negval:b=negval"
  1437. lutyuv="y=negval:u=negval:v=negval"
  1438. # negate luminance
  1439. lutyuv=y=negval
  1440. # remove chroma components, turns the video into a graytone image
  1441. lutyuv="u=128:v=128"
  1442. # apply a luma burning effect
  1443. lutyuv="y=2*val"
  1444. # remove green and blue components
  1445. lutrgb="g=0:b=0"
  1446. # set a constant alpha channel value on input
  1447. format=rgba,lutrgb=a="maxval-minval/2"
  1448. # correct luminance gamma by a 0.5 factor
  1449. lutyuv=y=gammaval(0.5)
  1450. @end example
  1451. @section mp
  1452. Apply an MPlayer filter to the input video.
  1453. This filter provides a wrapper around most of the filters of
  1454. MPlayer/MEncoder.
  1455. This wrapper is considered experimental. Some of the wrapped filters
  1456. may not work properly and we may drop support for them, as they will
  1457. be implemented natively into FFmpeg. Thus you should avoid
  1458. depending on them when writing portable scripts.
  1459. The filters accepts the parameters:
  1460. @var{filter_name}[:=]@var{filter_params}
  1461. @var{filter_name} is the name of a supported MPlayer filter,
  1462. @var{filter_params} is a string containing the parameters accepted by
  1463. the named filter.
  1464. The list of the currently supported filters follows:
  1465. @table @var
  1466. @item decimate
  1467. @item denoise3d
  1468. @item detc
  1469. @item dint
  1470. @item divtc
  1471. @item down3dright
  1472. @item dsize
  1473. @item eq2
  1474. @item eq
  1475. @item field
  1476. @item fil
  1477. @item fixpts
  1478. @item framestep
  1479. @item fspp
  1480. @item geq
  1481. @item harddup
  1482. @item hqdn3d
  1483. @item hue
  1484. @item il
  1485. @item ilpack
  1486. @item ivtc
  1487. @item kerndeint
  1488. @item mcdeint
  1489. @item noise
  1490. @item ow
  1491. @item palette
  1492. @item perspective
  1493. @item phase
  1494. @item pp7
  1495. @item pullup
  1496. @item qp
  1497. @item rectangle
  1498. @item rotate
  1499. @item sab
  1500. @item smartblur
  1501. @item softpulldown
  1502. @item softskip
  1503. @item spp
  1504. @item telecine
  1505. @item tile
  1506. @item tinterlace
  1507. @item unsharp
  1508. @item uspp
  1509. @item yuvcsp
  1510. @item yvu9
  1511. @end table
  1512. The parameter syntax and behavior for the listed filters are the same
  1513. of the corresponding MPlayer filters. For detailed instructions check
  1514. the "VIDEO FILTERS" section in the MPlayer manual.
  1515. Some examples follow:
  1516. @example
  1517. # adjust gamma, brightness, contrast
  1518. mp=eq2=1.0:2:0.5
  1519. # tweak hue and saturation
  1520. mp=hue=100:-10
  1521. @end example
  1522. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  1523. @section negate
  1524. Negate input video.
  1525. This filter accepts an integer in input, if non-zero it negates the
  1526. alpha component (if available). The default value in input is 0.
  1527. @section noformat
  1528. Force libavfilter not to use any of the specified pixel formats for the
  1529. input to the next filter.
  1530. The filter accepts a list of pixel format names, separated by ":",
  1531. for example "yuv420p:monow:rgb24".
  1532. Some examples follow:
  1533. @example
  1534. # force libavfilter to use a format different from "yuv420p" for the
  1535. # input to the vflip filter
  1536. noformat=yuv420p,vflip
  1537. # convert the input video to any of the formats not contained in the list
  1538. noformat=yuv420p:yuv444p:yuv410p
  1539. @end example
  1540. @section null
  1541. Pass the video source unchanged to the output.
  1542. @section ocv
  1543. Apply video transform using libopencv.
  1544. To enable this filter install libopencv library and headers and
  1545. configure FFmpeg with @code{--enable-libopencv}.
  1546. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  1547. @var{filter_name} is the name of the libopencv filter to apply.
  1548. @var{filter_params} specifies the parameters to pass to the libopencv
  1549. filter. If not specified the default values are assumed.
  1550. Refer to the official libopencv documentation for more precise
  1551. information:
  1552. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  1553. Follows the list of supported libopencv filters.
  1554. @anchor{dilate}
  1555. @subsection dilate
  1556. Dilate an image by using a specific structuring element.
  1557. This filter corresponds to the libopencv function @code{cvDilate}.
  1558. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  1559. @var{struct_el} represents a structuring element, and has the syntax:
  1560. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  1561. @var{cols} and @var{rows} represent the number of columns and rows of
  1562. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  1563. point, and @var{shape} the shape for the structuring element, and
  1564. can be one of the values "rect", "cross", "ellipse", "custom".
  1565. If the value for @var{shape} is "custom", it must be followed by a
  1566. string of the form "=@var{filename}". The file with name
  1567. @var{filename} is assumed to represent a binary image, with each
  1568. printable character corresponding to a bright pixel. When a custom
  1569. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  1570. or columns and rows of the read file are assumed instead.
  1571. The default value for @var{struct_el} is "3x3+0x0/rect".
  1572. @var{nb_iterations} specifies the number of times the transform is
  1573. applied to the image, and defaults to 1.
  1574. Follow some example:
  1575. @example
  1576. # use the default values
  1577. ocv=dilate
  1578. # dilate using a structuring element with a 5x5 cross, iterate two times
  1579. ocv=dilate=5x5+2x2/cross:2
  1580. # read the shape from the file diamond.shape, iterate two times
  1581. # the file diamond.shape may contain a pattern of characters like this:
  1582. # *
  1583. # ***
  1584. # *****
  1585. # ***
  1586. # *
  1587. # the specified cols and rows are ignored (but not the anchor point coordinates)
  1588. ocv=0x0+2x2/custom=diamond.shape:2
  1589. @end example
  1590. @subsection erode
  1591. Erode an image by using a specific structuring element.
  1592. This filter corresponds to the libopencv function @code{cvErode}.
  1593. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  1594. with the same syntax and semantics as the @ref{dilate} filter.
  1595. @subsection smooth
  1596. Smooth the input video.
  1597. The filter takes the following parameters:
  1598. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  1599. @var{type} is the type of smooth filter to apply, and can be one of
  1600. the following values: "blur", "blur_no_scale", "median", "gaussian",
  1601. "bilateral". The default value is "gaussian".
  1602. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  1603. parameters whose meanings depend on smooth type. @var{param1} and
  1604. @var{param2} accept integer positive values or 0, @var{param3} and
  1605. @var{param4} accept float values.
  1606. The default value for @var{param1} is 3, the default value for the
  1607. other parameters is 0.
  1608. These parameters correspond to the parameters assigned to the
  1609. libopencv function @code{cvSmooth}.
  1610. @anchor{overlay}
  1611. @section overlay
  1612. Overlay one video on top of another.
  1613. It takes two inputs and one output, the first input is the "main"
  1614. video on which the second input is overlayed.
  1615. It accepts the parameters: @var{x}:@var{y}[:@var{options}].
  1616. @var{x} is the x coordinate of the overlayed video on the main video,
  1617. @var{y} is the y coordinate. @var{x} and @var{y} are expressions containing
  1618. the following parameters:
  1619. @table @option
  1620. @item main_w, main_h
  1621. main input width and height
  1622. @item W, H
  1623. same as @var{main_w} and @var{main_h}
  1624. @item overlay_w, overlay_h
  1625. overlay input width and height
  1626. @item w, h
  1627. same as @var{overlay_w} and @var{overlay_h}
  1628. @end table
  1629. @var{options} is an optional list of @var{key}=@var{value} pairs,
  1630. separated by ":".
  1631. The description of the accepted options follows.
  1632. @table @option
  1633. @item rgb
  1634. If set to 1, force the filter to accept inputs in the RGB
  1635. color space. Default value is 0.
  1636. @end table
  1637. Be aware that frames are taken from each input video in timestamp
  1638. order, hence, if their initial timestamps differ, it is a a good idea
  1639. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  1640. have them begin in the same zero timestamp, as it does the example for
  1641. the @var{movie} filter.
  1642. Follow some examples:
  1643. @example
  1644. # draw the overlay at 10 pixels from the bottom right
  1645. # corner of the main video.
  1646. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  1647. # insert a transparent PNG logo in the bottom left corner of the input
  1648. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  1649. # insert 2 different transparent PNG logos (second logo on bottom
  1650. # right corner):
  1651. ffmpeg -i input -i logo1 -i logo2 -filter_complex
  1652. 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  1653. # add a transparent color layer on top of the main video,
  1654. # WxH specifies the size of the main input to the overlay filter
  1655. color=red@.3:WxH [over]; [in][over] overlay [out]
  1656. @end example
  1657. You can chain together more overlays but the efficiency of such
  1658. approach is yet to be tested.
  1659. @section pad
  1660. Add paddings to the input image, and places the original input at the
  1661. given coordinates @var{x}, @var{y}.
  1662. It accepts the following parameters:
  1663. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  1664. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  1665. expressions containing the following constants:
  1666. @table @option
  1667. @item in_w, in_h
  1668. the input video width and height
  1669. @item iw, ih
  1670. same as @var{in_w} and @var{in_h}
  1671. @item out_w, out_h
  1672. the output width and height, that is the size of the padded area as
  1673. specified by the @var{width} and @var{height} expressions
  1674. @item ow, oh
  1675. same as @var{out_w} and @var{out_h}
  1676. @item x, y
  1677. x and y offsets as specified by the @var{x} and @var{y}
  1678. expressions, or NAN if not yet specified
  1679. @item a
  1680. same as @var{iw} / @var{ih}
  1681. @item sar
  1682. input sample aspect ratio
  1683. @item dar
  1684. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1685. @item hsub, vsub
  1686. horizontal and vertical chroma subsample values. For example for the
  1687. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1688. @end table
  1689. Follows the description of the accepted parameters.
  1690. @table @option
  1691. @item width, height
  1692. Specify the size of the output image with the paddings added. If the
  1693. value for @var{width} or @var{height} is 0, the corresponding input size
  1694. is used for the output.
  1695. The @var{width} expression can reference the value set by the
  1696. @var{height} expression, and vice versa.
  1697. The default value of @var{width} and @var{height} is 0.
  1698. @item x, y
  1699. Specify the offsets where to place the input image in the padded area
  1700. with respect to the top/left border of the output image.
  1701. The @var{x} expression can reference the value set by the @var{y}
  1702. expression, and vice versa.
  1703. The default value of @var{x} and @var{y} is 0.
  1704. @item color
  1705. Specify the color of the padded area, it can be the name of a color
  1706. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  1707. The default value of @var{color} is "black".
  1708. @end table
  1709. Some examples follow:
  1710. @example
  1711. # Add paddings with color "violet" to the input video. Output video
  1712. # size is 640x480, the top-left corner of the input video is placed at
  1713. # column 0, row 40.
  1714. pad=640:480:0:40:violet
  1715. # pad the input to get an output with dimensions increased bt 3/2,
  1716. # and put the input video at the center of the padded area
  1717. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  1718. # pad the input to get a squared output with size equal to the maximum
  1719. # value between the input width and height, and put the input video at
  1720. # the center of the padded area
  1721. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  1722. # pad the input to get a final w/h ratio of 16:9
  1723. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  1724. # for anamorphic video, in order to set the output display aspect ratio,
  1725. # it is necessary to use sar in the expression, according to the relation:
  1726. # (ih * X / ih) * sar = output_dar
  1727. # X = output_dar / sar
  1728. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  1729. # double output size and put the input video in the bottom-right
  1730. # corner of the output padded area
  1731. pad="2*iw:2*ih:ow-iw:oh-ih"
  1732. @end example
  1733. @section pixdesctest
  1734. Pixel format descriptor test filter, mainly useful for internal
  1735. testing. The output video should be equal to the input video.
  1736. For example:
  1737. @example
  1738. format=monow, pixdesctest
  1739. @end example
  1740. can be used to test the monowhite pixel format descriptor definition.
  1741. @section removelogo
  1742. Suppress a TV station logo, using an image file to determine which
  1743. pixels comprise the logo. It works by filling in the pixels that
  1744. comprise the logo with neighboring pixels.
  1745. This filter requires one argument which specifies the filter bitmap
  1746. file, which can be any image format supported by libavformat. The
  1747. width and height of the image file must match those of the video
  1748. stream being processed.
  1749. Pixels in the provided bitmap image with a value of zero are not
  1750. considered part of the logo, non-zero pixels are considered part of
  1751. the logo. If you use white (255) for the logo and black (0) for the
  1752. rest, you will be safe. For making the filter bitmap, it is
  1753. recommended to take a screen capture of a black frame with the logo
  1754. visible, and then using a threshold filter followed by the erode
  1755. filter once or twice.
  1756. If needed, little splotches can be fixed manually. Remember that if
  1757. logo pixels are not covered, the filter quality will be much
  1758. reduced. Marking too many pixels as part of the logo does not hurt as
  1759. much, but it will increase the amount of blurring needed to cover over
  1760. the image and will destroy more information than necessary, and extra
  1761. pixels will slow things down on a large logo.
  1762. @section scale
  1763. Scale the input video to @var{width}:@var{height}[:@var{interl}=@{1|-1@}] and/or convert the image format.
  1764. The scale filter forces the output display aspect ratio to be the same
  1765. of the input, by changing the output sample aspect ratio.
  1766. The parameters @var{width} and @var{height} are expressions containing
  1767. the following constants:
  1768. @table @option
  1769. @item in_w, in_h
  1770. the input width and height
  1771. @item iw, ih
  1772. same as @var{in_w} and @var{in_h}
  1773. @item out_w, out_h
  1774. the output (cropped) width and height
  1775. @item ow, oh
  1776. same as @var{out_w} and @var{out_h}
  1777. @item a
  1778. same as @var{iw} / @var{ih}
  1779. @item sar
  1780. input sample aspect ratio
  1781. @item dar
  1782. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1783. @item hsub, vsub
  1784. horizontal and vertical chroma subsample values. For example for the
  1785. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1786. @end table
  1787. If the input image format is different from the format requested by
  1788. the next filter, the scale filter will convert the input to the
  1789. requested format.
  1790. If the value for @var{width} or @var{height} is 0, the respective input
  1791. size is used for the output.
  1792. If the value for @var{width} or @var{height} is -1, the scale filter will
  1793. use, for the respective output size, a value that maintains the aspect
  1794. ratio of the input image.
  1795. The default value of @var{width} and @var{height} is 0.
  1796. Valid values for the optional parameter @var{interl} are:
  1797. @table @option
  1798. @item 1
  1799. force interlaced aware scaling
  1800. @item -1
  1801. select interlaced aware scaling depending on whether the source frames
  1802. are flagged as interlaced or not
  1803. @end table
  1804. Unless @var{interl} is set to one of the above options, interlaced scaling will not be used.
  1805. Some examples follow:
  1806. @example
  1807. # scale the input video to a size of 200x100.
  1808. scale=200:100
  1809. # scale the input to 2x
  1810. scale=2*iw:2*ih
  1811. # the above is the same as
  1812. scale=2*in_w:2*in_h
  1813. # scale the input to 2x with forced interlaced scaling
  1814. scale=2*iw:2*ih:interl=1
  1815. # scale the input to half size
  1816. scale=iw/2:ih/2
  1817. # increase the width, and set the height to the same size
  1818. scale=3/2*iw:ow
  1819. # seek for Greek harmony
  1820. scale=iw:1/PHI*iw
  1821. scale=ih*PHI:ih
  1822. # increase the height, and set the width to 3/2 of the height
  1823. scale=3/2*oh:3/5*ih
  1824. # increase the size, but make the size a multiple of the chroma
  1825. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  1826. # increase the width to a maximum of 500 pixels, keep the same input aspect ratio
  1827. scale='min(500\, iw*3/2):-1'
  1828. @end example
  1829. @section select
  1830. Select frames to pass in output.
  1831. It accepts in input an expression, which is evaluated for each input
  1832. frame. If the expression is evaluated to a non-zero value, the frame
  1833. is selected and passed to the output, otherwise it is discarded.
  1834. The expression can contain the following constants:
  1835. @table @option
  1836. @item n
  1837. the sequential number of the filtered frame, starting from 0
  1838. @item selected_n
  1839. the sequential number of the selected frame, starting from 0
  1840. @item prev_selected_n
  1841. the sequential number of the last selected frame, NAN if undefined
  1842. @item TB
  1843. timebase of the input timestamps
  1844. @item pts
  1845. the PTS (Presentation TimeStamp) of the filtered video frame,
  1846. expressed in @var{TB} units, NAN if undefined
  1847. @item t
  1848. the PTS (Presentation TimeStamp) of the filtered video frame,
  1849. expressed in seconds, NAN if undefined
  1850. @item prev_pts
  1851. the PTS of the previously filtered video frame, NAN if undefined
  1852. @item prev_selected_pts
  1853. the PTS of the last previously filtered video frame, NAN if undefined
  1854. @item prev_selected_t
  1855. the PTS of the last previously selected video frame, NAN if undefined
  1856. @item start_pts
  1857. the PTS of the first video frame in the video, NAN if undefined
  1858. @item start_t
  1859. the time of the first video frame in the video, NAN if undefined
  1860. @item pict_type
  1861. the type of the filtered frame, can assume one of the following
  1862. values:
  1863. @table @option
  1864. @item I
  1865. @item P
  1866. @item B
  1867. @item S
  1868. @item SI
  1869. @item SP
  1870. @item BI
  1871. @end table
  1872. @item interlace_type
  1873. the frame interlace type, can assume one of the following values:
  1874. @table @option
  1875. @item PROGRESSIVE
  1876. the frame is progressive (not interlaced)
  1877. @item TOPFIRST
  1878. the frame is top-field-first
  1879. @item BOTTOMFIRST
  1880. the frame is bottom-field-first
  1881. @end table
  1882. @item key
  1883. 1 if the filtered frame is a key-frame, 0 otherwise
  1884. @item pos
  1885. the position in the file of the filtered frame, -1 if the information
  1886. is not available (e.g. for synthetic video)
  1887. @end table
  1888. The default value of the select expression is "1".
  1889. Some examples follow:
  1890. @example
  1891. # select all frames in input
  1892. select
  1893. # the above is the same as:
  1894. select=1
  1895. # skip all frames:
  1896. select=0
  1897. # select only I-frames
  1898. select='eq(pict_type\,I)'
  1899. # select one frame every 100
  1900. select='not(mod(n\,100))'
  1901. # select only frames contained in the 10-20 time interval
  1902. select='gte(t\,10)*lte(t\,20)'
  1903. # select only I frames contained in the 10-20 time interval
  1904. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  1905. # select frames with a minimum distance of 10 seconds
  1906. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  1907. @end example
  1908. @section setdar, setsar
  1909. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  1910. output video.
  1911. This is done by changing the specified Sample (aka Pixel) Aspect
  1912. Ratio, according to the following equation:
  1913. @example
  1914. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  1915. @end example
  1916. Keep in mind that the @code{setdar} filter does not modify the pixel
  1917. dimensions of the video frame. Also the display aspect ratio set by
  1918. this filter may be changed by later filters in the filterchain,
  1919. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  1920. applied.
  1921. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  1922. the filter output video.
  1923. Note that as a consequence of the application of this filter, the
  1924. output display aspect ratio will change according to the equation
  1925. above.
  1926. Keep in mind that the sample aspect ratio set by the @code{setsar}
  1927. filter may be changed by later filters in the filterchain, e.g. if
  1928. another "setsar" or a "setdar" filter is applied.
  1929. The @code{setdar} and @code{setsar} filters accept a parameter string
  1930. which represents the wanted aspect ratio. The parameter can
  1931. be a floating point number string, an expression, or a string of the form
  1932. @var{num}:@var{den}, where @var{num} and @var{den} are the numerator
  1933. and denominator of the aspect ratio. If the parameter is not
  1934. specified, it is assumed the value "0:1".
  1935. For example to change the display aspect ratio to 16:9, specify:
  1936. @example
  1937. setdar=16:9
  1938. @end example
  1939. The example above is equivalent to:
  1940. @example
  1941. setdar=1.77777
  1942. @end example
  1943. To change the sample aspect ratio to 10:11, specify:
  1944. @example
  1945. setsar=10:11
  1946. @end example
  1947. @section setfield
  1948. Force field for the output video frame.
  1949. The @code{setfield} filter marks the interlace type field for the
  1950. output frames. It does not change the input frame, but only sets the
  1951. corresponding property, which affects how the frame is treated by
  1952. following filters (e.g. @code{fieldorder} or @code{yadif}).
  1953. It accepts a string parameter, which can assume the following values:
  1954. @table @samp
  1955. @item auto
  1956. Keep the same field property.
  1957. @item bff
  1958. Mark the frame as bottom-field-first.
  1959. @item tff
  1960. Mark the frame as top-field-first.
  1961. @item prog
  1962. Mark the frame as progressive.
  1963. @end table
  1964. @section setpts
  1965. Change the PTS (presentation timestamp) of the input video frames.
  1966. Accept in input an expression evaluated through the eval API, which
  1967. can contain the following constants:
  1968. @table @option
  1969. @item PTS
  1970. the presentation timestamp in input
  1971. @item N
  1972. the count of the input frame, starting from 0.
  1973. @item STARTPTS
  1974. the PTS of the first video frame
  1975. @item INTERLACED
  1976. tell if the current frame is interlaced
  1977. @item POS
  1978. original position in the file of the frame, or undefined if undefined
  1979. for the current frame
  1980. @item PREV_INPTS
  1981. previous input PTS
  1982. @item PREV_OUTPTS
  1983. previous output PTS
  1984. @end table
  1985. Some examples follow:
  1986. @example
  1987. # start counting PTS from zero
  1988. setpts=PTS-STARTPTS
  1989. # fast motion
  1990. setpts=0.5*PTS
  1991. # slow motion
  1992. setpts=2.0*PTS
  1993. # fixed rate 25 fps
  1994. setpts=N/(25*TB)
  1995. # fixed rate 25 fps with some jitter
  1996. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  1997. @end example
  1998. @section settb
  1999. Set the timebase to use for the output frames timestamps.
  2000. It is mainly useful for testing timebase configuration.
  2001. It accepts in input an arithmetic expression representing a rational.
  2002. The expression can contain the constants "AVTB" (the
  2003. default timebase), and "intb" (the input timebase).
  2004. The default value for the input is "intb".
  2005. Follow some examples.
  2006. @example
  2007. # set the timebase to 1/25
  2008. settb=1/25
  2009. # set the timebase to 1/10
  2010. settb=0.1
  2011. #set the timebase to 1001/1000
  2012. settb=1+0.001
  2013. #set the timebase to 2*intb
  2014. settb=2*intb
  2015. #set the default timebase value
  2016. settb=AVTB
  2017. @end example
  2018. @section showinfo
  2019. Show a line containing various information for each input video frame.
  2020. The input video is not modified.
  2021. The shown line contains a sequence of key/value pairs of the form
  2022. @var{key}:@var{value}.
  2023. A description of each shown parameter follows:
  2024. @table @option
  2025. @item n
  2026. sequential number of the input frame, starting from 0
  2027. @item pts
  2028. Presentation TimeStamp of the input frame, expressed as a number of
  2029. time base units. The time base unit depends on the filter input pad.
  2030. @item pts_time
  2031. Presentation TimeStamp of the input frame, expressed as a number of
  2032. seconds
  2033. @item pos
  2034. position of the frame in the input stream, -1 if this information in
  2035. unavailable and/or meaningless (for example in case of synthetic video)
  2036. @item fmt
  2037. pixel format name
  2038. @item sar
  2039. sample aspect ratio of the input frame, expressed in the form
  2040. @var{num}/@var{den}
  2041. @item s
  2042. size of the input frame, expressed in the form
  2043. @var{width}x@var{height}
  2044. @item i
  2045. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  2046. for bottom field first)
  2047. @item iskey
  2048. 1 if the frame is a key frame, 0 otherwise
  2049. @item type
  2050. picture type of the input frame ("I" for an I-frame, "P" for a
  2051. P-frame, "B" for a B-frame, "?" for unknown type).
  2052. Check also the documentation of the @code{AVPictureType} enum and of
  2053. the @code{av_get_picture_type_char} function defined in
  2054. @file{libavutil/avutil.h}.
  2055. @item checksum
  2056. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  2057. @item plane_checksum
  2058. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  2059. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  2060. @end table
  2061. @section slicify
  2062. Pass the images of input video on to next video filter as multiple
  2063. slices.
  2064. @example
  2065. ffmpeg -i in.avi -vf "slicify=32" out.avi
  2066. @end example
  2067. The filter accepts the slice height as parameter. If the parameter is
  2068. not specified it will use the default value of 16.
  2069. Adding this in the beginning of filter chains should make filtering
  2070. faster due to better use of the memory cache.
  2071. @section split
  2072. Split input video into several identical outputs.
  2073. The filter accepts a single parameter which specifies the number of outputs. If
  2074. unspecified, it defaults to 2.
  2075. For example
  2076. @example
  2077. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  2078. @end example
  2079. will create 5 copies of the input video.
  2080. For example:
  2081. @example
  2082. [in] split [splitout1][splitout2];
  2083. [splitout1] crop=100:100:0:0 [cropout];
  2084. [splitout2] pad=200:200:100:100 [padout];
  2085. @end example
  2086. will create two separate outputs from the same input, one cropped and
  2087. one padded.
  2088. @section super2xsai
  2089. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  2090. Interpolate) pixel art scaling algorithm.
  2091. Useful for enlarging pixel art images without reducing sharpness.
  2092. @section swapuv
  2093. Swap U & V plane.
  2094. @section thumbnail
  2095. Select the most representative frame in a given sequence of consecutive frames.
  2096. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  2097. in a set of @var{N} frames, the filter will pick one of them, and then handle
  2098. the next batch of @var{N} frames until the end.
  2099. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  2100. value will result in a higher memory usage, so a high value is not recommended.
  2101. The following example extract one picture each 50 frames:
  2102. @example
  2103. thumbnail=50
  2104. @end example
  2105. Complete example of a thumbnail creation with @command{ffmpeg}:
  2106. @example
  2107. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  2108. @end example
  2109. @section tile
  2110. Tile several successive frames together.
  2111. It accepts as argument the tile size (i.e. the number of lines and columns)
  2112. in the form "@var{w}x@var{h}".
  2113. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  2114. nokey}) in a movie:
  2115. @example
  2116. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  2117. @end example
  2118. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  2119. duplicating each output frame to accomodate the originally detected frame
  2120. rate.
  2121. @section tinterlace
  2122. Perform various types of temporal field interlacing.
  2123. Frames are counted starting from 1, so the first input frame is
  2124. considered odd.
  2125. This filter accepts a single parameter specifying the mode. Available
  2126. modes are:
  2127. @table @samp
  2128. @item merge, 0
  2129. Move odd frames into the upper field, even into the lower field,
  2130. generating a double height frame at half framerate.
  2131. @item drop_odd, 1
  2132. Only output even frames, odd frames are dropped, generating a frame with
  2133. unchanged height at half framerate.
  2134. @item drop_even, 2
  2135. Only output odd frames, even frames are dropped, generating a frame with
  2136. unchanged height at half framerate.
  2137. @item pad, 3
  2138. Expand each frame to full height, but pad alternate lines with black,
  2139. generating a frame with double height at the same input framerate.
  2140. @item interleave_top, 4
  2141. Interleave the upper field from odd frames with the lower field from
  2142. even frames, generating a frame with unchanged height at half framerate.
  2143. @item interleave_bottom, 5
  2144. Interleave the lower field from odd frames with the upper field from
  2145. even frames, generating a frame with unchanged height at half framerate.
  2146. @item interlacex2, 6
  2147. Double frame rate with unchanged height. Frames are inserted each
  2148. containing the second temporal field from the previous input frame and
  2149. the first temporal field from the next input frame. This mode relies on
  2150. the top_field_first flag. Useful for interlaced video displays with no
  2151. field synchronisation.
  2152. @end table
  2153. Numeric values are deprecated but are accepted for backward
  2154. compatibility reasons.
  2155. Default mode is @code{merge}.
  2156. @section transpose
  2157. Transpose rows with columns in the input video and optionally flip it.
  2158. It accepts a parameter representing an integer, which can assume the
  2159. values:
  2160. @table @samp
  2161. @item 0
  2162. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  2163. @example
  2164. L.R L.l
  2165. . . -> . .
  2166. l.r R.r
  2167. @end example
  2168. @item 1
  2169. Rotate by 90 degrees clockwise, that is:
  2170. @example
  2171. L.R l.L
  2172. . . -> . .
  2173. l.r r.R
  2174. @end example
  2175. @item 2
  2176. Rotate by 90 degrees counterclockwise, that is:
  2177. @example
  2178. L.R R.r
  2179. . . -> . .
  2180. l.r L.l
  2181. @end example
  2182. @item 3
  2183. Rotate by 90 degrees clockwise and vertically flip, that is:
  2184. @example
  2185. L.R r.R
  2186. . . -> . .
  2187. l.r l.L
  2188. @end example
  2189. @end table
  2190. @section unsharp
  2191. Sharpen or blur the input video.
  2192. It accepts the following parameters:
  2193. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  2194. Negative values for the amount will blur the input video, while positive
  2195. values will sharpen. All parameters are optional and default to the
  2196. equivalent of the string '5:5:1.0:5:5:0.0'.
  2197. @table @option
  2198. @item luma_msize_x
  2199. Set the luma matrix horizontal size. It can be an integer between 3
  2200. and 13, default value is 5.
  2201. @item luma_msize_y
  2202. Set the luma matrix vertical size. It can be an integer between 3
  2203. and 13, default value is 5.
  2204. @item luma_amount
  2205. Set the luma effect strength. It can be a float number between -2.0
  2206. and 5.0, default value is 1.0.
  2207. @item chroma_msize_x
  2208. Set the chroma matrix horizontal size. It can be an integer between 3
  2209. and 13, default value is 5.
  2210. @item chroma_msize_y
  2211. Set the chroma matrix vertical size. It can be an integer between 3
  2212. and 13, default value is 5.
  2213. @item chroma_amount
  2214. Set the chroma effect strength. It can be a float number between -2.0
  2215. and 5.0, default value is 0.0.
  2216. @end table
  2217. @example
  2218. # Strong luma sharpen effect parameters
  2219. unsharp=7:7:2.5
  2220. # Strong blur of both luma and chroma parameters
  2221. unsharp=7:7:-2:7:7:-2
  2222. # Use the default values with @command{ffmpeg}
  2223. ffmpeg -i in.avi -vf "unsharp" out.mp4
  2224. @end example
  2225. @section vflip
  2226. Flip the input video vertically.
  2227. @example
  2228. ffmpeg -i in.avi -vf "vflip" out.avi
  2229. @end example
  2230. @section yadif
  2231. Deinterlace the input video ("yadif" means "yet another deinterlacing
  2232. filter").
  2233. It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}.
  2234. @var{mode} specifies the interlacing mode to adopt, accepts one of the
  2235. following values:
  2236. @table @option
  2237. @item 0
  2238. output 1 frame for each frame
  2239. @item 1
  2240. output 1 frame for each field
  2241. @item 2
  2242. like 0 but skips spatial interlacing check
  2243. @item 3
  2244. like 1 but skips spatial interlacing check
  2245. @end table
  2246. Default value is 0.
  2247. @var{parity} specifies the picture field parity assumed for the input
  2248. interlaced video, accepts one of the following values:
  2249. @table @option
  2250. @item 0
  2251. assume top field first
  2252. @item 1
  2253. assume bottom field first
  2254. @item -1
  2255. enable automatic detection
  2256. @end table
  2257. Default value is -1.
  2258. If interlacing is unknown or decoder does not export this information,
  2259. top field first will be assumed.
  2260. @var{auto} specifies if deinterlacer should trust the interlaced flag
  2261. and only deinterlace frames marked as interlaced
  2262. @table @option
  2263. @item 0
  2264. deinterlace all frames
  2265. @item 1
  2266. only deinterlace frames marked as interlaced
  2267. @end table
  2268. Default value is 0.
  2269. @c man end VIDEO FILTERS
  2270. @chapter Video Sources
  2271. @c man begin VIDEO SOURCES
  2272. Below is a description of the currently available video sources.
  2273. @section buffer
  2274. Buffer video frames, and make them available to the filter chain.
  2275. This source is mainly intended for a programmatic use, in particular
  2276. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  2277. It accepts the following parameters:
  2278. @var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den}:@var{scale_params}
  2279. All the parameters but @var{scale_params} need to be explicitly
  2280. defined.
  2281. Follows the list of the accepted parameters.
  2282. @table @option
  2283. @item width, height
  2284. Specify the width and height of the buffered video frames.
  2285. @item pix_fmt_string
  2286. A string representing the pixel format of the buffered video frames.
  2287. It may be a number corresponding to a pixel format, or a pixel format
  2288. name.
  2289. @item timebase_num, timebase_den
  2290. Specify numerator and denomitor of the timebase assumed by the
  2291. timestamps of the buffered frames.
  2292. @item sample_aspect_ratio.num, sample_aspect_ratio.den
  2293. Specify numerator and denominator of the sample aspect ratio assumed
  2294. by the video frames.
  2295. @item scale_params
  2296. Specify the optional parameters to be used for the scale filter which
  2297. is automatically inserted when an input change is detected in the
  2298. input size or format.
  2299. @end table
  2300. For example:
  2301. @example
  2302. buffer=320:240:yuv410p:1:24:1:1
  2303. @end example
  2304. will instruct the source to accept video frames with size 320x240 and
  2305. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  2306. square pixels (1:1 sample aspect ratio).
  2307. Since the pixel format with name "yuv410p" corresponds to the number 6
  2308. (check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
  2309. this example corresponds to:
  2310. @example
  2311. buffer=320:240:6:1:24:1:1
  2312. @end example
  2313. @section cellauto
  2314. Create a pattern generated by an elementary cellular automaton.
  2315. The initial state of the cellular automaton can be defined through the
  2316. @option{filename}, and @option{pattern} options. If such options are
  2317. not specified an initial state is created randomly.
  2318. At each new frame a new row in the video is filled with the result of
  2319. the cellular automaton next generation. The behavior when the whole
  2320. frame is filled is defined by the @option{scroll} option.
  2321. This source accepts a list of options in the form of
  2322. @var{key}=@var{value} pairs separated by ":". A description of the
  2323. accepted options follows.
  2324. @table @option
  2325. @item filename, f
  2326. Read the initial cellular automaton state, i.e. the starting row, from
  2327. the specified file.
  2328. In the file, each non-whitespace character is considered an alive
  2329. cell, a newline will terminate the row, and further characters in the
  2330. file will be ignored.
  2331. @item pattern, p
  2332. Read the initial cellular automaton state, i.e. the starting row, from
  2333. the specified string.
  2334. Each non-whitespace character in the string is considered an alive
  2335. cell, a newline will terminate the row, and further characters in the
  2336. string will be ignored.
  2337. @item rate, r
  2338. Set the video rate, that is the number of frames generated per second.
  2339. Default is 25.
  2340. @item random_fill_ratio, ratio
  2341. Set the random fill ratio for the initial cellular automaton row. It
  2342. is a floating point number value ranging from 0 to 1, defaults to
  2343. 1/PHI.
  2344. This option is ignored when a file or a pattern is specified.
  2345. @item random_seed, seed
  2346. Set the seed for filling randomly the initial row, must be an integer
  2347. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2348. set to -1, the filter will try to use a good random seed on a best
  2349. effort basis.
  2350. @item rule
  2351. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  2352. Default value is 110.
  2353. @item size, s
  2354. Set the size of the output video.
  2355. If @option{filename} or @option{pattern} is specified, the size is set
  2356. by default to the width of the specified initial state row, and the
  2357. height is set to @var{width} * PHI.
  2358. If @option{size} is set, it must contain the width of the specified
  2359. pattern string, and the specified pattern will be centered in the
  2360. larger row.
  2361. If a filename or a pattern string is not specified, the size value
  2362. defaults to "320x518" (used for a randomly generated initial state).
  2363. @item scroll
  2364. If set to 1, scroll the output upward when all the rows in the output
  2365. have been already filled. If set to 0, the new generated row will be
  2366. written over the top row just after the bottom row is filled.
  2367. Defaults to 1.
  2368. @item start_full, full
  2369. If set to 1, completely fill the output with generated rows before
  2370. outputting the first frame.
  2371. This is the default behavior, for disabling set the value to 0.
  2372. @item stitch
  2373. If set to 1, stitch the left and right row edges together.
  2374. This is the default behavior, for disabling set the value to 0.
  2375. @end table
  2376. @subsection Examples
  2377. @itemize
  2378. @item
  2379. Read the initial state from @file{pattern}, and specify an output of
  2380. size 200x400.
  2381. @example
  2382. cellauto=f=pattern:s=200x400
  2383. @end example
  2384. @item
  2385. Generate a random initial row with a width of 200 cells, with a fill
  2386. ratio of 2/3:
  2387. @example
  2388. cellauto=ratio=2/3:s=200x200
  2389. @end example
  2390. @item
  2391. Create a pattern generated by rule 18 starting by a single alive cell
  2392. centered on an initial row with width 100:
  2393. @example
  2394. cellauto=p=@@:s=100x400:full=0:rule=18
  2395. @end example
  2396. @item
  2397. Specify a more elaborated initial pattern:
  2398. @example
  2399. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  2400. @end example
  2401. @end itemize
  2402. @section color
  2403. Provide an uniformly colored input.
  2404. It accepts the following parameters:
  2405. @var{color}:@var{frame_size}:@var{frame_rate}
  2406. Follows the description of the accepted parameters.
  2407. @table @option
  2408. @item color
  2409. Specify the color of the source. It can be the name of a color (case
  2410. insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
  2411. alpha specifier. The default value is "black".
  2412. @item frame_size
  2413. Specify the size of the sourced video, it may be a string of the form
  2414. @var{width}x@var{height}, or the name of a size abbreviation. The
  2415. default value is "320x240".
  2416. @item frame_rate
  2417. Specify the frame rate of the sourced video, as the number of frames
  2418. generated per second. It has to be a string in the format
  2419. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2420. number or a valid video frame rate abbreviation. The default value is
  2421. "25".
  2422. @end table
  2423. For example the following graph description will generate a red source
  2424. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  2425. frames per second, which will be overlayed over the source connected
  2426. to the pad with identifier "in".
  2427. @example
  2428. "color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
  2429. @end example
  2430. @section movie
  2431. Read a video stream from a movie container.
  2432. It accepts the syntax: @var{movie_name}[:@var{options}] where
  2433. @var{movie_name} is the name of the resource to read (not necessarily
  2434. a file but also a device or a stream accessed through some protocol),
  2435. and @var{options} is an optional sequence of @var{key}=@var{value}
  2436. pairs, separated by ":".
  2437. The description of the accepted options follows.
  2438. @table @option
  2439. @item format_name, f
  2440. Specifies the format assumed for the movie to read, and can be either
  2441. the name of a container or an input device. If not specified the
  2442. format is guessed from @var{movie_name} or by probing.
  2443. @item seek_point, sp
  2444. Specifies the seek point in seconds, the frames will be output
  2445. starting from this seek point, the parameter is evaluated with
  2446. @code{av_strtod} so the numerical value may be suffixed by an IS
  2447. postfix. Default value is "0".
  2448. @item stream_index, si
  2449. Specifies the index of the video stream to read. If the value is -1,
  2450. the best suited video stream will be automatically selected. Default
  2451. value is "-1".
  2452. @item loop
  2453. Specifies how many times to read the video stream in sequence.
  2454. If the value is less than 1, the stream will be read again and again.
  2455. Default value is "1".
  2456. Note that when the movie is looped the source timestamps are not
  2457. changed, so it will generate non monotonically increasing timestamps.
  2458. @end table
  2459. This filter allows to overlay a second video on top of main input of
  2460. a filtergraph as shown in this graph:
  2461. @example
  2462. input -----------> deltapts0 --> overlay --> output
  2463. ^
  2464. |
  2465. movie --> scale--> deltapts1 -------+
  2466. @end example
  2467. Some examples follow:
  2468. @example
  2469. # skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  2470. # on top of the input labelled as "in".
  2471. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  2472. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  2473. # read from a video4linux2 device, and overlay it on top of the input
  2474. # labelled as "in"
  2475. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  2476. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  2477. @end example
  2478. @section mptestsrc
  2479. Generate various test patterns, as generated by the MPlayer test filter.
  2480. The size of the generated video is fixed, and is 256x256.
  2481. This source is useful in particular for testing encoding features.
  2482. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  2483. separated by ":". The description of the accepted options follows.
  2484. @table @option
  2485. @item rate, r
  2486. Specify the frame rate of the sourced video, as the number of frames
  2487. generated per second. It has to be a string in the format
  2488. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2489. number or a valid video frame rate abbreviation. The default value is
  2490. "25".
  2491. @item duration, d
  2492. Set the video duration of the sourced video. The accepted syntax is:
  2493. @example
  2494. [-]HH:MM:SS[.m...]
  2495. [-]S+[.m...]
  2496. @end example
  2497. See also the function @code{av_parse_time()}.
  2498. If not specified, or the expressed duration is negative, the video is
  2499. supposed to be generated forever.
  2500. @item test, t
  2501. Set the number or the name of the test to perform. Supported tests are:
  2502. @table @option
  2503. @item dc_luma
  2504. @item dc_chroma
  2505. @item freq_luma
  2506. @item freq_chroma
  2507. @item amp_luma
  2508. @item amp_chroma
  2509. @item cbp
  2510. @item mv
  2511. @item ring1
  2512. @item ring2
  2513. @item all
  2514. @end table
  2515. Default value is "all", which will cycle through the list of all tests.
  2516. @end table
  2517. For example the following:
  2518. @example
  2519. testsrc=t=dc_luma
  2520. @end example
  2521. will generate a "dc_luma" test pattern.
  2522. @section frei0r_src
  2523. Provide a frei0r source.
  2524. To enable compilation of this filter you need to install the frei0r
  2525. header and configure FFmpeg with @code{--enable-frei0r}.
  2526. The source supports the syntax:
  2527. @example
  2528. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  2529. @end example
  2530. @var{size} is the size of the video to generate, may be a string of the
  2531. form @var{width}x@var{height} or a frame size abbreviation.
  2532. @var{rate} is the rate of the video to generate, may be a string of
  2533. the form @var{num}/@var{den} or a frame rate abbreviation.
  2534. @var{src_name} is the name to the frei0r source to load. For more
  2535. information regarding frei0r and how to set the parameters read the
  2536. section @ref{frei0r} in the description of the video filters.
  2537. Some examples follow:
  2538. @example
  2539. # generate a frei0r partik0l source with size 200x200 and frame rate 10
  2540. # which is overlayed on the overlay filter main input
  2541. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  2542. @end example
  2543. @section life
  2544. Generate a life pattern.
  2545. This source is based on a generalization of John Conway's life game.
  2546. The sourced input represents a life grid, each pixel represents a cell
  2547. which can be in one of two possible states, alive or dead. Every cell
  2548. interacts with its eight neighbours, which are the cells that are
  2549. horizontally, vertically, or diagonally adjacent.
  2550. At each interaction the grid evolves according to the adopted rule,
  2551. which specifies the number of neighbor alive cells which will make a
  2552. cell stay alive or born. The @option{rule} option allows to specify
  2553. the rule to adopt.
  2554. This source accepts a list of options in the form of
  2555. @var{key}=@var{value} pairs separated by ":". A description of the
  2556. accepted options follows.
  2557. @table @option
  2558. @item filename, f
  2559. Set the file from which to read the initial grid state. In the file,
  2560. each non-whitespace character is considered an alive cell, and newline
  2561. is used to delimit the end of each row.
  2562. If this option is not specified, the initial grid is generated
  2563. randomly.
  2564. @item rate, r
  2565. Set the video rate, that is the number of frames generated per second.
  2566. Default is 25.
  2567. @item random_fill_ratio, ratio
  2568. Set the random fill ratio for the initial random grid. It is a
  2569. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  2570. It is ignored when a file is specified.
  2571. @item random_seed, seed
  2572. Set the seed for filling the initial random grid, must be an integer
  2573. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2574. set to -1, the filter will try to use a good random seed on a best
  2575. effort basis.
  2576. @item rule
  2577. Set the life rule.
  2578. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  2579. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  2580. @var{NS} specifies the number of alive neighbor cells which make a
  2581. live cell stay alive, and @var{NB} the number of alive neighbor cells
  2582. which make a dead cell to become alive (i.e. to "born").
  2583. "s" and "b" can be used in place of "S" and "B", respectively.
  2584. Alternatively a rule can be specified by an 18-bits integer. The 9
  2585. high order bits are used to encode the next cell state if it is alive
  2586. for each number of neighbor alive cells, the low order bits specify
  2587. the rule for "borning" new cells. Higher order bits encode for an
  2588. higher number of neighbor cells.
  2589. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  2590. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  2591. Default value is "S23/B3", which is the original Conway's game of life
  2592. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  2593. cells, and will born a new cell if there are three alive cells around
  2594. a dead cell.
  2595. @item size, s
  2596. Set the size of the output video.
  2597. If @option{filename} is specified, the size is set by default to the
  2598. same size of the input file. If @option{size} is set, it must contain
  2599. the size specified in the input file, and the initial grid defined in
  2600. that file is centered in the larger resulting area.
  2601. If a filename is not specified, the size value defaults to "320x240"
  2602. (used for a randomly generated initial grid).
  2603. @item stitch
  2604. If set to 1, stitch the left and right grid edges together, and the
  2605. top and bottom edges also. Defaults to 1.
  2606. @item mold
  2607. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  2608. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  2609. value from 0 to 255.
  2610. @item life_color
  2611. Set the color of living (or new born) cells.
  2612. @item death_color
  2613. Set the color of dead cells. If @option{mold} is set, this is the first color
  2614. used to represent a dead cell.
  2615. @item mold_color
  2616. Set mold color, for definitely dead and moldy cells.
  2617. @end table
  2618. @subsection Examples
  2619. @itemize
  2620. @item
  2621. Read a grid from @file{pattern}, and center it on a grid of size
  2622. 300x300 pixels:
  2623. @example
  2624. life=f=pattern:s=300x300
  2625. @end example
  2626. @item
  2627. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  2628. @example
  2629. life=ratio=2/3:s=200x200
  2630. @end example
  2631. @item
  2632. Specify a custom rule for evolving a randomly generated grid:
  2633. @example
  2634. life=rule=S14/B34
  2635. @end example
  2636. @item
  2637. Full example with slow death effect (mold) using @command{ffplay}:
  2638. @example
  2639. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  2640. @end example
  2641. @end itemize
  2642. @section nullsrc, rgbtestsrc, testsrc
  2643. The @code{nullsrc} source returns unprocessed video frames. It is
  2644. mainly useful to be employed in analysis / debugging tools, or as the
  2645. source for filters which ignore the input data.
  2646. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  2647. detecting RGB vs BGR issues. You should see a red, green and blue
  2648. stripe from top to bottom.
  2649. The @code{testsrc} source generates a test video pattern, showing a
  2650. color pattern, a scrolling gradient and a timestamp. This is mainly
  2651. intended for testing purposes.
  2652. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  2653. separated by ":". The description of the accepted options follows.
  2654. @table @option
  2655. @item size, s
  2656. Specify the size of the sourced video, it may be a string of the form
  2657. @var{width}x@var{height}, or the name of a size abbreviation. The
  2658. default value is "320x240".
  2659. @item rate, r
  2660. Specify the frame rate of the sourced video, as the number of frames
  2661. generated per second. It has to be a string in the format
  2662. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2663. number or a valid video frame rate abbreviation. The default value is
  2664. "25".
  2665. @item sar
  2666. Set the sample aspect ratio of the sourced video.
  2667. @item duration, d
  2668. Set the video duration of the sourced video. The accepted syntax is:
  2669. @example
  2670. [-]HH[:MM[:SS[.m...]]]
  2671. [-]S+[.m...]
  2672. @end example
  2673. See also the function @code{av_parse_time()}.
  2674. If not specified, or the expressed duration is negative, the video is
  2675. supposed to be generated forever.
  2676. @item decimals, n
  2677. Set the number of decimals to show in the timestamp, only used in the
  2678. @code{testsrc} source.
  2679. The displayed timestamp value will correspond to the original
  2680. timestamp value multiplied by the power of 10 of the specified
  2681. value. Default value is 0.
  2682. @end table
  2683. For example the following:
  2684. @example
  2685. testsrc=duration=5.3:size=qcif:rate=10
  2686. @end example
  2687. will generate a video with a duration of 5.3 seconds, with size
  2688. 176x144 and a frame rate of 10 frames per second.
  2689. If the input content is to be ignored, @code{nullsrc} can be used. The
  2690. following command generates noise in the luminance plane by employing
  2691. the @code{mp=geq} filter:
  2692. @example
  2693. nullsrc=s=256x256, mp=geq=random(1)*255:128:128
  2694. @end example
  2695. @c man end VIDEO SOURCES
  2696. @chapter Video Sinks
  2697. @c man begin VIDEO SINKS
  2698. Below is a description of the currently available video sinks.
  2699. @section buffersink
  2700. Buffer video frames, and make them available to the end of the filter
  2701. graph.
  2702. This sink is mainly intended for a programmatic use, in particular
  2703. through the interface defined in @file{libavfilter/buffersink.h}.
  2704. It does not require a string parameter in input, but you need to
  2705. specify a pointer to a list of supported pixel formats terminated by
  2706. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  2707. when initializing this sink.
  2708. @section nullsink
  2709. Null video sink, do absolutely nothing with the input video. It is
  2710. mainly useful as a template and to be employed in analysis / debugging
  2711. tools.
  2712. @c man end VIDEO SINKS