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.

3591 lines
101KB

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