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.

3543 lines
99KB

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