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.

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