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.

3701 lines
104KB

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