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.

5867 lines
163KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, it is possible for filters to have multiple inputs and
  5. multiple outputs.
  6. To illustrate the sorts of things that are possible, we can
  7. use a complex filter graph. For example, the following one:
  8. @example
  9. input --> split ---------------------> overlay --> output
  10. | ^
  11. | |
  12. +-----> crop --> vflip -------+
  13. @end example
  14. splits the stream in two streams, sends one stream through the crop filter
  15. and the vflip filter before merging it back with the other stream by
  16. overlaying it on top. You can use the following command to achieve this:
  17. @example
  18. ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
  19. @end example
  20. The result will be that in output the top half of the video is mirrored
  21. onto the bottom half.
  22. Filters are loaded using the @var{-vf} or @var{-af} option passed to
  23. @command{ffmpeg} or to @command{ffplay}. Filters in the same linear
  24. chain are separated by commas. In our example, @var{split,
  25. overlay} are in one linear chain, and @var{crop, vflip} are in
  26. another. The points where the linear chains join are labeled by names
  27. enclosed in square brackets. In our example, that is @var{[T1]} and
  28. @var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
  29. where video is input and output.
  30. Some filters take in input a list of parameters: they are specified
  31. after the filter name and an equal sign, and are separated from each other
  32. by a colon.
  33. There exist so-called @var{source filters} that do not have an
  34. audio/video input, and @var{sink filters} that will not have audio/video
  35. output.
  36. @c man end FILTERING INTRODUCTION
  37. @chapter graph2dot
  38. @c man begin GRAPH2DOT
  39. The @file{graph2dot} program included in the FFmpeg @file{tools}
  40. directory can be used to parse a filter graph description and issue a
  41. corresponding textual representation in the dot language.
  42. Invoke the command:
  43. @example
  44. graph2dot -h
  45. @end example
  46. to see how to use @file{graph2dot}.
  47. You can then pass the dot description to the @file{dot} program (from
  48. the graphviz suite of programs) and obtain a graphical representation
  49. of the filter graph.
  50. For example the sequence of commands:
  51. @example
  52. echo @var{GRAPH_DESCRIPTION} | \
  53. tools/graph2dot -o graph.tmp && \
  54. dot -Tpng graph.tmp -o graph.png && \
  55. display graph.png
  56. @end example
  57. can be used to create and display an image representing the graph
  58. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  59. a complete self-contained graph, with its inputs and outputs explicitly defined.
  60. For example if your command line is of the form:
  61. @example
  62. ffmpeg -i infile -vf scale=640:360 outfile
  63. @end example
  64. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  65. @example
  66. nullsrc,scale=640:360,nullsink
  67. @end example
  68. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  69. filter in order to simulate a specific input file.
  70. @c man end GRAPH2DOT
  71. @chapter Filtergraph description
  72. @c man begin FILTERGRAPH DESCRIPTION
  73. A filtergraph is a directed graph of connected filters. It can contain
  74. cycles, and there can be multiple links between a pair of
  75. filters. Each link has one input pad on one side connecting it to one
  76. filter from which it takes its input, and one output pad on the other
  77. side connecting it to the one filter accepting its output.
  78. Each filter in a filtergraph is an instance of a filter class
  79. registered in the application, which defines the features and the
  80. number of input and output pads of the filter.
  81. A filter with no input pads is called a "source", a filter with no
  82. output pads is called a "sink".
  83. @anchor{Filtergraph syntax}
  84. @section Filtergraph syntax
  85. A filtergraph can be represented using a textual representation, which is
  86. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  87. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  88. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  89. @file{libavfilter/avfiltergraph.h}.
  90. A filterchain consists of a sequence of connected filters, each one
  91. connected to the previous one in the sequence. A filterchain is
  92. represented by a list of ","-separated filter descriptions.
  93. A filtergraph consists of a sequence of filterchains. A sequence of
  94. filterchains is represented by a list of ";"-separated filterchain
  95. descriptions.
  96. A filter is represented by a string of the form:
  97. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  98. @var{filter_name} is the name of the filter class of which the
  99. described filter is an instance of, and has to be the name of one of
  100. the filter classes registered in the program.
  101. The name of the filter class is optionally followed by a string
  102. "=@var{arguments}".
  103. @var{arguments} is a string which contains the parameters used to
  104. initialize the filter instance, and are described in the filter
  105. descriptions below.
  106. The list of arguments can be quoted using the character "'" as initial
  107. and ending mark, and the character '\' for escaping the characters
  108. within the quoted text; otherwise the argument string is considered
  109. terminated when the next special character (belonging to the set
  110. "[]=;,") is encountered.
  111. The name and arguments of the filter are optionally preceded and
  112. followed by a list of link labels.
  113. A link label allows to name a link and associate it to a filter output
  114. or input pad. The preceding labels @var{in_link_1}
  115. ... @var{in_link_N}, are associated to the filter input pads,
  116. the following labels @var{out_link_1} ... @var{out_link_M}, are
  117. associated to the output pads.
  118. When two link labels with the same name are found in the
  119. filtergraph, a link between the corresponding input and output pad is
  120. created.
  121. If an output pad is not labelled, it is linked by default to the first
  122. unlabelled input pad of the next filter in the filterchain.
  123. For example in the filterchain:
  124. @example
  125. nullsrc, split[L1], [L2]overlay, nullsink
  126. @end example
  127. the split filter instance has two output pads, and the overlay filter
  128. instance two input pads. The first output pad of split is labelled
  129. "L1", the first input pad of overlay is labelled "L2", and the second
  130. output pad of split is linked to the second input pad of overlay,
  131. which are both unlabelled.
  132. In a complete filterchain all the unlabelled filter input and output
  133. pads must be connected. A filtergraph is considered valid if all the
  134. filter input and output pads of all the filterchains are connected.
  135. Libavfilter will automatically insert scale filters where format
  136. conversion is required. It is possible to specify swscale flags
  137. for those automatically inserted scalers by prepending
  138. @code{sws_flags=@var{flags};}
  139. to the filtergraph description.
  140. Follows a BNF description for the filtergraph syntax:
  141. @example
  142. @var{NAME} ::= sequence of alphanumeric characters and '_'
  143. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  144. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  145. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  146. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  147. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  148. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  149. @end example
  150. @section Notes on filtergraph escaping
  151. Some filter arguments require the use of special characters, typically
  152. @code{:} to separate key=value pairs in a named options list. In this
  153. case the user should perform a first level escaping when specifying
  154. the filter arguments. For example, consider the following literal
  155. string to be embedded in the @ref{drawtext} filter arguments:
  156. @example
  157. this is a 'string': may contain one, or more, special characters
  158. @end example
  159. Since @code{:} is special for the filter arguments syntax, it needs to
  160. be escaped, so you get:
  161. @example
  162. text=this is a \'string\'\: may contain one, or more, special characters
  163. @end example
  164. A second level of escaping is required when embedding the filter
  165. arguments in a filtergraph description, in order to escape all the
  166. filtergraph special characters. Thus the example above becomes:
  167. @example
  168. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  169. @end example
  170. Finally an additional level of escaping may be needed when writing the
  171. filtergraph description in a shell command, which depends on the
  172. escaping rules of the adopted shell. For example, assuming that
  173. @code{\} is special and needs to be escaped with another @code{\}, the
  174. previous string will finally result in:
  175. @example
  176. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  177. @end example
  178. Sometimes, it might be more convenient to employ quoting in place of
  179. escaping. For example the string:
  180. @example
  181. Caesar: tu quoque, Brute, fili mi
  182. @end example
  183. Can be quoted in the filter arguments as:
  184. @example
  185. text='Caesar: tu quoque, Brute, fili mi'
  186. @end example
  187. And finally inserted in a filtergraph like:
  188. @example
  189. drawtext=text=\'Caesar: tu quoque\, Brute\, fili mi\'
  190. @end example
  191. See the ``Quoting and escaping'' section in the ffmpeg-utils manual
  192. for more information about the escaping and quoting rules adopted by
  193. FFmpeg.
  194. @c man end FILTERGRAPH DESCRIPTION
  195. @chapter Audio Filters
  196. @c man begin AUDIO FILTERS
  197. When you configure your FFmpeg build, you can disable any of the
  198. existing filters using @code{--disable-filters}.
  199. The configure output will show the audio filters included in your
  200. build.
  201. Below is a description of the currently available audio filters.
  202. @section aconvert
  203. Convert the input audio format to the specified formats.
  204. The filter accepts a string of the form:
  205. "@var{sample_format}:@var{channel_layout}".
  206. @var{sample_format} specifies the sample format, and can be a string or the
  207. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  208. suffix for a planar sample format.
  209. @var{channel_layout} specifies the channel layout, and can be a string
  210. or the corresponding number value defined in @file{libavutil/channel_layout.h}.
  211. The special parameter "auto", signifies that the filter will
  212. automatically select the output format depending on the output filter.
  213. Some examples follow.
  214. @itemize
  215. @item
  216. Convert input to float, planar, stereo:
  217. @example
  218. aconvert=fltp:stereo
  219. @end example
  220. @item
  221. Convert input to unsigned 8-bit, automatically select out channel layout:
  222. @example
  223. aconvert=u8:auto
  224. @end example
  225. @end itemize
  226. @section afade
  227. Apply fade-in/out effect to input audio.
  228. The filter accepts parameters as a list of @var{key}=@var{value}
  229. pairs, separated by ":".
  230. A description of the accepted parameters follows.
  231. @table @option
  232. @item type, t
  233. Specify the effect type, can be either @code{in} for fade-in, or
  234. @code{out} for a fade-out effect. Default is @code{in}.
  235. @item start_sample, ss
  236. Specify the number of the start sample for starting to apply the fade
  237. effect. Default is 0.
  238. @item nb_samples, ns
  239. Specify the number of samples for which the fade effect has to last. At
  240. the end of the fade-in effect the output audio will have the same
  241. volume as the input audio, at the end of the fade-out transition
  242. the output audio will be silence. Default is 44100.
  243. @item start_time, st
  244. Specify time in seconds for starting to apply the fade
  245. effect. Default is 0.
  246. If set this option is used instead of @var{start_sample} one.
  247. @item duration, d
  248. Specify the number of seconds for which the fade effect has to last. At
  249. the end of the fade-in effect the output audio will have the same
  250. volume as the input audio, at the end of the fade-out transition
  251. the output audio will be silence. Default is 0.
  252. If set this option is used instead of @var{nb_samples} one.
  253. @item curve
  254. Set cuve for fade transition.
  255. @table @option
  256. @item @var{triangular, linear slope (default)}
  257. @code{tri}
  258. @item @var{quarter of sine wave}
  259. @code{qsin}
  260. @item @var{half of sine wave}
  261. @code{esin}
  262. @item @var{exponential sine wave}
  263. @code{hsin}
  264. @item @var{logarithmic}
  265. @code{log}
  266. @item @var{inverted parabola}
  267. @code{par}
  268. @item @var{quadratic}
  269. @code{qua}
  270. @item @var{cubic}
  271. @code{cub}
  272. @item @var{square root}
  273. @code{squ}
  274. @item @var{cubic root}
  275. @code{cbr}
  276. @end table
  277. @end table
  278. @subsection Examples
  279. @itemize
  280. @item
  281. Fade in first 15 seconds of audio:
  282. @example
  283. afade=t=in:ss=0:d=15
  284. @end example
  285. @item
  286. Fade out last 25 seconds of a 900 seconds audio:
  287. @example
  288. afade=t=out:ss=875:d=25
  289. @end example
  290. @end itemize
  291. @section aformat
  292. Set output format constraints for the input audio. The framework will
  293. negotiate the most appropriate format to minimize conversions.
  294. The filter accepts the following named parameters:
  295. @table @option
  296. @item sample_fmts
  297. A comma-separated list of requested sample formats.
  298. @item sample_rates
  299. A comma-separated list of requested sample rates.
  300. @item channel_layouts
  301. A comma-separated list of requested channel layouts.
  302. @end table
  303. If a parameter is omitted, all values are allowed.
  304. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  305. @example
  306. aformat='sample_fmts=u8,s16:channel_layouts=stereo'
  307. @end example
  308. @section amerge
  309. Merge two or more audio streams into a single multi-channel stream.
  310. The filter accepts the following named options:
  311. @table @option
  312. @item inputs
  313. Set the number of inputs. Default is 2.
  314. @end table
  315. If the channel layouts of the inputs are disjoint, and therefore compatible,
  316. the channel layout of the output will be set accordingly and the channels
  317. will be reordered as necessary. If the channel layouts of the inputs are not
  318. disjoint, the output will have all the channels of the first input then all
  319. the channels of the second input, in that order, and the channel layout of
  320. the output will be the default value corresponding to the total number of
  321. channels.
  322. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  323. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  324. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  325. first input, b1 is the first channel of the second input).
  326. On the other hand, if both input are in stereo, the output channels will be
  327. in the default order: a1, a2, b1, b2, and the channel layout will be
  328. arbitrarily set to 4.0, which may or may not be the expected value.
  329. All inputs must have the same sample rate, and format.
  330. If inputs do not have the same duration, the output will stop with the
  331. shortest.
  332. Example: merge two mono files into a stereo stream:
  333. @example
  334. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  335. @end example
  336. Example: multiple merges:
  337. @example
  338. ffmpeg -f lavfi -i "
  339. amovie=input.mkv:si=0 [a0];
  340. amovie=input.mkv:si=1 [a1];
  341. amovie=input.mkv:si=2 [a2];
  342. amovie=input.mkv:si=3 [a3];
  343. amovie=input.mkv:si=4 [a4];
  344. amovie=input.mkv:si=5 [a5];
  345. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  346. @end example
  347. @section amix
  348. Mixes multiple audio inputs into a single output.
  349. For example
  350. @example
  351. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  352. @end example
  353. will mix 3 input audio streams to a single output with the same duration as the
  354. first input and a dropout transition time of 3 seconds.
  355. The filter accepts the following named parameters:
  356. @table @option
  357. @item inputs
  358. Number of inputs. If unspecified, it defaults to 2.
  359. @item duration
  360. How to determine the end-of-stream.
  361. @table @option
  362. @item longest
  363. Duration of longest input. (default)
  364. @item shortest
  365. Duration of shortest input.
  366. @item first
  367. Duration of first input.
  368. @end table
  369. @item dropout_transition
  370. Transition time, in seconds, for volume renormalization when an input
  371. stream ends. The default value is 2 seconds.
  372. @end table
  373. @section anull
  374. Pass the audio source unchanged to the output.
  375. @section apad
  376. Pad the end of a audio stream with silence, this can be used together with
  377. -shortest to extend audio streams to the same length as the video stream.
  378. @anchor{aresample}
  379. @section aresample
  380. Resample the input audio to the specified parameters, using the
  381. libswresample library. If none are specified then the filter will
  382. automatically convert between its input and output.
  383. This filter is also able to stretch/squeeze the audio data to make it match
  384. the timestamps or to inject silence / cut out audio to make it match the
  385. timestamps, do a combination of both or do neither.
  386. The filter accepts the syntax
  387. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  388. expresses a sample rate and @var{resampler_options} is a list of
  389. @var{key}=@var{value} pairs, separated by ":". See the
  390. ffmpeg-resampler manual for the complete list of supported options.
  391. For example, to resample the input audio to 44100Hz:
  392. @example
  393. aresample=44100
  394. @end example
  395. To stretch/squeeze samples to the given timestamps, with a maximum of 1000
  396. samples per second compensation:
  397. @example
  398. aresample=async=1000
  399. @end example
  400. @section asetnsamples
  401. Set the number of samples per each output audio frame.
  402. The last output packet may contain a different number of samples, as
  403. the filter will flush all the remaining samples when the input audio
  404. signal its end.
  405. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  406. separated by ":".
  407. @table @option
  408. @item nb_out_samples, n
  409. Set the number of frames per each output audio frame. The number is
  410. intended as the number of samples @emph{per each channel}.
  411. Default value is 1024.
  412. @item pad, p
  413. If set to 1, the filter will pad the last audio frame with zeroes, so
  414. that the last frame will contain the same number of samples as the
  415. previous ones. Default value is 1.
  416. @end table
  417. For example, to set the number of per-frame samples to 1234 and
  418. disable padding for the last frame, use:
  419. @example
  420. asetnsamples=n=1234:p=0
  421. @end example
  422. @section ashowinfo
  423. Show a line containing various information for each input audio frame.
  424. The input audio is not modified.
  425. The shown line contains a sequence of key/value pairs of the form
  426. @var{key}:@var{value}.
  427. A description of each shown parameter follows:
  428. @table @option
  429. @item n
  430. sequential number of the input frame, starting from 0
  431. @item pts
  432. Presentation timestamp of the input frame, in time base units; the time base
  433. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  434. @item pts_time
  435. presentation timestamp of the input frame in seconds
  436. @item pos
  437. position of the frame in the input stream, -1 if this information in
  438. unavailable and/or meaningless (for example in case of synthetic audio)
  439. @item fmt
  440. sample format
  441. @item chlayout
  442. channel layout
  443. @item rate
  444. sample rate for the audio frame
  445. @item nb_samples
  446. number of samples (per channel) in the frame
  447. @item checksum
  448. Adler-32 checksum (printed in hexadecimal) of the audio data. For planar audio
  449. the data is treated as if all the planes were concatenated.
  450. @item plane_checksums
  451. A list of Adler-32 checksums for each data plane.
  452. @end table
  453. @section asplit
  454. Split input audio into several identical outputs.
  455. The filter accepts a single parameter which specifies the number of outputs. If
  456. unspecified, it defaults to 2.
  457. For example:
  458. @example
  459. [in] asplit [out0][out1]
  460. @end example
  461. will create two separate outputs from the same input.
  462. To create 3 or more outputs, you need to specify the number of
  463. outputs, like in:
  464. @example
  465. [in] asplit=3 [out0][out1][out2]
  466. @end example
  467. @example
  468. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  469. @end example
  470. will create 5 copies of the input audio.
  471. @section astreamsync
  472. Forward two audio streams and control the order the buffers are forwarded.
  473. The argument to the filter is an expression deciding which stream should be
  474. forwarded next: if the result is negative, the first stream is forwarded; if
  475. the result is positive or zero, the second stream is forwarded. It can use
  476. the following variables:
  477. @table @var
  478. @item b1 b2
  479. number of buffers forwarded so far on each stream
  480. @item s1 s2
  481. number of samples forwarded so far on each stream
  482. @item t1 t2
  483. current timestamp of each stream
  484. @end table
  485. The default value is @code{t1-t2}, which means to always forward the stream
  486. that has a smaller timestamp.
  487. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  488. input, while avoiding too much of a desynchronization:
  489. @example
  490. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  491. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  492. [a2] [b2] amerge
  493. @end example
  494. @section atempo
  495. Adjust audio tempo.
  496. The filter accepts exactly one parameter, the audio tempo. If not
  497. specified then the filter will assume nominal 1.0 tempo. Tempo must
  498. be in the [0.5, 2.0] range.
  499. For example, to slow down audio to 80% tempo:
  500. @example
  501. atempo=0.8
  502. @end example
  503. For example, to speed up audio to 125% tempo:
  504. @example
  505. atempo=1.25
  506. @end example
  507. @section earwax
  508. Make audio easier to listen to on headphones.
  509. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  510. so that when listened to on headphones the stereo image is moved from
  511. inside your head (standard for headphones) to outside and in front of
  512. the listener (standard for speakers).
  513. Ported from SoX.
  514. @section pan
  515. Mix channels with specific gain levels. The filter accepts the output
  516. channel layout followed by a set of channels definitions.
  517. This filter is also designed to remap efficiently the channels of an audio
  518. stream.
  519. The filter accepts parameters of the form:
  520. "@var{l}:@var{outdef}:@var{outdef}:..."
  521. @table @option
  522. @item l
  523. output channel layout or number of channels
  524. @item outdef
  525. output channel specification, of the form:
  526. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  527. @item out_name
  528. output channel to define, either a channel name (FL, FR, etc.) or a channel
  529. number (c0, c1, etc.)
  530. @item gain
  531. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  532. @item in_name
  533. input channel to use, see out_name for details; it is not possible to mix
  534. named and numbered input channels
  535. @end table
  536. If the `=' in a channel specification is replaced by `<', then the gains for
  537. that specification will be renormalized so that the total is 1, thus
  538. avoiding clipping noise.
  539. @subsection Mixing examples
  540. For example, if you want to down-mix from stereo to mono, but with a bigger
  541. factor for the left channel:
  542. @example
  543. pan=1:c0=0.9*c0+0.1*c1
  544. @end example
  545. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  546. 7-channels surround:
  547. @example
  548. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  549. @end example
  550. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  551. that should be preferred (see "-ac" option) unless you have very specific
  552. needs.
  553. @subsection Remapping examples
  554. The channel remapping will be effective if, and only if:
  555. @itemize
  556. @item gain coefficients are zeroes or ones,
  557. @item only one input per channel output,
  558. @end itemize
  559. If all these conditions are satisfied, the filter will notify the user ("Pure
  560. channel mapping detected"), and use an optimized and lossless method to do the
  561. remapping.
  562. For example, if you have a 5.1 source and want a stereo audio stream by
  563. dropping the extra channels:
  564. @example
  565. pan="stereo: c0=FL : c1=FR"
  566. @end example
  567. Given the same source, you can also switch front left and front right channels
  568. and keep the input channel layout:
  569. @example
  570. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  571. @end example
  572. If the input is a stereo audio stream, you can mute the front left channel (and
  573. still keep the stereo channel layout) with:
  574. @example
  575. pan="stereo:c1=c1"
  576. @end example
  577. Still with a stereo audio stream input, you can copy the right channel in both
  578. front left and right:
  579. @example
  580. pan="stereo: c0=FR : c1=FR"
  581. @end example
  582. @section silencedetect
  583. Detect silence in an audio stream.
  584. This filter logs a message when it detects that the input audio volume is less
  585. or equal to a noise tolerance value for a duration greater or equal to the
  586. minimum detected noise duration.
  587. The printed times and duration are expressed in seconds.
  588. @table @option
  589. @item duration, d
  590. Set silence duration until notification (default is 2 seconds).
  591. @item noise, n
  592. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  593. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  594. @end table
  595. Detect 5 seconds of silence with -50dB noise tolerance:
  596. @example
  597. silencedetect=n=-50dB:d=5
  598. @end example
  599. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  600. tolerance in @file{silence.mp3}:
  601. @example
  602. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  603. @end example
  604. @section asyncts
  605. Synchronize audio data with timestamps by squeezing/stretching it and/or
  606. dropping samples/adding silence when needed.
  607. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  608. The filter accepts the following named parameters:
  609. @table @option
  610. @item compensate
  611. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  612. by default. When disabled, time gaps are covered with silence.
  613. @item min_delta
  614. Minimum difference between timestamps and audio data (in seconds) to trigger
  615. adding/dropping samples. Default value is 0.1. If you get non-perfect sync with
  616. this filter, try setting this parameter to 0.
  617. @item max_comp
  618. Maximum compensation in samples per second. Relevant only with compensate=1.
  619. Default value 500.
  620. @item first_pts
  621. Assume the first pts should be this value. The time base is 1 / sample rate.
  622. This allows for padding/trimming at the start of stream. By default, no
  623. assumption is made about the first frame's expected pts, so no padding or
  624. trimming is done. For example, this could be set to 0 to pad the beginning with
  625. silence if an audio stream starts after the video stream or to trim any samples
  626. with a negative pts due to encoder delay.
  627. @end table
  628. @section channelsplit
  629. Split each channel in input audio stream into a separate output stream.
  630. This filter accepts the following named parameters:
  631. @table @option
  632. @item channel_layout
  633. Channel layout of the input stream. Default is "stereo".
  634. @end table
  635. For example, assuming a stereo input MP3 file
  636. @example
  637. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  638. @end example
  639. will create an output Matroska file with two audio streams, one containing only
  640. the left channel and the other the right channel.
  641. To split a 5.1 WAV file into per-channel files
  642. @example
  643. ffmpeg -i in.wav -filter_complex
  644. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  645. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  646. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  647. side_right.wav
  648. @end example
  649. @section channelmap
  650. Remap input channels to new locations.
  651. This filter accepts the following named parameters:
  652. @table @option
  653. @item channel_layout
  654. Channel layout of the output stream.
  655. @item map
  656. Map channels from input to output. The argument is a comma-separated list of
  657. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  658. @var{in_channel} form. @var{in_channel} can be either the name of the input
  659. channel (e.g. FL for front left) or its index in the input channel layout.
  660. @var{out_channel} is the name of the output channel or its index in the output
  661. channel layout. If @var{out_channel} is not given then it is implicitly an
  662. index, starting with zero and increasing by one for each mapping.
  663. @end table
  664. If no mapping is present, the filter will implicitly map input channels to
  665. output channels preserving index.
  666. For example, assuming a 5.1+downmix input MOV file
  667. @example
  668. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav
  669. @end example
  670. will create an output WAV file tagged as stereo from the downmix channels of
  671. the input.
  672. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  673. @example
  674. ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav
  675. @end example
  676. @section join
  677. Join multiple input streams into one multi-channel stream.
  678. The filter accepts the following named parameters:
  679. @table @option
  680. @item inputs
  681. Number of input streams. Defaults to 2.
  682. @item channel_layout
  683. Desired output channel layout. Defaults to stereo.
  684. @item map
  685. Map channels from inputs to output. The argument is a comma-separated list of
  686. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  687. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  688. can be either the name of the input channel (e.g. FL for front left) or its
  689. index in the specified input stream. @var{out_channel} is the name of the output
  690. channel.
  691. @end table
  692. The filter will attempt to guess the mappings when those are not specified
  693. explicitly. It does so by first trying to find an unused matching input channel
  694. and if that fails it picks the first unused input channel.
  695. E.g. to join 3 inputs (with properly set channel layouts)
  696. @example
  697. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  698. @end example
  699. To build a 5.1 output from 6 single-channel streams:
  700. @example
  701. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  702. 'join=inputs=6:channel_layout=5.1:map=0.0-FL\,1.0-FR\,2.0-FC\,3.0-SL\,4.0-SR\,5.0-LFE'
  703. out
  704. @end example
  705. @section resample
  706. Convert the audio sample format, sample rate and channel layout. This filter is
  707. not meant to be used directly.
  708. @section volume
  709. Adjust the input audio volume.
  710. The filter accepts the following named parameters. If the key of the
  711. first options is omitted, the arguments are interpreted according to
  712. the following syntax:
  713. @example
  714. volume=@var{volume}:@var{precision}
  715. @end example
  716. @table @option
  717. @item volume
  718. Expresses how the audio volume will be increased or decreased.
  719. Output values are clipped to the maximum value.
  720. The output audio volume is given by the relation:
  721. @example
  722. @var{output_volume} = @var{volume} * @var{input_volume}
  723. @end example
  724. Default value for @var{volume} is 1.0.
  725. @item precision
  726. Set the mathematical precision.
  727. This determines which input sample formats will be allowed, which affects the
  728. precision of the volume scaling.
  729. @table @option
  730. @item fixed
  731. 8-bit fixed-point; limits input sample format to U8, S16, and S32.
  732. @item float
  733. 32-bit floating-point; limits input sample format to FLT. (default)
  734. @item double
  735. 64-bit floating-point; limits input sample format to DBL.
  736. @end table
  737. @end table
  738. @subsection Examples
  739. @itemize
  740. @item
  741. Halve the input audio volume:
  742. @example
  743. volume=volume=0.5
  744. volume=volume=1/2
  745. volume=volume=-6.0206dB
  746. @end example
  747. In all the above example the named key for @option{volume} can be
  748. omitted, for example like in:
  749. @example
  750. volume=0.5
  751. @end example
  752. @item
  753. Increase input audio power by 6 decibels using fixed-point precision:
  754. @example
  755. volume=volume=6dB:precision=fixed
  756. @end example
  757. @end itemize
  758. @section volumedetect
  759. Detect the volume of the input video.
  760. The filter has no parameters. The input is not modified. Statistics about
  761. the volume will be printed in the log when the input stream end is reached.
  762. In particular it will show the mean volume (root mean square), maximum
  763. volume (on a per-sample basis), and the beginning of an histogram of the
  764. registered volume values (from the maximum value to a cumulated 1/1000 of
  765. the samples).
  766. All volumes are in decibels relative to the maximum PCM value.
  767. Here is an excerpt of the output:
  768. @example
  769. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  770. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  771. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  772. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  773. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  774. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  775. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  776. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  777. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  778. @end example
  779. It means that:
  780. @itemize
  781. @item
  782. The mean square energy is approximately -27 dB, or 10^-2.7.
  783. @item
  784. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  785. @item
  786. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  787. @end itemize
  788. In other words, raising the volume by +4 dB does not cause any clipping,
  789. raising it by +5 dB causes clipping for 6 samples, etc.
  790. @c man end AUDIO FILTERS
  791. @chapter Audio Sources
  792. @c man begin AUDIO SOURCES
  793. Below is a description of the currently available audio sources.
  794. @section abuffer
  795. Buffer audio frames, and make them available to the filter chain.
  796. This source is mainly intended for a programmatic use, in particular
  797. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  798. It accepts the following mandatory parameters:
  799. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  800. @table @option
  801. @item sample_rate
  802. The sample rate of the incoming audio buffers.
  803. @item sample_fmt
  804. The sample format of the incoming audio buffers.
  805. Either a sample format name or its corresponging integer representation from
  806. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  807. @item channel_layout
  808. The channel layout of the incoming audio buffers.
  809. Either a channel layout name from channel_layout_map in
  810. @file{libavutil/channel_layout.c} or its corresponding integer representation
  811. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  812. @item channels
  813. The number of channels of the incoming audio buffers.
  814. If both @var{channels} and @var{channel_layout} are specified, then they
  815. must be consistent.
  816. @end table
  817. For example:
  818. @example
  819. abuffer=44100:s16p:stereo
  820. @end example
  821. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  822. Since the sample format with name "s16p" corresponds to the number
  823. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  824. equivalent to:
  825. @example
  826. abuffer=44100:6:0x3
  827. @end example
  828. @section aevalsrc
  829. Generate an audio signal specified by an expression.
  830. This source accepts in input one or more expressions (one for each
  831. channel), which are evaluated and used to generate a corresponding
  832. audio signal.
  833. It accepts the syntax: @var{exprs}[::@var{options}].
  834. @var{exprs} is a list of expressions separated by ":", one for each
  835. separate channel. In case the @var{channel_layout} is not
  836. specified, the selected channel layout depends on the number of
  837. provided expressions.
  838. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  839. separated by ":".
  840. The description of the accepted options follows.
  841. @table @option
  842. @item channel_layout, c
  843. Set the channel layout. The number of channels in the specified layout
  844. must be equal to the number of specified expressions.
  845. @item duration, d
  846. Set the minimum duration of the sourced audio. See the function
  847. @code{av_parse_time()} for the accepted format.
  848. Note that the resulting duration may be greater than the specified
  849. duration, as the generated audio is always cut at the end of a
  850. complete frame.
  851. If not specified, or the expressed duration is negative, the audio is
  852. supposed to be generated forever.
  853. @item nb_samples, n
  854. Set the number of samples per channel per each output frame,
  855. default to 1024.
  856. @item sample_rate, s
  857. Specify the sample rate, default to 44100.
  858. @end table
  859. Each expression in @var{exprs} can contain the following constants:
  860. @table @option
  861. @item n
  862. number of the evaluated sample, starting from 0
  863. @item t
  864. time of the evaluated sample expressed in seconds, starting from 0
  865. @item s
  866. sample rate
  867. @end table
  868. @subsection Examples
  869. @itemize
  870. @item
  871. Generate silence:
  872. @example
  873. aevalsrc=0
  874. @end example
  875. @item
  876. Generate a sin signal with frequency of 440 Hz, set sample rate to
  877. 8000 Hz:
  878. @example
  879. aevalsrc="sin(440*2*PI*t)::s=8000"
  880. @end example
  881. @item
  882. Generate a two channels signal, specify the channel layout (Front
  883. Center + Back Center) explicitly:
  884. @example
  885. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  886. @end example
  887. @item
  888. Generate white noise:
  889. @example
  890. aevalsrc="-2+random(0)"
  891. @end example
  892. @item
  893. Generate an amplitude modulated signal:
  894. @example
  895. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  896. @end example
  897. @item
  898. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  899. @example
  900. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  901. @end example
  902. @end itemize
  903. @section anullsrc
  904. Null audio source, return unprocessed audio frames. It is mainly useful
  905. as a template and to be employed in analysis / debugging tools, or as
  906. the source for filters which ignore the input data (for example the sox
  907. synth filter).
  908. It accepts an optional sequence of @var{key}=@var{value} pairs,
  909. separated by ":".
  910. The description of the accepted options follows.
  911. @table @option
  912. @item sample_rate, s
  913. Specify the sample rate, and defaults to 44100.
  914. @item channel_layout, cl
  915. Specify the channel layout, and can be either an integer or a string
  916. representing a channel layout. The default value of @var{channel_layout}
  917. is "stereo".
  918. Check the channel_layout_map definition in
  919. @file{libavutil/channel_layout.c} for the mapping between strings and
  920. channel layout values.
  921. @item nb_samples, n
  922. Set the number of samples per requested frames.
  923. @end table
  924. Follow some examples:
  925. @example
  926. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  927. anullsrc=r=48000:cl=4
  928. # same as
  929. anullsrc=r=48000:cl=mono
  930. @end example
  931. @section abuffer
  932. Buffer audio frames, and make them available to the filter chain.
  933. This source is not intended to be part of user-supplied graph descriptions but
  934. for insertion by calling programs through the interface defined in
  935. @file{libavfilter/buffersrc.h}.
  936. It accepts the following named parameters:
  937. @table @option
  938. @item time_base
  939. Timebase which will be used for timestamps of submitted frames. It must be
  940. either a floating-point number or in @var{numerator}/@var{denominator} form.
  941. @item sample_rate
  942. Audio sample rate.
  943. @item sample_fmt
  944. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  945. @item channel_layout
  946. Channel layout of the audio data, in the form that can be accepted by
  947. @code{av_get_channel_layout()}.
  948. @end table
  949. All the parameters need to be explicitly defined.
  950. @section flite
  951. Synthesize a voice utterance using the libflite library.
  952. To enable compilation of this filter you need to configure FFmpeg with
  953. @code{--enable-libflite}.
  954. Note that the flite library is not thread-safe.
  955. The source accepts parameters as a list of @var{key}=@var{value} pairs,
  956. separated by ":".
  957. The description of the accepted parameters follows.
  958. @table @option
  959. @item list_voices
  960. If set to 1, list the names of the available voices and exit
  961. immediately. Default value is 0.
  962. @item nb_samples, n
  963. Set the maximum number of samples per frame. Default value is 512.
  964. @item textfile
  965. Set the filename containing the text to speak.
  966. @item text
  967. Set the text to speak.
  968. @item voice, v
  969. Set the voice to use for the speech synthesis. Default value is
  970. @code{kal}. See also the @var{list_voices} option.
  971. @end table
  972. @subsection Examples
  973. @itemize
  974. @item
  975. Read from file @file{speech.txt}, and synthetize the text using the
  976. standard flite voice:
  977. @example
  978. flite=textfile=speech.txt
  979. @end example
  980. @item
  981. Read the specified text selecting the @code{slt} voice:
  982. @example
  983. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  984. @end example
  985. @item
  986. Input text to ffmpeg:
  987. @example
  988. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  989. @end example
  990. @item
  991. Make @file{ffplay} speak the specified text, using @code{flite} and
  992. the @code{lavfi} device:
  993. @example
  994. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  995. @end example
  996. @end itemize
  997. For more information about libflite, check:
  998. @url{http://www.speech.cs.cmu.edu/flite/}
  999. @c man end AUDIO SOURCES
  1000. @chapter Audio Sinks
  1001. @c man begin AUDIO SINKS
  1002. Below is a description of the currently available audio sinks.
  1003. @section abuffersink
  1004. Buffer audio frames, and make them available to the end of filter chain.
  1005. This sink is mainly intended for programmatic use, in particular
  1006. through the interface defined in @file{libavfilter/buffersink.h}.
  1007. It requires a pointer to an AVABufferSinkContext structure, which
  1008. defines the incoming buffers' formats, to be passed as the opaque
  1009. parameter to @code{avfilter_init_filter} for initialization.
  1010. @section anullsink
  1011. Null audio sink, do absolutely nothing with the input audio. It is
  1012. mainly useful as a template and to be employed in analysis / debugging
  1013. tools.
  1014. @section abuffersink
  1015. This sink is intended for programmatic use. Frames that arrive on this sink can
  1016. be retrieved by the calling program using the interface defined in
  1017. @file{libavfilter/buffersink.h}.
  1018. This filter accepts no parameters.
  1019. @c man end AUDIO SINKS
  1020. @chapter Video Filters
  1021. @c man begin VIDEO FILTERS
  1022. When you configure your FFmpeg build, you can disable any of the
  1023. existing filters using @code{--disable-filters}.
  1024. The configure output will show the video filters included in your
  1025. build.
  1026. Below is a description of the currently available video filters.
  1027. @section alphaextract
  1028. Extract the alpha component from the input as a grayscale video. This
  1029. is especially useful with the @var{alphamerge} filter.
  1030. @section alphamerge
  1031. Add or replace the alpha component of the primary input with the
  1032. grayscale value of a second input. This is intended for use with
  1033. @var{alphaextract} to allow the transmission or storage of frame
  1034. sequences that have alpha in a format that doesn't support an alpha
  1035. channel.
  1036. For example, to reconstruct full frames from a normal YUV-encoded video
  1037. and a separate video created with @var{alphaextract}, you might use:
  1038. @example
  1039. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  1040. @end example
  1041. Since this filter is designed for reconstruction, it operates on frame
  1042. sequences without considering timestamps, and terminates when either
  1043. input reaches end of stream. This will cause problems if your encoding
  1044. pipeline drops frames. If you're trying to apply an image as an
  1045. overlay to a video stream, consider the @var{overlay} filter instead.
  1046. @section ass
  1047. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  1048. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  1049. Substation Alpha) subtitles files.
  1050. @section bbox
  1051. Compute the bounding box for the non-black pixels in the input frame
  1052. luminance plane.
  1053. This filter computes the bounding box containing all the pixels with a
  1054. luminance value greater than the minimum allowed value.
  1055. The parameters describing the bounding box are printed on the filter
  1056. log.
  1057. @section blackdetect
  1058. Detect video intervals that are (almost) completely black. Can be
  1059. useful to detect chapter transitions, commercials, or invalid
  1060. recordings. Output lines contains the time for the start, end and
  1061. duration of the detected black interval expressed in seconds.
  1062. In order to display the output lines, you need to set the loglevel at
  1063. least to the AV_LOG_INFO value.
  1064. This filter accepts a list of options in the form of
  1065. @var{key}=@var{value} pairs separated by ":". A description of the
  1066. accepted options follows.
  1067. @table @option
  1068. @item black_min_duration, d
  1069. Set the minimum detected black duration expressed in seconds. It must
  1070. be a non-negative floating point number.
  1071. Default value is 2.0.
  1072. @item picture_black_ratio_th, pic_th
  1073. Set the threshold for considering a picture "black".
  1074. Express the minimum value for the ratio:
  1075. @example
  1076. @var{nb_black_pixels} / @var{nb_pixels}
  1077. @end example
  1078. for which a picture is considered black.
  1079. Default value is 0.98.
  1080. @item pixel_black_th, pix_th
  1081. Set the threshold for considering a pixel "black".
  1082. The threshold expresses the maximum pixel luminance value for which a
  1083. pixel is considered "black". The provided value is scaled according to
  1084. the following equation:
  1085. @example
  1086. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1087. @end example
  1088. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1089. the input video format, the range is [0-255] for YUV full-range
  1090. formats and [16-235] for YUV non full-range formats.
  1091. Default value is 0.10.
  1092. @end table
  1093. The following example sets the maximum pixel threshold to the minimum
  1094. value, and detects only black intervals of 2 or more seconds:
  1095. @example
  1096. blackdetect=d=2:pix_th=0.00
  1097. @end example
  1098. @section blackframe
  1099. Detect frames that are (almost) completely black. Can be useful to
  1100. detect chapter transitions or commercials. Output lines consist of
  1101. the frame number of the detected frame, the percentage of blackness,
  1102. the position in the file if known or -1 and the timestamp in seconds.
  1103. In order to display the output lines, you need to set the loglevel at
  1104. least to the AV_LOG_INFO value.
  1105. The filter accepts the syntax:
  1106. @example
  1107. blackframe[=@var{amount}:[@var{threshold}]]
  1108. @end example
  1109. @var{amount} is the percentage of the pixels that have to be below the
  1110. threshold, and defaults to 98.
  1111. @var{threshold} is the threshold below which a pixel value is
  1112. considered black, and defaults to 32.
  1113. @section boxblur
  1114. Apply boxblur algorithm to the input video.
  1115. This filter accepts the parameters:
  1116. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  1117. Chroma and alpha parameters are optional, if not specified they default
  1118. to the corresponding values set for @var{luma_radius} and
  1119. @var{luma_power}.
  1120. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  1121. the radius in pixels of the box used for blurring the corresponding
  1122. input plane. They are expressions, and can contain the following
  1123. constants:
  1124. @table @option
  1125. @item w, h
  1126. the input width and height in pixels
  1127. @item cw, ch
  1128. the input chroma image width and height in pixels
  1129. @item hsub, vsub
  1130. horizontal and vertical chroma subsample values. For example for the
  1131. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1132. @end table
  1133. The radius must be a non-negative number, and must not be greater than
  1134. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  1135. and of @code{min(cw,ch)/2} for the chroma planes.
  1136. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  1137. how many times the boxblur filter is applied to the corresponding
  1138. plane.
  1139. Some examples follow:
  1140. @itemize
  1141. @item
  1142. Apply a boxblur filter with luma, chroma, and alpha radius
  1143. set to 2:
  1144. @example
  1145. boxblur=2:1
  1146. @end example
  1147. @item
  1148. Set luma radius to 2, alpha and chroma radius to 0
  1149. @example
  1150. boxblur=2:1:0:0:0:0
  1151. @end example
  1152. @item
  1153. Set luma and chroma radius to a fraction of the video dimension
  1154. @example
  1155. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  1156. @end example
  1157. @end itemize
  1158. @section colormatrix
  1159. The colormatrix filter allows conversion between any of the following color
  1160. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  1161. and FCC (@var{fcc}).
  1162. The syntax of the parameters is @var{source}:@var{destination}:
  1163. @example
  1164. colormatrix=bt601:smpte240m
  1165. @end example
  1166. @section copy
  1167. Copy the input source unchanged to the output. Mainly useful for
  1168. testing purposes.
  1169. @section crop
  1170. Crop the input video.
  1171. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  1172. separated by ':'. If the key of the first options is omitted, the
  1173. arguments are interpreted according to the syntax
  1174. @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}.
  1175. A description of the accepted options follows:
  1176. @table @option
  1177. @item w, out_w
  1178. Set the crop area width. It defaults to @code{iw}.
  1179. This expression is evaluated only once during the filter
  1180. configuration.
  1181. @item h, out_h
  1182. Set the crop area width. It defaults to @code{ih}.
  1183. This expression is evaluated only once during the filter
  1184. configuration.
  1185. @item x
  1186. Set the expression for the x top-left coordinate of the cropped area.
  1187. It defaults to @code{(in_w-out_w)/2}.
  1188. This expression is evaluated per-frame.
  1189. @item y
  1190. Set the expression for the y top-left coordinate of the cropped area.
  1191. It defaults to @code{(in_h-out_h)/2}.
  1192. This expression is evaluated per-frame.
  1193. @item keep_aspect
  1194. If set to 1 will force the output display aspect ratio
  1195. to be the same of the input, by changing the output sample aspect
  1196. ratio. It defaults to 0.
  1197. @end table
  1198. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1199. expressions containing the following constants:
  1200. @table @option
  1201. @item x, y
  1202. the computed values for @var{x} and @var{y}. They are evaluated for
  1203. each new frame.
  1204. @item in_w, in_h
  1205. the input width and height
  1206. @item iw, ih
  1207. same as @var{in_w} and @var{in_h}
  1208. @item out_w, out_h
  1209. the output (cropped) width and height
  1210. @item ow, oh
  1211. same as @var{out_w} and @var{out_h}
  1212. @item a
  1213. same as @var{iw} / @var{ih}
  1214. @item sar
  1215. input sample aspect ratio
  1216. @item dar
  1217. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1218. @item hsub, vsub
  1219. horizontal and vertical chroma subsample values. For example for the
  1220. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1221. @item n
  1222. the number of input frame, starting from 0
  1223. @item pos
  1224. the position in the file of the input frame, NAN if unknown
  1225. @item t
  1226. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1227. @end table
  1228. The expression for @var{out_w} may depend on the value of @var{out_h},
  1229. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1230. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1231. evaluated after @var{out_w} and @var{out_h}.
  1232. The @var{x} and @var{y} parameters specify the expressions for the
  1233. position of the top-left corner of the output (non-cropped) area. They
  1234. are evaluated for each frame. If the evaluated value is not valid, it
  1235. is approximated to the nearest valid value.
  1236. The expression for @var{x} may depend on @var{y}, and the expression
  1237. for @var{y} may depend on @var{x}.
  1238. @subsection Examples
  1239. @itemize
  1240. @item
  1241. Crop area with size 100x100 at position (12,34).
  1242. @example
  1243. crop=100:100:12:34
  1244. @end example
  1245. Using named options, the example above becomes:
  1246. @example
  1247. crop=w=100:h=100:x=12:y=34
  1248. @end example
  1249. @item
  1250. Crop the central input area with size 100x100:
  1251. @example
  1252. crop=100:100
  1253. @end example
  1254. @item
  1255. Crop the central input area with size 2/3 of the input video:
  1256. @example
  1257. crop=2/3*in_w:2/3*in_h
  1258. @end example
  1259. @item
  1260. Crop the input video central square:
  1261. @example
  1262. crop=in_h
  1263. @end example
  1264. @item
  1265. Delimit the rectangle with the top-left corner placed at position
  1266. 100:100 and the right-bottom corner corresponding to the right-bottom
  1267. corner of the input image:
  1268. @example
  1269. crop=in_w-100:in_h-100:100:100
  1270. @end example
  1271. @item
  1272. Crop 10 pixels from the left and right borders, and 20 pixels from
  1273. the top and bottom borders
  1274. @example
  1275. crop=in_w-2*10:in_h-2*20
  1276. @end example
  1277. @item
  1278. Keep only the bottom right quarter of the input image:
  1279. @example
  1280. crop=in_w/2:in_h/2:in_w/2:in_h/2
  1281. @end example
  1282. @item
  1283. Crop height for getting Greek harmony:
  1284. @example
  1285. crop=in_w:1/PHI*in_w
  1286. @end example
  1287. @item
  1288. Appply trembling effect:
  1289. @example
  1290. 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)
  1291. @end example
  1292. @item
  1293. Apply erratic camera effect depending on timestamp:
  1294. @example
  1295. 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)"
  1296. @end example
  1297. @item
  1298. Set x depending on the value of y:
  1299. @example
  1300. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  1301. @end example
  1302. @end itemize
  1303. @section cropdetect
  1304. Auto-detect crop size.
  1305. Calculate necessary cropping parameters and prints the recommended
  1306. parameters through the logging system. The detected dimensions
  1307. correspond to the non-black area of the input video.
  1308. It accepts the syntax:
  1309. @example
  1310. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  1311. @end example
  1312. @table @option
  1313. @item limit
  1314. Threshold, which can be optionally specified from nothing (0) to
  1315. everything (255), defaults to 24.
  1316. @item round
  1317. Value which the width/height should be divisible by, defaults to
  1318. 16. The offset is automatically adjusted to center the video. Use 2 to
  1319. get only even dimensions (needed for 4:2:2 video). 16 is best when
  1320. encoding to most video codecs.
  1321. @item reset
  1322. Counter that determines after how many frames cropdetect will reset
  1323. the previously detected largest video area and start over to detect
  1324. the current optimal crop area. Defaults to 0.
  1325. This can be useful when channel logos distort the video area. 0
  1326. indicates never reset and return the largest area encountered during
  1327. playback.
  1328. @end table
  1329. @section decimate
  1330. This filter drops frames that do not differ greatly from the previous
  1331. frame in order to reduce framerate. The main use of this filter is
  1332. for very-low-bitrate encoding (e.g. streaming over dialup modem), but
  1333. it could in theory be used for fixing movies that were
  1334. inverse-telecined incorrectly.
  1335. It accepts the following parameters:
  1336. @var{max}:@var{hi}:@var{lo}:@var{frac}.
  1337. @table @option
  1338. @item max
  1339. Set the maximum number of consecutive frames which can be dropped (if
  1340. positive), or the minimum interval between dropped frames (if
  1341. negative). If the value is 0, the frame is dropped unregarding the
  1342. number of previous sequentially dropped frames.
  1343. Default value is 0.
  1344. @item hi, lo, frac
  1345. Set the dropping threshold values.
  1346. Values for @var{hi} and @var{lo} are for 8x8 pixel blocks and
  1347. represent actual pixel value differences, so a threshold of 64
  1348. corresponds to 1 unit of difference for each pixel, or the same spread
  1349. out differently over the block.
  1350. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1351. than a threshold of @var{hi}, and if no more than @var{frac} blocks (1
  1352. meaning the whole image) differ by more than a threshold of @var{lo}.
  1353. Default value for @var{hi} is 64*12, default value for @var{lo} is
  1354. 64*5, and default value for @var{frac} is 0.33.
  1355. @end table
  1356. @section delogo
  1357. Suppress a TV station logo by a simple interpolation of the surrounding
  1358. pixels. Just set a rectangle covering the logo and watch it disappear
  1359. (and sometimes something even uglier appear - your mileage may vary).
  1360. The filter accepts parameters as a string of the form
  1361. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1362. @var{key}=@var{value} pairs, separated by ":".
  1363. The description of the accepted parameters follows.
  1364. @table @option
  1365. @item x, y
  1366. Specify the top left corner coordinates of the logo. They must be
  1367. specified.
  1368. @item w, h
  1369. Specify the width and height of the logo to clear. They must be
  1370. specified.
  1371. @item band, t
  1372. Specify the thickness of the fuzzy edge of the rectangle (added to
  1373. @var{w} and @var{h}). The default value is 4.
  1374. @item show
  1375. When set to 1, a green rectangle is drawn on the screen to simplify
  1376. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1377. @var{band} is set to 4. The default value is 0.
  1378. @end table
  1379. Some examples follow.
  1380. @itemize
  1381. @item
  1382. Set a rectangle covering the area with top left corner coordinates 0,0
  1383. and size 100x77, setting a band of size 10:
  1384. @example
  1385. delogo=0:0:100:77:10
  1386. @end example
  1387. @item
  1388. As the previous example, but use named options:
  1389. @example
  1390. delogo=x=0:y=0:w=100:h=77:band=10
  1391. @end example
  1392. @end itemize
  1393. @section deshake
  1394. Attempt to fix small changes in horizontal and/or vertical shift. This
  1395. filter helps remove camera shake from hand-holding a camera, bumping a
  1396. tripod, moving on a vehicle, etc.
  1397. The filter accepts parameters as a string of the form
  1398. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  1399. A description of the accepted parameters follows.
  1400. @table @option
  1401. @item x, y, w, h
  1402. Specify a rectangular area where to limit the search for motion
  1403. vectors.
  1404. If desired the search for motion vectors can be limited to a
  1405. rectangular area of the frame defined by its top left corner, width
  1406. and height. These parameters have the same meaning as the drawbox
  1407. filter which can be used to visualise the position of the bounding
  1408. box.
  1409. This is useful when simultaneous movement of subjects within the frame
  1410. might be confused for camera motion by the motion vector search.
  1411. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1412. then the full frame is used. This allows later options to be set
  1413. without specifying the bounding box for the motion vector search.
  1414. Default - search the whole frame.
  1415. @item rx, ry
  1416. Specify the maximum extent of movement in x and y directions in the
  1417. range 0-64 pixels. Default 16.
  1418. @item edge
  1419. Specify how to generate pixels to fill blanks at the edge of the
  1420. frame. An integer from 0 to 3 as follows:
  1421. @table @option
  1422. @item 0
  1423. Fill zeroes at blank locations
  1424. @item 1
  1425. Original image at blank locations
  1426. @item 2
  1427. Extruded edge value at blank locations
  1428. @item 3
  1429. Mirrored edge at blank locations
  1430. @end table
  1431. The default setting is mirror edge at blank locations.
  1432. @item blocksize
  1433. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1434. default 8.
  1435. @item contrast
  1436. Specify the contrast threshold for blocks. Only blocks with more than
  1437. the specified contrast (difference between darkest and lightest
  1438. pixels) will be considered. Range 1-255, default 125.
  1439. @item search
  1440. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  1441. search. Default - exhaustive search.
  1442. @item filename
  1443. If set then a detailed log of the motion search is written to the
  1444. specified file.
  1445. @end table
  1446. @section drawbox
  1447. Draw a colored box on the input image.
  1448. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1449. separated by ":".
  1450. The description of the accepted parameters follows.
  1451. @table @option
  1452. @item x, y
  1453. Specify the top left corner coordinates of the box. Default to 0.
  1454. @item width, w
  1455. @item height, h
  1456. Specify the width and height of the box, if 0 they are interpreted as
  1457. the input width and height. Default to 0.
  1458. @item color, c
  1459. Specify the color of the box to write, it can be the name of a color
  1460. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  1461. value @code{invert} is used, the box edge color is the same as the
  1462. video with inverted luma.
  1463. @item thickness, t
  1464. Set the thickness of the box edge. Default value is @code{4}.
  1465. @end table
  1466. If the key of the first options is omitted, the arguments are
  1467. interpreted according to the syntax
  1468. @var{x}:@var{y}:@var{width}:@var{height}:@var{color}:@var{thickness}.
  1469. Some examples follow:
  1470. @itemize
  1471. @item
  1472. Draw a black box around the edge of the input image:
  1473. @example
  1474. drawbox
  1475. @end example
  1476. @item
  1477. Draw a box with color red and an opacity of 50%:
  1478. @example
  1479. drawbox=10:20:200:60:red@@0.5
  1480. @end example
  1481. The previous example can be specified as:
  1482. @example
  1483. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  1484. @end example
  1485. @item
  1486. Fill the box with pink color:
  1487. @example
  1488. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  1489. @end example
  1490. @end itemize
  1491. @anchor{drawtext}
  1492. @section drawtext
  1493. Draw text string or text from specified file on top of video using the
  1494. libfreetype library.
  1495. To enable compilation of this filter you need to configure FFmpeg with
  1496. @code{--enable-libfreetype}.
  1497. @subsection Syntax
  1498. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1499. separated by ":".
  1500. The description of the accepted parameters follows.
  1501. @table @option
  1502. @item box
  1503. Used to draw a box around text using background color.
  1504. Value should be either 1 (enable) or 0 (disable).
  1505. The default value of @var{box} is 0.
  1506. @item boxcolor
  1507. The color to be used for drawing box around text.
  1508. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1509. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1510. The default value of @var{boxcolor} is "white".
  1511. @item draw
  1512. Set an expression which specifies if the text should be drawn. If the
  1513. expression evaluates to 0, the text is not drawn. This is useful for
  1514. specifying that the text should be drawn only when specific conditions
  1515. are met.
  1516. Default value is "1".
  1517. See below for the list of accepted constants and functions.
  1518. @item expansion
  1519. Select how the @var{text} is expanded. Can be either @code{none},
  1520. @code{strftime} (default for compatibity reasons but deprecated) or
  1521. @code{normal}. See the @ref{drawtext_expansion, Text expansion} section
  1522. below for details.
  1523. @item fix_bounds
  1524. If true, check and fix text coords to avoid clipping.
  1525. @item fontcolor
  1526. The color to be used for drawing fonts.
  1527. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1528. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1529. The default value of @var{fontcolor} is "black".
  1530. @item fontfile
  1531. The font file to be used for drawing text. Path must be included.
  1532. This parameter is mandatory.
  1533. @item fontsize
  1534. The font size to be used for drawing text.
  1535. The default value of @var{fontsize} is 16.
  1536. @item ft_load_flags
  1537. Flags to be used for loading the fonts.
  1538. The flags map the corresponding flags supported by libfreetype, and are
  1539. a combination of the following values:
  1540. @table @var
  1541. @item default
  1542. @item no_scale
  1543. @item no_hinting
  1544. @item render
  1545. @item no_bitmap
  1546. @item vertical_layout
  1547. @item force_autohint
  1548. @item crop_bitmap
  1549. @item pedantic
  1550. @item ignore_global_advance_width
  1551. @item no_recurse
  1552. @item ignore_transform
  1553. @item monochrome
  1554. @item linear_design
  1555. @item no_autohint
  1556. @item end table
  1557. @end table
  1558. Default value is "render".
  1559. For more information consult the documentation for the FT_LOAD_*
  1560. libfreetype flags.
  1561. @item shadowcolor
  1562. The color to be used for drawing a shadow behind the drawn text. It
  1563. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1564. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1565. The default value of @var{shadowcolor} is "black".
  1566. @item shadowx, shadowy
  1567. The x and y offsets for the text shadow position with respect to the
  1568. position of the text. They can be either positive or negative
  1569. values. Default value for both is "0".
  1570. @item tabsize
  1571. The size in number of spaces to use for rendering the tab.
  1572. Default value is 4.
  1573. @item timecode
  1574. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1575. format. It can be used with or without text parameter. @var{timecode_rate}
  1576. option must be specified.
  1577. @item timecode_rate, rate, r
  1578. Set the timecode frame rate (timecode only).
  1579. @item text
  1580. The text string to be drawn. The text must be a sequence of UTF-8
  1581. encoded characters.
  1582. This parameter is mandatory if no file is specified with the parameter
  1583. @var{textfile}.
  1584. @item textfile
  1585. A text file containing text to be drawn. The text must be a sequence
  1586. of UTF-8 encoded characters.
  1587. This parameter is mandatory if no text string is specified with the
  1588. parameter @var{text}.
  1589. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1590. @item reload
  1591. If set to 1, the @var{textfile} will be reloaded before each frame.
  1592. Be sure to update it atomically, or it may be read partially, or even fail.
  1593. @item x, y
  1594. The expressions which specify the offsets where text will be drawn
  1595. within the video frame. They are relative to the top/left border of the
  1596. output image.
  1597. The default value of @var{x} and @var{y} is "0".
  1598. See below for the list of accepted constants and functions.
  1599. @end table
  1600. The parameters for @var{x} and @var{y} are expressions containing the
  1601. following constants and functions:
  1602. @table @option
  1603. @item dar
  1604. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1605. @item hsub, vsub
  1606. horizontal and vertical chroma subsample values. For example for the
  1607. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1608. @item line_h, lh
  1609. the height of each text line
  1610. @item main_h, h, H
  1611. the input height
  1612. @item main_w, w, W
  1613. the input width
  1614. @item max_glyph_a, ascent
  1615. the maximum distance from the baseline to the highest/upper grid
  1616. coordinate used to place a glyph outline point, for all the rendered
  1617. glyphs.
  1618. It is a positive value, due to the grid's orientation with the Y axis
  1619. upwards.
  1620. @item max_glyph_d, descent
  1621. the maximum distance from the baseline to the lowest grid coordinate
  1622. used to place a glyph outline point, for all the rendered glyphs.
  1623. This is a negative value, due to the grid's orientation, with the Y axis
  1624. upwards.
  1625. @item max_glyph_h
  1626. maximum glyph height, that is the maximum height for all the glyphs
  1627. contained in the rendered text, it is equivalent to @var{ascent} -
  1628. @var{descent}.
  1629. @item max_glyph_w
  1630. maximum glyph width, that is the maximum width for all the glyphs
  1631. contained in the rendered text
  1632. @item n
  1633. the number of input frame, starting from 0
  1634. @item rand(min, max)
  1635. return a random number included between @var{min} and @var{max}
  1636. @item sar
  1637. input sample aspect ratio
  1638. @item t
  1639. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1640. @item text_h, th
  1641. the height of the rendered text
  1642. @item text_w, tw
  1643. the width of the rendered text
  1644. @item x, y
  1645. the x and y offset coordinates where the text is drawn.
  1646. These parameters allow the @var{x} and @var{y} expressions to refer
  1647. each other, so you can for example specify @code{y=x/dar}.
  1648. @end table
  1649. If libavfilter was built with @code{--enable-fontconfig}, then
  1650. @option{fontfile} can be a fontconfig pattern or omitted.
  1651. @anchor{drawtext_expansion}
  1652. @subsection Text expansion
  1653. If @option{expansion} is set to @code{strftime} (which is the default for
  1654. now), the filter recognizes strftime() sequences in the provided text and
  1655. expands them accordingly. Check the documentation of strftime(). This
  1656. feature is deprecated.
  1657. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  1658. If @option{expansion} is set to @code{normal} (which will be the default),
  1659. the following expansion mechanism is used.
  1660. The backslash character '\', followed by any character, always expands to
  1661. the second character.
  1662. Sequence of the form @code{%@{...@}} are expanded. The text between the
  1663. braces is a function name, possibly followed by arguments separated by ':'.
  1664. If the arguments contain special characters or delimiters (':' or '@}'),
  1665. they should be escaped.
  1666. Note that they probably must also be escaped as the value for the
  1667. @option{text} option in the filter argument string and as the filter
  1668. argument in the filter graph description, and possibly also for the shell,
  1669. that makes up to four levels of escaping; using a text file avoids these
  1670. problems.
  1671. The following functions are available:
  1672. @table @command
  1673. @item expr, e
  1674. The expression evaluation result.
  1675. It must take one argument specifying the expression to be evaluated,
  1676. which accepts the same constants and functions as the @var{x} and
  1677. @var{y} values. Note that not all constants should be used, for
  1678. example the text size is not known when evaluating the expression, so
  1679. the constants @var{text_w} and @var{text_h} will have an undefined
  1680. value.
  1681. @item gmtime
  1682. The time at which the filter is running, expressed in UTC.
  1683. It can accept an argument: a strftime() format string.
  1684. @item localtime
  1685. The time at which the filter is running, expressed in the local time zone.
  1686. It can accept an argument: a strftime() format string.
  1687. @item n, frame_num
  1688. The frame number, starting from 0.
  1689. @item pts
  1690. The timestamp of the current frame, in seconds, with microsecond accuracy.
  1691. @end table
  1692. @subsection Examples
  1693. Some examples follow.
  1694. @itemize
  1695. @item
  1696. Draw "Test Text" with font FreeSerif, using the default values for the
  1697. optional parameters.
  1698. @example
  1699. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1700. @end example
  1701. @item
  1702. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1703. and y=50 (counting from the top-left corner of the screen), text is
  1704. yellow with a red box around it. Both the text and the box have an
  1705. opacity of 20%.
  1706. @example
  1707. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1708. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1709. @end example
  1710. Note that the double quotes are not necessary if spaces are not used
  1711. within the parameter list.
  1712. @item
  1713. Show the text at the center of the video frame:
  1714. @example
  1715. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1716. @end example
  1717. @item
  1718. Show a text line sliding from right to left in the last row of the video
  1719. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1720. with no newlines.
  1721. @example
  1722. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1723. @end example
  1724. @item
  1725. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1726. @example
  1727. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1728. @end example
  1729. @item
  1730. Draw a single green letter "g", at the center of the input video.
  1731. The glyph baseline is placed at half screen height.
  1732. @example
  1733. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1734. @end example
  1735. @item
  1736. Show text for 1 second every 3 seconds:
  1737. @example
  1738. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  1739. @end example
  1740. @item
  1741. Use fontconfig to set the font. Note that the colons need to be escaped.
  1742. @example
  1743. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  1744. @end example
  1745. @item
  1746. Print the date of a real-time encoding (see strftime(3)):
  1747. @example
  1748. drawtext='fontfile=FreeSans.ttf:expansion=normal:text=%@{localtime:%a %b %d %Y@}'
  1749. @end example
  1750. @end itemize
  1751. For more information about libfreetype, check:
  1752. @url{http://www.freetype.org/}.
  1753. For more information about fontconfig, check:
  1754. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1755. @section edgedetect
  1756. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  1757. This filter accepts the following optional named parameters:
  1758. @table @option
  1759. @item low, high
  1760. Set low and high threshold values used by the Canny thresholding
  1761. algorithm.
  1762. The high threshold selects the "strong" edge pixels, which are then
  1763. connected through 8-connectivity with the "weak" edge pixels selected
  1764. by the low threshold.
  1765. @var{low} and @var{high} threshold values must be choosen in the range
  1766. [0,1], and @var{low} should be lesser or equal to @var{high}.
  1767. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  1768. is @code{50/255}.
  1769. @end table
  1770. Example:
  1771. @example
  1772. edgedetect=low=0.1:high=0.4
  1773. @end example
  1774. @section fade
  1775. Apply fade-in/out effect to input video.
  1776. The filter accepts parameters as a list of @var{key}=@var{value}
  1777. pairs, separated by ":". If the key of the first options is omitted,
  1778. the arguments are interpreted according to the syntax
  1779. @var{type}:@var{start_frame}:@var{nb_frames}.
  1780. A description of the accepted parameters follows.
  1781. @table @option
  1782. @item type, t
  1783. Specify if the effect type, can be either @code{in} for fade-in, or
  1784. @code{out} for a fade-out effect. Default is @code{in}.
  1785. @item start_frame, s
  1786. Specify the number of the start frame for starting to apply the fade
  1787. effect. Default is 0.
  1788. @item nb_frames, n
  1789. Specify the number of frames for which the fade effect has to last. At
  1790. the end of the fade-in effect the output video will have the same
  1791. intensity as the input video, at the end of the fade-out transition
  1792. the output video will be completely black. Default is 25.
  1793. @item alpha
  1794. If set to 1, fade only alpha channel, if one exists on the input.
  1795. Default value is 0.
  1796. @end table
  1797. @subsection Examples
  1798. @itemize
  1799. @item
  1800. Fade in first 30 frames of video:
  1801. @example
  1802. fade=in:0:30
  1803. @end example
  1804. The command above is equivalent to:
  1805. @example
  1806. fade=t=in:s=0:n=30
  1807. @end example
  1808. @item
  1809. Fade out last 45 frames of a 200-frame video:
  1810. @example
  1811. fade=out:155:45
  1812. @end example
  1813. @item
  1814. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  1815. @example
  1816. fade=in:0:25, fade=out:975:25
  1817. @end example
  1818. @item
  1819. Make first 5 frames black, then fade in from frame 5-24:
  1820. @example
  1821. fade=in:5:20
  1822. @end example
  1823. @item
  1824. Fade in alpha over first 25 frames of video:
  1825. @example
  1826. fade=in:0:25:alpha=1
  1827. @end example
  1828. @end itemize
  1829. @section field
  1830. Extract a single field from an interlaced image using stride
  1831. arithmetic to avoid wasting CPU time. The output frames are marked as
  1832. non-interlaced.
  1833. This filter accepts the following named options:
  1834. @table @option
  1835. @item type
  1836. Specify whether to extract the top (if the value is @code{0} or
  1837. @code{top}) or the bottom field (if the value is @code{1} or
  1838. @code{bottom}).
  1839. @end table
  1840. If the option key is not specified, the first value sets the @var{type}
  1841. option. For example:
  1842. @example
  1843. field=bottom
  1844. @end example
  1845. is equivalent to:
  1846. @example
  1847. field=type=bottom
  1848. @end example
  1849. @section fieldorder
  1850. Transform the field order of the input video.
  1851. It accepts one parameter which specifies the required field order that
  1852. the input interlaced video will be transformed to. The parameter can
  1853. assume one of the following values:
  1854. @table @option
  1855. @item 0 or bff
  1856. output bottom field first
  1857. @item 1 or tff
  1858. output top field first
  1859. @end table
  1860. Default value is "tff".
  1861. Transformation is achieved by shifting the picture content up or down
  1862. by one line, and filling the remaining line with appropriate picture content.
  1863. This method is consistent with most broadcast field order converters.
  1864. If the input video is not flagged as being interlaced, or it is already
  1865. flagged as being of the required output field order then this filter does
  1866. not alter the incoming video.
  1867. This filter is very useful when converting to or from PAL DV material,
  1868. which is bottom field first.
  1869. For example:
  1870. @example
  1871. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1872. @end example
  1873. @section fifo
  1874. Buffer input images and send them when they are requested.
  1875. This filter is mainly useful when auto-inserted by the libavfilter
  1876. framework.
  1877. The filter does not take parameters.
  1878. @section format
  1879. Convert the input video to one of the specified pixel formats.
  1880. Libavfilter will try to pick one that is supported for the input to
  1881. the next filter.
  1882. The filter accepts a list of pixel format names, separated by ":",
  1883. for example "yuv420p:monow:rgb24".
  1884. Some examples follow:
  1885. @example
  1886. # convert the input video to the format "yuv420p"
  1887. format=yuv420p
  1888. # convert the input video to any of the formats in the list
  1889. format=yuv420p:yuv444p:yuv410p
  1890. @end example
  1891. @section fps
  1892. Convert the video to specified constant framerate by duplicating or dropping
  1893. frames as necessary.
  1894. This filter accepts the following named parameters:
  1895. @table @option
  1896. @item fps
  1897. Desired output framerate. The default is @code{25}.
  1898. @item round
  1899. Rounding method.
  1900. Possible values are:
  1901. @table @option
  1902. @item zero
  1903. zero round towards 0
  1904. @item inf
  1905. round away from 0
  1906. @item down
  1907. round towards -infinity
  1908. @item up
  1909. round towards +infinity
  1910. @item near
  1911. round to nearest
  1912. @end table
  1913. The default is @code{near}.
  1914. @end table
  1915. Alternatively, the options can be specified as a flat string:
  1916. @var{fps}[:@var{round}].
  1917. See also the @ref{setpts} filter.
  1918. @section framestep
  1919. Select one frame every N.
  1920. This filter accepts in input a string representing a positive
  1921. integer. Default argument is @code{1}.
  1922. @anchor{frei0r}
  1923. @section frei0r
  1924. Apply a frei0r effect to the input video.
  1925. To enable compilation of this filter you need to install the frei0r
  1926. header and configure FFmpeg with @code{--enable-frei0r}.
  1927. The filter supports the syntax:
  1928. @example
  1929. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1930. @end example
  1931. @var{filter_name} is the name of the frei0r effect to load. If the
  1932. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1933. is searched in each one of the directories specified by the colon (or
  1934. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  1935. otherwise in the standard frei0r paths, which are in this order:
  1936. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  1937. @file{/usr/lib/frei0r-1/}.
  1938. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1939. for the frei0r effect.
  1940. A frei0r effect parameter can be a boolean (whose values are specified
  1941. with "y" and "n"), a double, a color (specified by the syntax
  1942. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1943. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1944. description), a position (specified by the syntax @var{X}/@var{Y},
  1945. @var{X} and @var{Y} being float numbers) and a string.
  1946. The number and kind of parameters depend on the loaded effect. If an
  1947. effect parameter is not specified the default value is set.
  1948. Some examples follow:
  1949. @itemize
  1950. @item
  1951. Apply the distort0r effect, set the first two double parameters:
  1952. @example
  1953. frei0r=distort0r:0.5:0.01
  1954. @end example
  1955. @item
  1956. Apply the colordistance effect, take a color as first parameter:
  1957. @example
  1958. frei0r=colordistance:0.2/0.3/0.4
  1959. frei0r=colordistance:violet
  1960. frei0r=colordistance:0x112233
  1961. @end example
  1962. @item
  1963. Apply the perspective effect, specify the top left and top right image
  1964. positions:
  1965. @example
  1966. frei0r=perspective:0.2/0.2:0.8/0.2
  1967. @end example
  1968. @end itemize
  1969. For more information see:
  1970. @url{http://frei0r.dyne.org}
  1971. @section geq
  1972. The filter takes one, two or three equations as parameter, separated by ':'.
  1973. The first equation is mandatory and applies to the luma plane. The two
  1974. following are respectively for chroma blue and chroma red planes.
  1975. The filter syntax allows named parameters:
  1976. @table @option
  1977. @item lum_expr
  1978. the luminance expression
  1979. @item cb_expr
  1980. the chrominance blue expression
  1981. @item cr_expr
  1982. the chrominance red expression
  1983. @end table
  1984. If one of the chrominance expression is not defined, it falls back on the other
  1985. one. If none of them are specified, they will evaluate the luminance
  1986. expression.
  1987. The expressions can use the following variables and functions:
  1988. @table @option
  1989. @item N
  1990. The sequential number of the filtered frame, starting from @code{0}.
  1991. @item X, Y
  1992. The coordinates of the current sample.
  1993. @item W, H
  1994. The width and height of the image.
  1995. @item SW, SH
  1996. Width and height scale depending on the currently filtered plane. It is the
  1997. ratio between the corresponding luma plane number of pixels and the current
  1998. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1999. @code{0.5,0.5} for chroma planes.
  2000. @item T
  2001. Time of the current frame, expressed in seconds.
  2002. @item p(x, y)
  2003. Return the value of the pixel at location (@var{x},@var{y}) of the current
  2004. plane.
  2005. @item lum(x, y)
  2006. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  2007. plane.
  2008. @item cb(x, y)
  2009. Return the value of the pixel at location (@var{x},@var{y}) of the
  2010. blue-difference chroma plane.
  2011. @item cr(x, y)
  2012. Return the value of the pixel at location (@var{x},@var{y}) of the
  2013. red-difference chroma plane.
  2014. @end table
  2015. For functions, if @var{x} and @var{y} are outside the area, the value will be
  2016. automatically clipped to the closer edge.
  2017. Some examples follow:
  2018. @itemize
  2019. @item
  2020. Flip the image horizontally:
  2021. @example
  2022. geq=p(W-X\,Y)
  2023. @end example
  2024. @item
  2025. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  2026. wavelength of 100 pixels:
  2027. @example
  2028. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  2029. @end example
  2030. @item
  2031. Generate a fancy enigmatic moving light:
  2032. @example
  2033. nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
  2034. @end example
  2035. @end itemize
  2036. @section gradfun
  2037. Fix the banding artifacts that are sometimes introduced into nearly flat
  2038. regions by truncation to 8bit color depth.
  2039. Interpolate the gradients that should go where the bands are, and
  2040. dither them.
  2041. This filter is designed for playback only. Do not use it prior to
  2042. lossy compression, because compression tends to lose the dither and
  2043. bring back the bands.
  2044. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  2045. separated by ":". A description of the accepted options follows.
  2046. @table @option
  2047. @item strength
  2048. The maximum amount by which the filter will change
  2049. any one pixel. Also the threshold for detecting nearly flat
  2050. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  2051. is @code{1.2}.
  2052. @item radius
  2053. The neighborhood to fit the gradient to. A larger
  2054. radius makes for smoother gradients, but also prevents the filter from
  2055. modifying the pixels near detailed regions. Acceptable values are
  2056. @code{8-32}, default value is @code{16}.
  2057. @end table
  2058. Alternatively, the options can be specified as a flat string:
  2059. @var{strength}[:@var{radius}]
  2060. @subsection Examples
  2061. @itemize
  2062. @item
  2063. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  2064. @example
  2065. gradfun=3.5:8
  2066. @end example
  2067. @item
  2068. Specify radius, omitting the strength (which will fall-back to the default
  2069. value):
  2070. @example
  2071. gradfun=radius=8
  2072. @end example
  2073. @end itemize
  2074. @section hflip
  2075. Flip the input video horizontally.
  2076. For example to horizontally flip the input video with @command{ffmpeg}:
  2077. @example
  2078. ffmpeg -i in.avi -vf "hflip" out.avi
  2079. @end example
  2080. @section histeq
  2081. This filter applies a global color histogram equalization on a
  2082. per-frame basis.
  2083. It can be used to correct video that has a compressed range of pixel
  2084. intensities. The filter redistributes the pixel intensities to
  2085. equalize their distribution across the intensity range. It may be
  2086. viewed as an "automatically adjusting contrast filter". This filter is
  2087. useful only for correcting degraded or poorly captured source
  2088. video.
  2089. The filter accepts parameters as a list of @var{key}=@var{value}
  2090. pairs, separated by ":". If the key of the first options is omitted,
  2091. the arguments are interpreted according to syntax
  2092. @var{strength}:@var{intensity}:@var{antibanding}.
  2093. This filter accepts the following named options:
  2094. @table @option
  2095. @item strength
  2096. Determine the amount of equalization to be applied. As the strength
  2097. is reduced, the distribution of pixel intensities more-and-more
  2098. approaches that of the input frame. The value must be a float number
  2099. in the range [0,1] and defaults to 0.200.
  2100. @item intensity
  2101. Set the maximum intensity that can generated and scale the output
  2102. values appropriately. The strength should be set as desired and then
  2103. the intensity can be limited if needed to avoid washing-out. The value
  2104. must be a float number in the range [0,1] and defaults to 0.210.
  2105. @item antibanding
  2106. Set the antibanding level. If enabled the filter will randomly vary
  2107. the luminance of output pixels by a small amount to avoid banding of
  2108. the histogram. Possible values are @code{none}, @code{weak} or
  2109. @code{strong}. It defaults to @code{none}.
  2110. @end table
  2111. @section hqdn3d
  2112. High precision/quality 3d denoise filter. This filter aims to reduce
  2113. image noise producing smooth images and making still images really
  2114. still. It should enhance compressibility.
  2115. It accepts the following optional parameters:
  2116. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2117. @table @option
  2118. @item luma_spatial
  2119. a non-negative float number which specifies spatial luma strength,
  2120. defaults to 4.0
  2121. @item chroma_spatial
  2122. a non-negative float number which specifies spatial chroma strength,
  2123. defaults to 3.0*@var{luma_spatial}/4.0
  2124. @item luma_tmp
  2125. a float number which specifies luma temporal strength, defaults to
  2126. 6.0*@var{luma_spatial}/4.0
  2127. @item chroma_tmp
  2128. a float number which specifies chroma temporal strength, defaults to
  2129. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2130. @end table
  2131. @section hue
  2132. Modify the hue and/or the saturation of the input.
  2133. This filter accepts the following optional named options:
  2134. @table @option
  2135. @item h
  2136. Specify the hue angle as a number of degrees. It accepts a float
  2137. number or an expression, and defaults to 0.0.
  2138. @item H
  2139. Specify the hue angle as a number of degrees. It accepts a float
  2140. number or an expression, and defaults to 0.0.
  2141. @item s
  2142. Specify the saturation in the [-10,10] range. It accepts a float number and
  2143. defaults to 1.0.
  2144. @end table
  2145. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2146. following constants:
  2147. @table @option
  2148. @item n
  2149. frame count of the input frame starting from 0
  2150. @item pts
  2151. presentation timestamp of the input frame expressed in time base units
  2152. @item r
  2153. frame rate of the input video, NAN if the input frame rate is unknown
  2154. @item t
  2155. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2156. @item tb
  2157. time base of the input video
  2158. @end table
  2159. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2160. In this case @var{hue} is expressed in degrees.
  2161. Some examples follow:
  2162. @itemize
  2163. @item
  2164. Set the hue to 90 degrees and the saturation to 1.0:
  2165. @example
  2166. hue=h=90:s=1
  2167. @end example
  2168. @item
  2169. Same command but expressing the hue in radians:
  2170. @example
  2171. hue=H=PI/2:s=1
  2172. @end example
  2173. @item
  2174. Same command without named options, hue must be expressed in degrees:
  2175. @example
  2176. hue=90:1
  2177. @end example
  2178. @item
  2179. Note that "h:s" syntax does not support expressions for the values of
  2180. h and s, so the following example will issue an error:
  2181. @example
  2182. hue=PI/2:1
  2183. @end example
  2184. @item
  2185. Rotate hue and make the saturation swing between 0
  2186. and 2 over a period of 1 second:
  2187. @example
  2188. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2189. @end example
  2190. @item
  2191. Apply a 3 seconds saturation fade-in effect starting at 0:
  2192. @example
  2193. hue="s=min(t/3\,1)"
  2194. @end example
  2195. The general fade-in expression can be written as:
  2196. @example
  2197. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2198. @end example
  2199. @item
  2200. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2201. @example
  2202. hue="s=max(0\, min(1\, (8-t)/3))"
  2203. @end example
  2204. The general fade-out expression can be written as:
  2205. @example
  2206. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2207. @end example
  2208. @end itemize
  2209. @subsection Commands
  2210. This filter supports the following command:
  2211. @table @option
  2212. @item reinit
  2213. Modify the hue and/or the saturation of the input video.
  2214. The command accepts the same named options and syntax than when calling the
  2215. filter from the command-line.
  2216. If a parameter is omitted, it is kept at its current value.
  2217. @end table
  2218. @section idet
  2219. Interlaceing detect filter. This filter tries to detect if the input is
  2220. interlaced or progressive. Top or bottom field first.
  2221. @section kerndeint
  2222. Deinterlace input video by applying Donald Graft's adaptive kernel
  2223. deinterling. Work on interlaced parts of a video to produce
  2224. progressive frames.
  2225. This filter accepts parameters as a list of @var{key}=@var{value}
  2226. pairs, separated by ":". If the key of the first options is omitted,
  2227. the arguments are interpreted according to the following syntax:
  2228. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2229. The description of the accepted parameters follows.
  2230. @table @option
  2231. @item thresh
  2232. Set the threshold which affects the filter's tolerance when
  2233. determining if a pixel line must be processed. It must be an integer
  2234. in the range [0,255] and defaults to 10. A value of 0 will result in
  2235. applying the process on every pixels.
  2236. @item map
  2237. Paint pixels exceeding the threshold value to white if set to 1.
  2238. Default is 0.
  2239. @item order
  2240. Set the fields order. Swap fields if set to 1, leave fields alone if
  2241. 0. Default is 0.
  2242. @item sharp
  2243. Enable additional sharpening if set to 1. Default is 0.
  2244. @item twoway
  2245. Enable twoway sharpening if set to 1. Default is 0.
  2246. @end table
  2247. @subsection Examples
  2248. @itemize
  2249. @item
  2250. Apply default values:
  2251. @example
  2252. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2253. @end example
  2254. @item
  2255. Enable additional sharpening:
  2256. @example
  2257. kerndeint=sharp=1
  2258. @end example
  2259. @item
  2260. Paint processed pixels in white:
  2261. @example
  2262. kerndeint=map=1
  2263. @end example
  2264. @end itemize
  2265. @section lut, lutrgb, lutyuv
  2266. Compute a look-up table for binding each pixel component input value
  2267. to an output value, and apply it to input video.
  2268. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2269. to an RGB input video.
  2270. These filters accept in input a ":"-separated list of options, which
  2271. specify the expressions used for computing the lookup table for the
  2272. corresponding pixel component values.
  2273. The @var{lut} filter requires either YUV or RGB pixel formats in
  2274. input, and accepts the options:
  2275. @table @option
  2276. @item @var{c0} (first pixel component)
  2277. @item @var{c1} (second pixel component)
  2278. @item @var{c2} (third pixel component)
  2279. @item @var{c3} (fourth pixel component, corresponds to the alpha component)
  2280. @end table
  2281. The exact component associated to each option depends on the format in
  2282. input.
  2283. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2284. accepts the options:
  2285. @table @option
  2286. @item @var{r} (red component)
  2287. @item @var{g} (green component)
  2288. @item @var{b} (blue component)
  2289. @item @var{a} (alpha component)
  2290. @end table
  2291. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2292. accepts the options:
  2293. @table @option
  2294. @item @var{y} (Y/luminance component)
  2295. @item @var{u} (U/Cb component)
  2296. @item @var{v} (V/Cr component)
  2297. @item @var{a} (alpha component)
  2298. @end table
  2299. The expressions can contain the following constants and functions:
  2300. @table @option
  2301. @item w, h
  2302. the input width and height
  2303. @item val
  2304. input value for the pixel component
  2305. @item clipval
  2306. the input value clipped in the @var{minval}-@var{maxval} range
  2307. @item maxval
  2308. maximum value for the pixel component
  2309. @item minval
  2310. minimum value for the pixel component
  2311. @item negval
  2312. the negated value for the pixel component value clipped in the
  2313. @var{minval}-@var{maxval} range , it corresponds to the expression
  2314. "maxval-clipval+minval"
  2315. @item clip(val)
  2316. the computed value in @var{val} clipped in the
  2317. @var{minval}-@var{maxval} range
  2318. @item gammaval(gamma)
  2319. the computed gamma correction value of the pixel component value
  2320. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2321. expression
  2322. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2323. @end table
  2324. All expressions default to "val".
  2325. Some examples follow:
  2326. @example
  2327. # negate input video
  2328. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2329. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2330. # the above is the same as
  2331. lutrgb="r=negval:g=negval:b=negval"
  2332. lutyuv="y=negval:u=negval:v=negval"
  2333. # negate luminance
  2334. lutyuv=y=negval
  2335. # remove chroma components, turns the video into a graytone image
  2336. lutyuv="u=128:v=128"
  2337. # apply a luma burning effect
  2338. lutyuv="y=2*val"
  2339. # remove green and blue components
  2340. lutrgb="g=0:b=0"
  2341. # set a constant alpha channel value on input
  2342. format=rgba,lutrgb=a="maxval-minval/2"
  2343. # correct luminance gamma by a 0.5 factor
  2344. lutyuv=y=gammaval(0.5)
  2345. @end example
  2346. @section mp
  2347. Apply an MPlayer filter to the input video.
  2348. This filter provides a wrapper around most of the filters of
  2349. MPlayer/MEncoder.
  2350. This wrapper is considered experimental. Some of the wrapped filters
  2351. may not work properly and we may drop support for them, as they will
  2352. be implemented natively into FFmpeg. Thus you should avoid
  2353. depending on them when writing portable scripts.
  2354. The filters accepts the parameters:
  2355. @var{filter_name}[:=]@var{filter_params}
  2356. @var{filter_name} is the name of a supported MPlayer filter,
  2357. @var{filter_params} is a string containing the parameters accepted by
  2358. the named filter.
  2359. The list of the currently supported filters follows:
  2360. @table @var
  2361. @item detc
  2362. @item dint
  2363. @item divtc
  2364. @item down3dright
  2365. @item dsize
  2366. @item eq2
  2367. @item eq
  2368. @item fil
  2369. @item fspp
  2370. @item harddup
  2371. @item il
  2372. @item ilpack
  2373. @item ivtc
  2374. @item kerndeint
  2375. @item mcdeint
  2376. @item noise
  2377. @item ow
  2378. @item perspective
  2379. @item phase
  2380. @item pp7
  2381. @item pullup
  2382. @item qp
  2383. @item sab
  2384. @item softpulldown
  2385. @item softskip
  2386. @item spp
  2387. @item telecine
  2388. @item tinterlace
  2389. @item unsharp
  2390. @item uspp
  2391. @end table
  2392. The parameter syntax and behavior for the listed filters are the same
  2393. of the corresponding MPlayer filters. For detailed instructions check
  2394. the "VIDEO FILTERS" section in the MPlayer manual.
  2395. Some examples follow:
  2396. @itemize
  2397. @item
  2398. Adjust gamma, brightness, contrast:
  2399. @example
  2400. mp=eq2=1.0:2:0.5
  2401. @end example
  2402. @item
  2403. Add temporal noise to input video:
  2404. @example
  2405. mp=noise=20t
  2406. @end example
  2407. @end itemize
  2408. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2409. @section negate
  2410. Negate input video.
  2411. This filter accepts an integer in input, if non-zero it negates the
  2412. alpha component (if available). The default value in input is 0.
  2413. @section noformat
  2414. Force libavfilter not to use any of the specified pixel formats for the
  2415. input to the next filter.
  2416. The filter accepts a list of pixel format names, separated by ":",
  2417. for example "yuv420p:monow:rgb24".
  2418. Some examples follow:
  2419. @example
  2420. # force libavfilter to use a format different from "yuv420p" for the
  2421. # input to the vflip filter
  2422. noformat=yuv420p,vflip
  2423. # convert the input video to any of the formats not contained in the list
  2424. noformat=yuv420p:yuv444p:yuv410p
  2425. @end example
  2426. @section null
  2427. Pass the video source unchanged to the output.
  2428. @section ocv
  2429. Apply video transform using libopencv.
  2430. To enable this filter install libopencv library and headers and
  2431. configure FFmpeg with @code{--enable-libopencv}.
  2432. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2433. @var{filter_name} is the name of the libopencv filter to apply.
  2434. @var{filter_params} specifies the parameters to pass to the libopencv
  2435. filter. If not specified the default values are assumed.
  2436. Refer to the official libopencv documentation for more precise
  2437. information:
  2438. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2439. Follows the list of supported libopencv filters.
  2440. @anchor{dilate}
  2441. @subsection dilate
  2442. Dilate an image by using a specific structuring element.
  2443. This filter corresponds to the libopencv function @code{cvDilate}.
  2444. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2445. @var{struct_el} represents a structuring element, and has the syntax:
  2446. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2447. @var{cols} and @var{rows} represent the number of columns and rows of
  2448. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2449. point, and @var{shape} the shape for the structuring element, and
  2450. can be one of the values "rect", "cross", "ellipse", "custom".
  2451. If the value for @var{shape} is "custom", it must be followed by a
  2452. string of the form "=@var{filename}". The file with name
  2453. @var{filename} is assumed to represent a binary image, with each
  2454. printable character corresponding to a bright pixel. When a custom
  2455. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2456. or columns and rows of the read file are assumed instead.
  2457. The default value for @var{struct_el} is "3x3+0x0/rect".
  2458. @var{nb_iterations} specifies the number of times the transform is
  2459. applied to the image, and defaults to 1.
  2460. Follow some example:
  2461. @example
  2462. # use the default values
  2463. ocv=dilate
  2464. # dilate using a structuring element with a 5x5 cross, iterate two times
  2465. ocv=dilate=5x5+2x2/cross:2
  2466. # read the shape from the file diamond.shape, iterate two times
  2467. # the file diamond.shape may contain a pattern of characters like this:
  2468. # *
  2469. # ***
  2470. # *****
  2471. # ***
  2472. # *
  2473. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2474. ocv=0x0+2x2/custom=diamond.shape:2
  2475. @end example
  2476. @subsection erode
  2477. Erode an image by using a specific structuring element.
  2478. This filter corresponds to the libopencv function @code{cvErode}.
  2479. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2480. with the same syntax and semantics as the @ref{dilate} filter.
  2481. @subsection smooth
  2482. Smooth the input video.
  2483. The filter takes the following parameters:
  2484. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2485. @var{type} is the type of smooth filter to apply, and can be one of
  2486. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2487. "bilateral". The default value is "gaussian".
  2488. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2489. parameters whose meanings depend on smooth type. @var{param1} and
  2490. @var{param2} accept integer positive values or 0, @var{param3} and
  2491. @var{param4} accept float values.
  2492. The default value for @var{param1} is 3, the default value for the
  2493. other parameters is 0.
  2494. These parameters correspond to the parameters assigned to the
  2495. libopencv function @code{cvSmooth}.
  2496. @anchor{overlay}
  2497. @section overlay
  2498. Overlay one video on top of another.
  2499. It takes two inputs and one output, the first input is the "main"
  2500. video on which the second input is overlayed.
  2501. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2502. separated by ":". If the key of the first options is omitted, the
  2503. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2504. A description of the accepted options follows.
  2505. @table @option
  2506. @item x, y
  2507. Set the expression for the x and y coordinates of the overlayed video
  2508. on the main video. Default value is 0.
  2509. The @var{x} and @var{y} expressions can contain the following
  2510. parameters:
  2511. @table @option
  2512. @item main_w, main_h
  2513. main input width and height
  2514. @item W, H
  2515. same as @var{main_w} and @var{main_h}
  2516. @item overlay_w, overlay_h
  2517. overlay input width and height
  2518. @item w, h
  2519. same as @var{overlay_w} and @var{overlay_h}
  2520. @end table
  2521. @item rgb
  2522. If set to 1, force the filter to accept inputs in the RGB
  2523. color space. Default value is 0.
  2524. @end table
  2525. Be aware that frames are taken from each input video in timestamp
  2526. order, hence, if their initial timestamps differ, it is a a good idea
  2527. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2528. have them begin in the same zero timestamp, as it does the example for
  2529. the @var{movie} filter.
  2530. You can chain together more overlays but you should test the
  2531. efficiency of such approach.
  2532. @subsection Examples
  2533. @itemize
  2534. @item
  2535. Draw the overlay at 10 pixels from the bottom right corner of the main
  2536. video:
  2537. @example
  2538. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2539. @end example
  2540. Using named options the example above becomes:
  2541. @example
  2542. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2543. @end example
  2544. @item
  2545. Insert a transparent PNG logo in the bottom left corner of the input,
  2546. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2547. @example
  2548. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2549. @end example
  2550. @item
  2551. Insert 2 different transparent PNG logos (second logo on bottom
  2552. right corner) using the @command{ffmpeg} tool:
  2553. @example
  2554. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2555. @end example
  2556. @item
  2557. Add a transparent color layer on top of the main video, WxH specifies
  2558. the size of the main input to the overlay filter:
  2559. @example
  2560. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2561. @end example
  2562. @item
  2563. Play an original video and a filtered version (here with the deshake
  2564. filter) side by side using the @command{ffplay} tool:
  2565. @example
  2566. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2567. @end example
  2568. The above command is the same as:
  2569. @example
  2570. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2571. @end example
  2572. @item
  2573. Chain several overlays in cascade:
  2574. @example
  2575. nullsrc=s=200x200 [bg];
  2576. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2577. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2578. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2579. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2580. [in3] null, [mid2] overlay=100:100 [out0]
  2581. @end example
  2582. @end itemize
  2583. @section pad
  2584. Add paddings to the input image, and places the original input at the
  2585. given coordinates @var{x}, @var{y}.
  2586. It accepts the following parameters:
  2587. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2588. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  2589. expressions containing the following constants:
  2590. @table @option
  2591. @item in_w, in_h
  2592. the input video width and height
  2593. @item iw, ih
  2594. same as @var{in_w} and @var{in_h}
  2595. @item out_w, out_h
  2596. the output width and height, that is the size of the padded area as
  2597. specified by the @var{width} and @var{height} expressions
  2598. @item ow, oh
  2599. same as @var{out_w} and @var{out_h}
  2600. @item x, y
  2601. x and y offsets as specified by the @var{x} and @var{y}
  2602. expressions, or NAN if not yet specified
  2603. @item a
  2604. same as @var{iw} / @var{ih}
  2605. @item sar
  2606. input sample aspect ratio
  2607. @item dar
  2608. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2609. @item hsub, vsub
  2610. horizontal and vertical chroma subsample values. For example for the
  2611. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2612. @end table
  2613. Follows the description of the accepted parameters.
  2614. @table @option
  2615. @item width, height
  2616. Specify the size of the output image with the paddings added. If the
  2617. value for @var{width} or @var{height} is 0, the corresponding input size
  2618. is used for the output.
  2619. The @var{width} expression can reference the value set by the
  2620. @var{height} expression, and vice versa.
  2621. The default value of @var{width} and @var{height} is 0.
  2622. @item x, y
  2623. Specify the offsets where to place the input image in the padded area
  2624. with respect to the top/left border of the output image.
  2625. The @var{x} expression can reference the value set by the @var{y}
  2626. expression, and vice versa.
  2627. The default value of @var{x} and @var{y} is 0.
  2628. @item color
  2629. Specify the color of the padded area, it can be the name of a color
  2630. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2631. The default value of @var{color} is "black".
  2632. @end table
  2633. @subsection Examples
  2634. @itemize
  2635. @item
  2636. Add paddings with color "violet" to the input video. Output video
  2637. size is 640x480, the top-left corner of the input video is placed at
  2638. column 0, row 40:
  2639. @example
  2640. pad=640:480:0:40:violet
  2641. @end example
  2642. @item
  2643. Pad the input to get an output with dimensions increased by 3/2,
  2644. and put the input video at the center of the padded area:
  2645. @example
  2646. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  2647. @end example
  2648. @item
  2649. Pad the input to get a squared output with size equal to the maximum
  2650. value between the input width and height, and put the input video at
  2651. the center of the padded area:
  2652. @example
  2653. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  2654. @end example
  2655. @item
  2656. Pad the input to get a final w/h ratio of 16:9:
  2657. @example
  2658. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  2659. @end example
  2660. @item
  2661. In case of anamorphic video, in order to set the output display aspect
  2662. correctly, it is necessary to use @var{sar} in the expression,
  2663. according to the relation:
  2664. @example
  2665. (ih * X / ih) * sar = output_dar
  2666. X = output_dar / sar
  2667. @end example
  2668. Thus the previous example needs to be modified to:
  2669. @example
  2670. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  2671. @end example
  2672. @item
  2673. Double output size and put the input video in the bottom-right
  2674. corner of the output padded area:
  2675. @example
  2676. pad="2*iw:2*ih:ow-iw:oh-ih"
  2677. @end example
  2678. @end itemize
  2679. @section pixdesctest
  2680. Pixel format descriptor test filter, mainly useful for internal
  2681. testing. The output video should be equal to the input video.
  2682. For example:
  2683. @example
  2684. format=monow, pixdesctest
  2685. @end example
  2686. can be used to test the monowhite pixel format descriptor definition.
  2687. @section pp
  2688. Enable the specified chain of postprocessing subfilters using libpostproc. This
  2689. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  2690. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  2691. Each subfilter and some options have a short and a long name that can be used
  2692. interchangeably, i.e. dr/dering are the same.
  2693. All subfilters share common options to determine their scope:
  2694. @table @option
  2695. @item a/autoq
  2696. Honor the quality commands for this subfilter.
  2697. @item c/chrom
  2698. Do chrominance filtering, too (default).
  2699. @item y/nochrom
  2700. Do luminance filtering only (no chrominance).
  2701. @item n/noluma
  2702. Do chrominance filtering only (no luminance).
  2703. @end table
  2704. These options can be appended after the subfilter name, separated by a ':'.
  2705. Available subfilters are:
  2706. @table @option
  2707. @item hb/hdeblock[:difference[:flatness]]
  2708. Horizontal deblocking filter
  2709. @table @option
  2710. @item difference
  2711. Difference factor where higher values mean more deblocking (default: @code{32}).
  2712. @item flatness
  2713. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2714. @end table
  2715. @item vb/vdeblock[:difference[:flatness]]
  2716. Vertical deblocking filter
  2717. @table @option
  2718. @item difference
  2719. Difference factor where higher values mean more deblocking (default: @code{32}).
  2720. @item flatness
  2721. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2722. @end table
  2723. @item ha/hadeblock[:difference[:flatness]]
  2724. Accurate horizontal deblocking filter
  2725. @table @option
  2726. @item difference
  2727. Difference factor where higher values mean more deblocking (default: @code{32}).
  2728. @item flatness
  2729. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2730. @end table
  2731. @item va/vadeblock[:difference[:flatness]]
  2732. Accurate vertical deblocking filter
  2733. @table @option
  2734. @item difference
  2735. Difference factor where higher values mean more deblocking (default: @code{32}).
  2736. @item flatness
  2737. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2738. @end table
  2739. @end table
  2740. The horizontal and vertical deblocking filters share the difference and
  2741. flatness values so you cannot set different horizontal and vertical
  2742. thresholds.
  2743. @table @option
  2744. @item h1/x1hdeblock
  2745. Experimental horizontal deblocking filter
  2746. @item v1/x1vdeblock
  2747. Experimental vertical deblocking filter
  2748. @item dr/dering
  2749. Deringing filter
  2750. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  2751. @table @option
  2752. @item threshold1
  2753. larger -> stronger filtering
  2754. @item threshold2
  2755. larger -> stronger filtering
  2756. @item threshold3
  2757. larger -> stronger filtering
  2758. @end table
  2759. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  2760. @table @option
  2761. @item f/fullyrange
  2762. Stretch luminance to @code{0-255}.
  2763. @end table
  2764. @item lb/linblenddeint
  2765. Linear blend deinterlacing filter that deinterlaces the given block by
  2766. filtering all lines with a @code{(1 2 1)} filter.
  2767. @item li/linipoldeint
  2768. Linear interpolating deinterlacing filter that deinterlaces the given block by
  2769. linearly interpolating every second line.
  2770. @item ci/cubicipoldeint
  2771. Cubic interpolating deinterlacing filter deinterlaces the given block by
  2772. cubically interpolating every second line.
  2773. @item md/mediandeint
  2774. Median deinterlacing filter that deinterlaces the given block by applying a
  2775. median filter to every second line.
  2776. @item fd/ffmpegdeint
  2777. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  2778. second line with a @code{(-1 4 2 4 -1)} filter.
  2779. @item l5/lowpass5
  2780. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  2781. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  2782. @item fq/forceQuant[:quantizer]
  2783. Overrides the quantizer table from the input with the constant quantizer you
  2784. specify.
  2785. @table @option
  2786. @item quantizer
  2787. Quantizer to use
  2788. @end table
  2789. @item de/default
  2790. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  2791. @item fa/fast
  2792. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  2793. @item ac
  2794. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  2795. @end table
  2796. @subsection Examples
  2797. @itemize
  2798. @item
  2799. Apply horizontal and vertical deblocking, deringing and automatic
  2800. brightness/contrast:
  2801. @example
  2802. pp=hb/vb/dr/al
  2803. @end example
  2804. @item
  2805. Apply default filters without brightness/contrast correction:
  2806. @example
  2807. pp=de/-al
  2808. @end example
  2809. @item
  2810. Apply default filters and temporal denoiser:
  2811. @example
  2812. pp=default/tmpnoise:1:2:3
  2813. @end example
  2814. @item
  2815. Apply deblocking on luminance only, and switch vertical deblocking on or off
  2816. automatically depending on available CPU time:
  2817. @example
  2818. pp=hb:y/vb:a
  2819. @end example
  2820. @end itemize
  2821. @section removelogo
  2822. Suppress a TV station logo, using an image file to determine which
  2823. pixels comprise the logo. It works by filling in the pixels that
  2824. comprise the logo with neighboring pixels.
  2825. This filter requires one argument which specifies the filter bitmap
  2826. file, which can be any image format supported by libavformat. The
  2827. width and height of the image file must match those of the video
  2828. stream being processed.
  2829. Pixels in the provided bitmap image with a value of zero are not
  2830. considered part of the logo, non-zero pixels are considered part of
  2831. the logo. If you use white (255) for the logo and black (0) for the
  2832. rest, you will be safe. For making the filter bitmap, it is
  2833. recommended to take a screen capture of a black frame with the logo
  2834. visible, and then using a threshold filter followed by the erode
  2835. filter once or twice.
  2836. If needed, little splotches can be fixed manually. Remember that if
  2837. logo pixels are not covered, the filter quality will be much
  2838. reduced. Marking too many pixels as part of the logo does not hurt as
  2839. much, but it will increase the amount of blurring needed to cover over
  2840. the image and will destroy more information than necessary, and extra
  2841. pixels will slow things down on a large logo.
  2842. @section scale
  2843. Scale (resize) the input video, using the libswscale library.
  2844. The scale filter forces the output display aspect ratio to be the same
  2845. of the input, by changing the output sample aspect ratio.
  2846. This filter accepts a list of named options in the form of
  2847. @var{key}=@var{value} pairs separated by ":". If the key for the first
  2848. two options is not specified, the assumed keys for the first two
  2849. values are @code{w} and @code{h}. If the first option has no key and
  2850. can be interpreted like a video size specification, it will be used
  2851. to set the video size.
  2852. A description of the accepted options follows.
  2853. @table @option
  2854. @item width, w
  2855. Set the video width expression, default value is @code{iw}. See below
  2856. for the list of accepted constants.
  2857. @item height, h
  2858. Set the video heiht expression, default value is @code{ih}.
  2859. See below for the list of accepted constants.
  2860. @item interl
  2861. Set the interlacing. It accepts the following values:
  2862. @table @option
  2863. @item 1
  2864. force interlaced aware scaling
  2865. @item 0
  2866. do not apply interlaced scaling
  2867. @item -1
  2868. select interlaced aware scaling depending on whether the source frames
  2869. are flagged as interlaced or not
  2870. @end table
  2871. Default value is @code{0}.
  2872. @item flags
  2873. Set libswscale scaling flags. If not explictly specified the filter
  2874. applies a bilinear scaling algorithm.
  2875. @item size, s
  2876. Set the video size, the value must be a valid abbreviation or in the
  2877. form @var{width}x@var{height}.
  2878. @end table
  2879. The values of the @var{w} and @var{h} options are expressions
  2880. containing the following constants:
  2881. @table @option
  2882. @item in_w, in_h
  2883. the input width and height
  2884. @item iw, ih
  2885. same as @var{in_w} and @var{in_h}
  2886. @item out_w, out_h
  2887. the output (cropped) width and height
  2888. @item ow, oh
  2889. same as @var{out_w} and @var{out_h}
  2890. @item a
  2891. same as @var{iw} / @var{ih}
  2892. @item sar
  2893. input sample aspect ratio
  2894. @item dar
  2895. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2896. @item hsub, vsub
  2897. horizontal and vertical chroma subsample values. For example for the
  2898. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2899. @end table
  2900. If the input image format is different from the format requested by
  2901. the next filter, the scale filter will convert the input to the
  2902. requested format.
  2903. If the value for @var{width} or @var{height} is 0, the respective input
  2904. size is used for the output.
  2905. If the value for @var{width} or @var{height} is -1, the scale filter will
  2906. use, for the respective output size, a value that maintains the aspect
  2907. ratio of the input image.
  2908. @subsection Examples
  2909. @itemize
  2910. @item
  2911. Scale the input video to a size of 200x100:
  2912. @example
  2913. scale=200:100
  2914. @end example
  2915. This is equivalent to:
  2916. @example
  2917. scale=w=200:h=100
  2918. @end example
  2919. or:
  2920. @example
  2921. scale=200x100
  2922. @end example
  2923. @item
  2924. Specify a size abbreviation for the output size:
  2925. @example
  2926. scale=qcif
  2927. @end example
  2928. which can also be written as:
  2929. @example
  2930. scale=size=qcif
  2931. @end example
  2932. @item
  2933. Scale the input to 2x:
  2934. @example
  2935. scale=2*iw:2*ih
  2936. @end example
  2937. @item
  2938. The above is the same as:
  2939. @example
  2940. scale=2*in_w:2*in_h
  2941. @end example
  2942. @item
  2943. Scale the input to 2x with forced interlaced scaling:
  2944. @example
  2945. scale=2*iw:2*ih:interl=1
  2946. @end example
  2947. @item
  2948. Scale the input to half size:
  2949. @example
  2950. scale=iw/2:ih/2
  2951. @end example
  2952. @item
  2953. Increase the width, and set the height to the same size:
  2954. @example
  2955. scale=3/2*iw:ow
  2956. @end example
  2957. @item
  2958. Seek for Greek harmony:
  2959. @example
  2960. scale=iw:1/PHI*iw
  2961. scale=ih*PHI:ih
  2962. @end example
  2963. @item
  2964. Increase the height, and set the width to 3/2 of the height:
  2965. @example
  2966. scale=3/2*oh:3/5*ih
  2967. @end example
  2968. @item
  2969. Increase the size, but make the size a multiple of the chroma:
  2970. @example
  2971. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  2972. @end example
  2973. @item
  2974. Increase the width to a maximum of 500 pixels, keep the same input
  2975. aspect ratio:
  2976. @example
  2977. scale='min(500\, iw*3/2):-1'
  2978. @end example
  2979. @end itemize
  2980. @section setdar, setsar
  2981. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  2982. output video.
  2983. This is done by changing the specified Sample (aka Pixel) Aspect
  2984. Ratio, according to the following equation:
  2985. @example
  2986. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  2987. @end example
  2988. Keep in mind that the @code{setdar} filter does not modify the pixel
  2989. dimensions of the video frame. Also the display aspect ratio set by
  2990. this filter may be changed by later filters in the filterchain,
  2991. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  2992. applied.
  2993. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  2994. the filter output video.
  2995. Note that as a consequence of the application of this filter, the
  2996. output display aspect ratio will change according to the equation
  2997. above.
  2998. Keep in mind that the sample aspect ratio set by the @code{setsar}
  2999. filter may be changed by later filters in the filterchain, e.g. if
  3000. another "setsar" or a "setdar" filter is applied.
  3001. The @code{setdar} and @code{setsar} filters accept a string in the
  3002. form @var{num}:@var{den} expressing an aspect ratio, or the following
  3003. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  3004. separated by ":".
  3005. @table @option
  3006. @item max
  3007. Set the maximum integer value to use for expressing numerator and
  3008. denominator when reducing the expressed aspect ratio to a rational.
  3009. Default value is @code{100}.
  3010. @item r, ratio:
  3011. Set the aspect ratio used by the filter.
  3012. The parameter can be a floating point number string, an expression, or
  3013. a string of the form @var{num}:@var{den}, where @var{num} and
  3014. @var{den} are the numerator and denominator of the aspect ratio. If
  3015. the parameter is not specified, it is assumed the value "0".
  3016. In case the form "@var{num}:@var{den}" the @code{:} character should
  3017. be escaped.
  3018. @end table
  3019. If the keys are omitted in the named options list, the specifed values
  3020. are assumed to be @var{ratio} and @var{max} in that order.
  3021. For example to change the display aspect ratio to 16:9, specify:
  3022. @example
  3023. setdar='16:9'
  3024. @end example
  3025. The example above is equivalent to:
  3026. @example
  3027. setdar=1.77777
  3028. @end example
  3029. To change the sample aspect ratio to 10:11, specify:
  3030. @example
  3031. setsar='10:11'
  3032. @end example
  3033. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  3034. 1000 in the aspect ratio reduction, use the command:
  3035. @example
  3036. setdar=ratio='16:9':max=1000
  3037. @end example
  3038. @section setfield
  3039. Force field for the output video frame.
  3040. The @code{setfield} filter marks the interlace type field for the
  3041. output frames. It does not change the input frame, but only sets the
  3042. corresponding property, which affects how the frame is treated by
  3043. following filters (e.g. @code{fieldorder} or @code{yadif}).
  3044. This filter accepts a single option @option{mode}, which can be
  3045. specified either by setting @code{mode=VALUE} or setting the value
  3046. alone. Available values are:
  3047. @table @samp
  3048. @item auto
  3049. Keep the same field property.
  3050. @item bff
  3051. Mark the frame as bottom-field-first.
  3052. @item tff
  3053. Mark the frame as top-field-first.
  3054. @item prog
  3055. Mark the frame as progressive.
  3056. @end table
  3057. @section showinfo
  3058. Show a line containing various information for each input video frame.
  3059. The input video is not modified.
  3060. The shown line contains a sequence of key/value pairs of the form
  3061. @var{key}:@var{value}.
  3062. A description of each shown parameter follows:
  3063. @table @option
  3064. @item n
  3065. sequential number of the input frame, starting from 0
  3066. @item pts
  3067. Presentation TimeStamp of the input frame, expressed as a number of
  3068. time base units. The time base unit depends on the filter input pad.
  3069. @item pts_time
  3070. Presentation TimeStamp of the input frame, expressed as a number of
  3071. seconds
  3072. @item pos
  3073. position of the frame in the input stream, -1 if this information in
  3074. unavailable and/or meaningless (for example in case of synthetic video)
  3075. @item fmt
  3076. pixel format name
  3077. @item sar
  3078. sample aspect ratio of the input frame, expressed in the form
  3079. @var{num}/@var{den}
  3080. @item s
  3081. size of the input frame, expressed in the form
  3082. @var{width}x@var{height}
  3083. @item i
  3084. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3085. for bottom field first)
  3086. @item iskey
  3087. 1 if the frame is a key frame, 0 otherwise
  3088. @item type
  3089. picture type of the input frame ("I" for an I-frame, "P" for a
  3090. P-frame, "B" for a B-frame, "?" for unknown type).
  3091. Check also the documentation of the @code{AVPictureType} enum and of
  3092. the @code{av_get_picture_type_char} function defined in
  3093. @file{libavutil/avutil.h}.
  3094. @item checksum
  3095. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3096. @item plane_checksum
  3097. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3098. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3099. @end table
  3100. @section smartblur
  3101. Blur the input video without impacting the outlines.
  3102. The filter accepts the following parameters:
  3103. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3104. Parameters prefixed by @var{luma} indicate that they work on the
  3105. luminance of the pixels whereas parameters prefixed by @var{chroma}
  3106. refer to the chrominance of the pixels.
  3107. If the chroma parameters are not set, the luma parameters are used for
  3108. either the luminance and the chrominance of the pixels.
  3109. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  3110. range [0.1,5.0] that specifies the variance of the gaussian filter
  3111. used to blur the image (slower if larger).
  3112. @var{luma_strength} or @var{chroma_strength} must be a float number in
  3113. the range [-1.0,1.0] that configures the blurring. A value included in
  3114. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  3115. will sharpen the image.
  3116. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  3117. the range [-30,30] that is used as a coefficient to determine whether
  3118. a pixel should be blurred or not. A value of 0 will filter all the
  3119. image, a value included in [0,30] will filter flat areas and a value
  3120. included in [-30,0] will filter edges.
  3121. @anchor{subtitles}
  3122. @section subtitles
  3123. Draw subtitles on top of input video using the libass library.
  3124. To enable compilation of this filter you need to configure FFmpeg with
  3125. @code{--enable-libass}. This filter also requires a build with libavcodec and
  3126. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  3127. Alpha) subtitles format.
  3128. This filter accepts the following named options, expressed as a
  3129. sequence of @var{key}=@var{value} pairs, separated by ":".
  3130. @table @option
  3131. @item filename, f
  3132. Set the filename of the subtitle file to read. It must be specified.
  3133. @item original_size
  3134. Specify the size of the original video, the video for which the ASS file
  3135. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  3136. necessary to correctly scale the fonts if the aspect ratio has been changed.
  3137. @end table
  3138. If the first key is not specified, it is assumed that the first value
  3139. specifies the @option{filename}.
  3140. For example, to render the file @file{sub.srt} on top of the input
  3141. video, use the command:
  3142. @example
  3143. subtitles=sub.srt
  3144. @end example
  3145. which is equivalent to:
  3146. @example
  3147. subtitles=filename=sub.srt
  3148. @end example
  3149. @section split
  3150. Split input video into several identical outputs.
  3151. The filter accepts a single parameter which specifies the number of outputs. If
  3152. unspecified, it defaults to 2.
  3153. For example
  3154. @example
  3155. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  3156. @end example
  3157. will create 5 copies of the input video.
  3158. For example:
  3159. @example
  3160. [in] split [splitout1][splitout2];
  3161. [splitout1] crop=100:100:0:0 [cropout];
  3162. [splitout2] pad=200:200:100:100 [padout];
  3163. @end example
  3164. will create two separate outputs from the same input, one cropped and
  3165. one padded.
  3166. @section super2xsai
  3167. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3168. Interpolate) pixel art scaling algorithm.
  3169. Useful for enlarging pixel art images without reducing sharpness.
  3170. @section swapuv
  3171. Swap U & V plane.
  3172. @section thumbnail
  3173. Select the most representative frame in a given sequence of consecutive frames.
  3174. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3175. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3176. the next batch of @var{N} frames until the end.
  3177. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3178. value will result in a higher memory usage, so a high value is not recommended.
  3179. The following example extract one picture each 50 frames:
  3180. @example
  3181. thumbnail=50
  3182. @end example
  3183. Complete example of a thumbnail creation with @command{ffmpeg}:
  3184. @example
  3185. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3186. @end example
  3187. @section tile
  3188. Tile several successive frames together.
  3189. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3190. separated by ":". A description of the accepted options follows.
  3191. @table @option
  3192. @item layout
  3193. Set the grid size (i.e. the number of lines and columns) in the form
  3194. "@var{w}x@var{h}".
  3195. @item margin
  3196. Set the outer border margin in pixels.
  3197. @item padding
  3198. Set the inner border thickness (i.e. the number of pixels between frames). For
  3199. more advanced padding options (such as having different values for the edges),
  3200. refer to the pad video filter.
  3201. @item nb_frames
  3202. Set the maximum number of frames to render in the given area. It must be less
  3203. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3204. the area will be used.
  3205. @end table
  3206. Alternatively, the options can be specified as a flat string:
  3207. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3208. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  3209. nokey}) in a movie:
  3210. @example
  3211. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3212. @end example
  3213. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3214. duplicating each output frame to accomodate the originally detected frame
  3215. rate.
  3216. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3217. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3218. mixed flat and named options:
  3219. @example
  3220. tile=3x2:nb_frames=5:padding=7:margin=2
  3221. @end example
  3222. @section tinterlace
  3223. Perform various types of temporal field interlacing.
  3224. Frames are counted starting from 1, so the first input frame is
  3225. considered odd.
  3226. This filter accepts options in the form of @var{key}=@var{value} pairs
  3227. separated by ":".
  3228. Alternatively, the @var{mode} option can be specified as a value alone,
  3229. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3230. pairs.
  3231. A description of the accepted options follows.
  3232. @table @option
  3233. @item mode
  3234. Specify the mode of the interlacing. This option can also be specified
  3235. as a value alone. See below for a list of values for this option.
  3236. Available values are:
  3237. @table @samp
  3238. @item merge, 0
  3239. Move odd frames into the upper field, even into the lower field,
  3240. generating a double height frame at half framerate.
  3241. @item drop_odd, 1
  3242. Only output even frames, odd frames are dropped, generating a frame with
  3243. unchanged height at half framerate.
  3244. @item drop_even, 2
  3245. Only output odd frames, even frames are dropped, generating a frame with
  3246. unchanged height at half framerate.
  3247. @item pad, 3
  3248. Expand each frame to full height, but pad alternate lines with black,
  3249. generating a frame with double height at the same input framerate.
  3250. @item interleave_top, 4
  3251. Interleave the upper field from odd frames with the lower field from
  3252. even frames, generating a frame with unchanged height at half framerate.
  3253. @item interleave_bottom, 5
  3254. Interleave the lower field from odd frames with the upper field from
  3255. even frames, generating a frame with unchanged height at half framerate.
  3256. @item interlacex2, 6
  3257. Double frame rate with unchanged height. Frames are inserted each
  3258. containing the second temporal field from the previous input frame and
  3259. the first temporal field from the next input frame. This mode relies on
  3260. the top_field_first flag. Useful for interlaced video displays with no
  3261. field synchronisation.
  3262. @end table
  3263. Numeric values are deprecated but are accepted for backward
  3264. compatibility reasons.
  3265. Default mode is @code{merge}.
  3266. @item flags
  3267. Specify flags influencing the filter process.
  3268. Available value for @var{flags} is:
  3269. @table @option
  3270. @item low_pass_filter, vlfp
  3271. Enable vertical low-pass filtering in the filter.
  3272. Vertical low-pass filtering is required when creating an interlaced
  3273. destination from a progressive source which contains high-frequency
  3274. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3275. patterning.
  3276. Vertical low-pass filtering can only be enabled for @option{mode}
  3277. @var{interleave_top} and @var{interleave_bottom}.
  3278. @end table
  3279. @end table
  3280. @section transpose
  3281. Transpose rows with columns in the input video and optionally flip it.
  3282. The filter accepts parameters as a list of @var{key}=@var{value}
  3283. pairs, separated by ':'. If the key of the first options is omitted,
  3284. the arguments are interpreted according to the syntax
  3285. @var{dir}:@var{passthrough}.
  3286. @table @option
  3287. @item dir
  3288. Specify the transposition direction. Can assume the following values:
  3289. @table @samp
  3290. @item 0, 4
  3291. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3292. @example
  3293. L.R L.l
  3294. . . -> . .
  3295. l.r R.r
  3296. @end example
  3297. @item 1, 5
  3298. Rotate by 90 degrees clockwise, that is:
  3299. @example
  3300. L.R l.L
  3301. . . -> . .
  3302. l.r r.R
  3303. @end example
  3304. @item 2, 6
  3305. Rotate by 90 degrees counterclockwise, that is:
  3306. @example
  3307. L.R R.r
  3308. . . -> . .
  3309. l.r L.l
  3310. @end example
  3311. @item 3, 7
  3312. Rotate by 90 degrees clockwise and vertically flip, that is:
  3313. @example
  3314. L.R r.R
  3315. . . -> . .
  3316. l.r l.L
  3317. @end example
  3318. @end table
  3319. For values between 4-7, the transposition is only done if the input
  3320. video geometry is portrait and not landscape. These values are
  3321. deprecated, the @code{passthrough} option should be used instead.
  3322. @item passthrough
  3323. Do not apply the transposition if the input geometry matches the one
  3324. specified by the specified value. It accepts the following values:
  3325. @table @samp
  3326. @item none
  3327. Always apply transposition.
  3328. @item portrait
  3329. Preserve portrait geometry (when @var{height} >= @var{width}).
  3330. @item landscape
  3331. Preserve landscape geometry (when @var{width} >= @var{height}).
  3332. @end table
  3333. Default value is @code{none}.
  3334. @end table
  3335. For example to rotate by 90 degrees clockwise and preserve portrait
  3336. layout:
  3337. @example
  3338. transpose=dir=1:passthrough=portrait
  3339. @end example
  3340. The command above can also be specified as:
  3341. @example
  3342. transpose=1:portrait
  3343. @end example
  3344. @section unsharp
  3345. Sharpen or blur the input video.
  3346. It accepts the following parameters:
  3347. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3348. Negative values for the amount will blur the input video, while positive
  3349. values will sharpen. All parameters are optional and default to the
  3350. equivalent of the string '5:5:1.0:5:5:0.0'.
  3351. @table @option
  3352. @item luma_msize_x
  3353. Set the luma matrix horizontal size. It can be an integer between 3
  3354. and 13, default value is 5.
  3355. @item luma_msize_y
  3356. Set the luma matrix vertical size. It can be an integer between 3
  3357. and 13, default value is 5.
  3358. @item luma_amount
  3359. Set the luma effect strength. It can be a float number between -2.0
  3360. and 5.0, default value is 1.0.
  3361. @item chroma_msize_x
  3362. Set the chroma matrix horizontal size. It can be an integer between 3
  3363. and 13, default value is 5.
  3364. @item chroma_msize_y
  3365. Set the chroma matrix vertical size. It can be an integer between 3
  3366. and 13, default value is 5.
  3367. @item chroma_amount
  3368. Set the chroma effect strength. It can be a float number between -2.0
  3369. and 5.0, default value is 0.0.
  3370. @end table
  3371. @example
  3372. # Strong luma sharpen effect parameters
  3373. unsharp=7:7:2.5
  3374. # Strong blur of both luma and chroma parameters
  3375. unsharp=7:7:-2:7:7:-2
  3376. # Use the default values with @command{ffmpeg}
  3377. ffmpeg -i in.avi -vf "unsharp" out.mp4
  3378. @end example
  3379. @section vflip
  3380. Flip the input video vertically.
  3381. @example
  3382. ffmpeg -i in.avi -vf "vflip" out.avi
  3383. @end example
  3384. @section yadif
  3385. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3386. filter").
  3387. The filter accepts parameters as a list of @var{key}=@var{value}
  3388. pairs, separated by ":". If the key of the first options is omitted,
  3389. the arguments are interpreted according to syntax
  3390. @var{mode}:@var{parity}:@var{deint}.
  3391. The description of the accepted parameters follows.
  3392. @table @option
  3393. @item mode
  3394. Specify the interlacing mode to adopt. Accept one of the following
  3395. values:
  3396. @table @option
  3397. @item 0, send_frame
  3398. output 1 frame for each frame
  3399. @item 1, send_field
  3400. output 1 frame for each field
  3401. @item 2, send_frame_nospatial
  3402. like @code{send_frame} but skip spatial interlacing check
  3403. @item 3, send_field_nospatial
  3404. like @code{send_field} but skip spatial interlacing check
  3405. @end table
  3406. Default value is @code{send_frame}.
  3407. @item parity
  3408. Specify the picture field parity assumed for the input interlaced
  3409. video. Accept one of the following values:
  3410. @table @option
  3411. @item 0, tff
  3412. assume top field first
  3413. @item 1, bff
  3414. assume bottom field first
  3415. @item -1, auto
  3416. enable automatic detection
  3417. @end table
  3418. Default value is @code{auto}.
  3419. If interlacing is unknown or decoder does not export this information,
  3420. top field first will be assumed.
  3421. @item deint
  3422. Specify which frames to deinterlace. Accept one of the following
  3423. values:
  3424. @table @option
  3425. @item 0, all
  3426. deinterlace all frames
  3427. @item 1, interlaced
  3428. only deinterlace frames marked as interlaced
  3429. @end table
  3430. Default value is @code{all}.
  3431. @end table
  3432. @c man end VIDEO FILTERS
  3433. @chapter Video Sources
  3434. @c man begin VIDEO SOURCES
  3435. Below is a description of the currently available video sources.
  3436. @section buffer
  3437. Buffer video frames, and make them available to the filter chain.
  3438. This source is mainly intended for a programmatic use, in particular
  3439. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3440. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3441. separated by ":". A description of the accepted options follows.
  3442. @table @option
  3443. @item video_size
  3444. Specify the size (width and height) of the buffered video frames.
  3445. @item pix_fmt
  3446. A string representing the pixel format of the buffered video frames.
  3447. It may be a number corresponding to a pixel format, or a pixel format
  3448. name.
  3449. @item time_base
  3450. Specify the timebase assumed by the timestamps of the buffered frames.
  3451. @item time_base
  3452. Specify the frame rate expected for the video stream.
  3453. @item pixel_aspect
  3454. Specify the sample aspect ratio assumed by the video frames.
  3455. @item sws_param
  3456. Specify the optional parameters to be used for the scale filter which
  3457. is automatically inserted when an input change is detected in the
  3458. input size or format.
  3459. @end table
  3460. For example:
  3461. @example
  3462. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3463. @end example
  3464. will instruct the source to accept video frames with size 320x240 and
  3465. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3466. square pixels (1:1 sample aspect ratio).
  3467. Since the pixel format with name "yuv410p" corresponds to the number 6
  3468. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3469. this example corresponds to:
  3470. @example
  3471. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3472. @end example
  3473. Alternatively, the options can be specified as a flat string, but this
  3474. syntax is deprecated:
  3475. @var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
  3476. @section cellauto
  3477. Create a pattern generated by an elementary cellular automaton.
  3478. The initial state of the cellular automaton can be defined through the
  3479. @option{filename}, and @option{pattern} options. If such options are
  3480. not specified an initial state is created randomly.
  3481. At each new frame a new row in the video is filled with the result of
  3482. the cellular automaton next generation. The behavior when the whole
  3483. frame is filled is defined by the @option{scroll} option.
  3484. This source accepts a list of options in the form of
  3485. @var{key}=@var{value} pairs separated by ":". A description of the
  3486. accepted options follows.
  3487. @table @option
  3488. @item filename, f
  3489. Read the initial cellular automaton state, i.e. the starting row, from
  3490. the specified file.
  3491. In the file, each non-whitespace character is considered an alive
  3492. cell, a newline will terminate the row, and further characters in the
  3493. file will be ignored.
  3494. @item pattern, p
  3495. Read the initial cellular automaton state, i.e. the starting row, from
  3496. the specified string.
  3497. Each non-whitespace character in the string is considered an alive
  3498. cell, a newline will terminate the row, and further characters in the
  3499. string will be ignored.
  3500. @item rate, r
  3501. Set the video rate, that is the number of frames generated per second.
  3502. Default is 25.
  3503. @item random_fill_ratio, ratio
  3504. Set the random fill ratio for the initial cellular automaton row. It
  3505. is a floating point number value ranging from 0 to 1, defaults to
  3506. 1/PHI.
  3507. This option is ignored when a file or a pattern is specified.
  3508. @item random_seed, seed
  3509. Set the seed for filling randomly the initial row, must be an integer
  3510. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3511. set to -1, the filter will try to use a good random seed on a best
  3512. effort basis.
  3513. @item rule
  3514. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3515. Default value is 110.
  3516. @item size, s
  3517. Set the size of the output video.
  3518. If @option{filename} or @option{pattern} is specified, the size is set
  3519. by default to the width of the specified initial state row, and the
  3520. height is set to @var{width} * PHI.
  3521. If @option{size} is set, it must contain the width of the specified
  3522. pattern string, and the specified pattern will be centered in the
  3523. larger row.
  3524. If a filename or a pattern string is not specified, the size value
  3525. defaults to "320x518" (used for a randomly generated initial state).
  3526. @item scroll
  3527. If set to 1, scroll the output upward when all the rows in the output
  3528. have been already filled. If set to 0, the new generated row will be
  3529. written over the top row just after the bottom row is filled.
  3530. Defaults to 1.
  3531. @item start_full, full
  3532. If set to 1, completely fill the output with generated rows before
  3533. outputting the first frame.
  3534. This is the default behavior, for disabling set the value to 0.
  3535. @item stitch
  3536. If set to 1, stitch the left and right row edges together.
  3537. This is the default behavior, for disabling set the value to 0.
  3538. @end table
  3539. @subsection Examples
  3540. @itemize
  3541. @item
  3542. Read the initial state from @file{pattern}, and specify an output of
  3543. size 200x400.
  3544. @example
  3545. cellauto=f=pattern:s=200x400
  3546. @end example
  3547. @item
  3548. Generate a random initial row with a width of 200 cells, with a fill
  3549. ratio of 2/3:
  3550. @example
  3551. cellauto=ratio=2/3:s=200x200
  3552. @end example
  3553. @item
  3554. Create a pattern generated by rule 18 starting by a single alive cell
  3555. centered on an initial row with width 100:
  3556. @example
  3557. cellauto=p=@@:s=100x400:full=0:rule=18
  3558. @end example
  3559. @item
  3560. Specify a more elaborated initial pattern:
  3561. @example
  3562. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3563. @end example
  3564. @end itemize
  3565. @section mandelbrot
  3566. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3567. point specified with @var{start_x} and @var{start_y}.
  3568. This source accepts a list of options in the form of
  3569. @var{key}=@var{value} pairs separated by ":". A description of the
  3570. accepted options follows.
  3571. @table @option
  3572. @item end_pts
  3573. Set the terminal pts value. Default value is 400.
  3574. @item end_scale
  3575. Set the terminal scale value.
  3576. Must be a floating point value. Default value is 0.3.
  3577. @item inner
  3578. Set the inner coloring mode, that is the algorithm used to draw the
  3579. Mandelbrot fractal internal region.
  3580. It shall assume one of the following values:
  3581. @table @option
  3582. @item black
  3583. Set black mode.
  3584. @item convergence
  3585. Show time until convergence.
  3586. @item mincol
  3587. Set color based on point closest to the origin of the iterations.
  3588. @item period
  3589. Set period mode.
  3590. @end table
  3591. Default value is @var{mincol}.
  3592. @item bailout
  3593. Set the bailout value. Default value is 10.0.
  3594. @item maxiter
  3595. Set the maximum of iterations performed by the rendering
  3596. algorithm. Default value is 7189.
  3597. @item outer
  3598. Set outer coloring mode.
  3599. It shall assume one of following values:
  3600. @table @option
  3601. @item iteration_count
  3602. Set iteration cound mode.
  3603. @item normalized_iteration_count
  3604. set normalized iteration count mode.
  3605. @end table
  3606. Default value is @var{normalized_iteration_count}.
  3607. @item rate, r
  3608. Set frame rate, expressed as number of frames per second. Default
  3609. value is "25".
  3610. @item size, s
  3611. Set frame size. Default value is "640x480".
  3612. @item start_scale
  3613. Set the initial scale value. Default value is 3.0.
  3614. @item start_x
  3615. Set the initial x position. Must be a floating point value between
  3616. -100 and 100. Default value is -0.743643887037158704752191506114774.
  3617. @item start_y
  3618. Set the initial y position. Must be a floating point value between
  3619. -100 and 100. Default value is -0.131825904205311970493132056385139.
  3620. @end table
  3621. @section mptestsrc
  3622. Generate various test patterns, as generated by the MPlayer test filter.
  3623. The size of the generated video is fixed, and is 256x256.
  3624. This source is useful in particular for testing encoding features.
  3625. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  3626. separated by ":". The description of the accepted options follows.
  3627. @table @option
  3628. @item rate, r
  3629. Specify the frame rate of the sourced video, as the number of frames
  3630. generated per second. It has to be a string in the format
  3631. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3632. number or a valid video frame rate abbreviation. The default value is
  3633. "25".
  3634. @item duration, d
  3635. Set the video duration of the sourced video. The accepted syntax is:
  3636. @example
  3637. [-]HH:MM:SS[.m...]
  3638. [-]S+[.m...]
  3639. @end example
  3640. See also the function @code{av_parse_time()}.
  3641. If not specified, or the expressed duration is negative, the video is
  3642. supposed to be generated forever.
  3643. @item test, t
  3644. Set the number or the name of the test to perform. Supported tests are:
  3645. @table @option
  3646. @item dc_luma
  3647. @item dc_chroma
  3648. @item freq_luma
  3649. @item freq_chroma
  3650. @item amp_luma
  3651. @item amp_chroma
  3652. @item cbp
  3653. @item mv
  3654. @item ring1
  3655. @item ring2
  3656. @item all
  3657. @end table
  3658. Default value is "all", which will cycle through the list of all tests.
  3659. @end table
  3660. For example the following:
  3661. @example
  3662. testsrc=t=dc_luma
  3663. @end example
  3664. will generate a "dc_luma" test pattern.
  3665. @section frei0r_src
  3666. Provide a frei0r source.
  3667. To enable compilation of this filter you need to install the frei0r
  3668. header and configure FFmpeg with @code{--enable-frei0r}.
  3669. The source supports the syntax:
  3670. @example
  3671. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  3672. @end example
  3673. @var{size} is the size of the video to generate, may be a string of the
  3674. form @var{width}x@var{height} or a frame size abbreviation.
  3675. @var{rate} is the rate of the video to generate, may be a string of
  3676. the form @var{num}/@var{den} or a frame rate abbreviation.
  3677. @var{src_name} is the name to the frei0r source to load. For more
  3678. information regarding frei0r and how to set the parameters read the
  3679. section @ref{frei0r} in the description of the video filters.
  3680. For example, to generate a frei0r partik0l source with size 200x200
  3681. and frame rate 10 which is overlayed on the overlay filter main input:
  3682. @example
  3683. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  3684. @end example
  3685. @section life
  3686. Generate a life pattern.
  3687. This source is based on a generalization of John Conway's life game.
  3688. The sourced input represents a life grid, each pixel represents a cell
  3689. which can be in one of two possible states, alive or dead. Every cell
  3690. interacts with its eight neighbours, which are the cells that are
  3691. horizontally, vertically, or diagonally adjacent.
  3692. At each interaction the grid evolves according to the adopted rule,
  3693. which specifies the number of neighbor alive cells which will make a
  3694. cell stay alive or born. The @option{rule} option allows to specify
  3695. the rule to adopt.
  3696. This source accepts a list of options in the form of
  3697. @var{key}=@var{value} pairs separated by ":". A description of the
  3698. accepted options follows.
  3699. @table @option
  3700. @item filename, f
  3701. Set the file from which to read the initial grid state. In the file,
  3702. each non-whitespace character is considered an alive cell, and newline
  3703. is used to delimit the end of each row.
  3704. If this option is not specified, the initial grid is generated
  3705. randomly.
  3706. @item rate, r
  3707. Set the video rate, that is the number of frames generated per second.
  3708. Default is 25.
  3709. @item random_fill_ratio, ratio
  3710. Set the random fill ratio for the initial random grid. It is a
  3711. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  3712. It is ignored when a file is specified.
  3713. @item random_seed, seed
  3714. Set the seed for filling the initial random grid, must be an integer
  3715. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3716. set to -1, the filter will try to use a good random seed on a best
  3717. effort basis.
  3718. @item rule
  3719. Set the life rule.
  3720. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  3721. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  3722. @var{NS} specifies the number of alive neighbor cells which make a
  3723. live cell stay alive, and @var{NB} the number of alive neighbor cells
  3724. which make a dead cell to become alive (i.e. to "born").
  3725. "s" and "b" can be used in place of "S" and "B", respectively.
  3726. Alternatively a rule can be specified by an 18-bits integer. The 9
  3727. high order bits are used to encode the next cell state if it is alive
  3728. for each number of neighbor alive cells, the low order bits specify
  3729. the rule for "borning" new cells. Higher order bits encode for an
  3730. higher number of neighbor cells.
  3731. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  3732. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  3733. Default value is "S23/B3", which is the original Conway's game of life
  3734. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  3735. cells, and will born a new cell if there are three alive cells around
  3736. a dead cell.
  3737. @item size, s
  3738. Set the size of the output video.
  3739. If @option{filename} is specified, the size is set by default to the
  3740. same size of the input file. If @option{size} is set, it must contain
  3741. the size specified in the input file, and the initial grid defined in
  3742. that file is centered in the larger resulting area.
  3743. If a filename is not specified, the size value defaults to "320x240"
  3744. (used for a randomly generated initial grid).
  3745. @item stitch
  3746. If set to 1, stitch the left and right grid edges together, and the
  3747. top and bottom edges also. Defaults to 1.
  3748. @item mold
  3749. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  3750. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  3751. value from 0 to 255.
  3752. @item life_color
  3753. Set the color of living (or new born) cells.
  3754. @item death_color
  3755. Set the color of dead cells. If @option{mold} is set, this is the first color
  3756. used to represent a dead cell.
  3757. @item mold_color
  3758. Set mold color, for definitely dead and moldy cells.
  3759. @end table
  3760. @subsection Examples
  3761. @itemize
  3762. @item
  3763. Read a grid from @file{pattern}, and center it on a grid of size
  3764. 300x300 pixels:
  3765. @example
  3766. life=f=pattern:s=300x300
  3767. @end example
  3768. @item
  3769. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  3770. @example
  3771. life=ratio=2/3:s=200x200
  3772. @end example
  3773. @item
  3774. Specify a custom rule for evolving a randomly generated grid:
  3775. @example
  3776. life=rule=S14/B34
  3777. @end example
  3778. @item
  3779. Full example with slow death effect (mold) using @command{ffplay}:
  3780. @example
  3781. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  3782. @end example
  3783. @end itemize
  3784. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  3785. The @code{color} source provides an uniformly colored input.
  3786. The @code{nullsrc} source returns unprocessed video frames. It is
  3787. mainly useful to be employed in analysis / debugging tools, or as the
  3788. source for filters which ignore the input data.
  3789. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  3790. detecting RGB vs BGR issues. You should see a red, green and blue
  3791. stripe from top to bottom.
  3792. The @code{smptebars} source generates a color bars pattern, based on
  3793. the SMPTE Engineering Guideline EG 1-1990.
  3794. The @code{testsrc} source generates a test video pattern, showing a
  3795. color pattern, a scrolling gradient and a timestamp. This is mainly
  3796. intended for testing purposes.
  3797. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  3798. separated by ":". The description of the accepted options follows.
  3799. @table @option
  3800. @item color, c
  3801. Specify the color of the source, only used in the @code{color}
  3802. source. It can be the name of a color (case insensitive match) or a
  3803. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  3804. default value is "black".
  3805. @item size, s
  3806. Specify the size of the sourced video, it may be a string of the form
  3807. @var{width}x@var{height}, or the name of a size abbreviation. The
  3808. default value is "320x240".
  3809. @item rate, r
  3810. Specify the frame rate of the sourced video, as the number of frames
  3811. generated per second. It has to be a string in the format
  3812. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3813. number or a valid video frame rate abbreviation. The default value is
  3814. "25".
  3815. @item sar
  3816. Set the sample aspect ratio of the sourced video.
  3817. @item duration, d
  3818. Set the video duration of the sourced video. The accepted syntax is:
  3819. @example
  3820. [-]HH[:MM[:SS[.m...]]]
  3821. [-]S+[.m...]
  3822. @end example
  3823. See also the function @code{av_parse_time()}.
  3824. If not specified, or the expressed duration is negative, the video is
  3825. supposed to be generated forever.
  3826. @item decimals, n
  3827. Set the number of decimals to show in the timestamp, only used in the
  3828. @code{testsrc} source.
  3829. The displayed timestamp value will correspond to the original
  3830. timestamp value multiplied by the power of 10 of the specified
  3831. value. Default value is 0.
  3832. @end table
  3833. For example the following:
  3834. @example
  3835. testsrc=duration=5.3:size=qcif:rate=10
  3836. @end example
  3837. will generate a video with a duration of 5.3 seconds, with size
  3838. 176x144 and a frame rate of 10 frames per second.
  3839. The following graph description will generate a red source
  3840. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  3841. frames per second.
  3842. @example
  3843. color=c=red@@0.2:s=qcif:r=10
  3844. @end example
  3845. If the input content is to be ignored, @code{nullsrc} can be used. The
  3846. following command generates noise in the luminance plane by employing
  3847. the @code{geq} filter:
  3848. @example
  3849. nullsrc=s=256x256, geq=random(1)*255:128:128
  3850. @end example
  3851. @c man end VIDEO SOURCES
  3852. @chapter Video Sinks
  3853. @c man begin VIDEO SINKS
  3854. Below is a description of the currently available video sinks.
  3855. @section buffersink
  3856. Buffer video frames, and make them available to the end of the filter
  3857. graph.
  3858. This sink is mainly intended for a programmatic use, in particular
  3859. through the interface defined in @file{libavfilter/buffersink.h}.
  3860. It does not require a string parameter in input, but you need to
  3861. specify a pointer to a list of supported pixel formats terminated by
  3862. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  3863. when initializing this sink.
  3864. @section nullsink
  3865. Null video sink, do absolutely nothing with the input video. It is
  3866. mainly useful as a template and to be employed in analysis / debugging
  3867. tools.
  3868. @c man end VIDEO SINKS
  3869. @chapter Multimedia Filters
  3870. @c man begin MULTIMEDIA FILTERS
  3871. Below is a description of the currently available multimedia filters.
  3872. @section aselect, select
  3873. Select frames to pass in output.
  3874. These filters accept a single option @option{expr} or @option{e}
  3875. specifying the select expression, which can be specified either by
  3876. specyfing @code{expr=VALUE} or specifying the expression
  3877. alone.
  3878. The select expression is evaluated for each input frame. If the
  3879. evaluation result is a non-zero value, the frame is selected and
  3880. passed to the output, otherwise it is discarded.
  3881. The expression can contain the following constants:
  3882. @table @option
  3883. @item n
  3884. the sequential number of the filtered frame, starting from 0
  3885. @item selected_n
  3886. the sequential number of the selected frame, starting from 0
  3887. @item prev_selected_n
  3888. the sequential number of the last selected frame, NAN if undefined
  3889. @item TB
  3890. timebase of the input timestamps
  3891. @item pts
  3892. the PTS (Presentation TimeStamp) of the filtered video frame,
  3893. expressed in @var{TB} units, NAN if undefined
  3894. @item t
  3895. the PTS (Presentation TimeStamp) of the filtered video frame,
  3896. expressed in seconds, NAN if undefined
  3897. @item prev_pts
  3898. the PTS of the previously filtered video frame, NAN if undefined
  3899. @item prev_selected_pts
  3900. the PTS of the last previously filtered video frame, NAN if undefined
  3901. @item prev_selected_t
  3902. the PTS of the last previously selected video frame, NAN if undefined
  3903. @item start_pts
  3904. the PTS of the first video frame in the video, NAN if undefined
  3905. @item start_t
  3906. the time of the first video frame in the video, NAN if undefined
  3907. @item pict_type @emph{(video only)}
  3908. the type of the filtered frame, can assume one of the following
  3909. values:
  3910. @table @option
  3911. @item I
  3912. @item P
  3913. @item B
  3914. @item S
  3915. @item SI
  3916. @item SP
  3917. @item BI
  3918. @end table
  3919. @item interlace_type @emph{(video only)}
  3920. the frame interlace type, can assume one of the following values:
  3921. @table @option
  3922. @item PROGRESSIVE
  3923. the frame is progressive (not interlaced)
  3924. @item TOPFIRST
  3925. the frame is top-field-first
  3926. @item BOTTOMFIRST
  3927. the frame is bottom-field-first
  3928. @end table
  3929. @item consumed_sample_n @emph{(audio only)}
  3930. the number of selected samples before the current frame
  3931. @item samples_n @emph{(audio only)}
  3932. the number of samples in the current frame
  3933. @item sample_rate @emph{(audio only)}
  3934. the input sample rate
  3935. @item key
  3936. 1 if the filtered frame is a key-frame, 0 otherwise
  3937. @item pos
  3938. the position in the file of the filtered frame, -1 if the information
  3939. is not available (e.g. for synthetic video)
  3940. @item scene @emph{(video only)}
  3941. value between 0 and 1 to indicate a new scene; a low value reflects a low
  3942. probability for the current frame to introduce a new scene, while a higher
  3943. value means the current frame is more likely to be one (see the example below)
  3944. @end table
  3945. The default value of the select expression is "1".
  3946. @subsection Examples
  3947. @itemize
  3948. @item
  3949. Select all frames in input:
  3950. @example
  3951. select
  3952. @end example
  3953. The example above is the same as:
  3954. @example
  3955. select=1
  3956. @end example
  3957. @item
  3958. Skip all frames:
  3959. @example
  3960. select=0
  3961. @end example
  3962. @item
  3963. Select only I-frames:
  3964. @example
  3965. select='eq(pict_type\,I)'
  3966. @end example
  3967. @item
  3968. Select one frame every 100:
  3969. @example
  3970. select='not(mod(n\,100))'
  3971. @end example
  3972. @item
  3973. Select only frames contained in the 10-20 time interval:
  3974. @example
  3975. select='gte(t\,10)*lte(t\,20)'
  3976. @end example
  3977. @item
  3978. Select only I frames contained in the 10-20 time interval:
  3979. @example
  3980. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  3981. @end example
  3982. @item
  3983. Select frames with a minimum distance of 10 seconds:
  3984. @example
  3985. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  3986. @end example
  3987. @item
  3988. Use aselect to select only audio frames with samples number > 100:
  3989. @example
  3990. aselect='gt(samples_n\,100)'
  3991. @end example
  3992. @item
  3993. Create a mosaic of the first scenes:
  3994. @example
  3995. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  3996. @end example
  3997. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  3998. choice.
  3999. @end itemize
  4000. @section asendcmd, sendcmd
  4001. Send commands to filters in the filtergraph.
  4002. These filters read commands to be sent to other filters in the
  4003. filtergraph.
  4004. @code{asendcmd} must be inserted between two audio filters,
  4005. @code{sendcmd} must be inserted between two video filters, but apart
  4006. from that they act the same way.
  4007. The specification of commands can be provided in the filter arguments
  4008. with the @var{commands} option, or in a file specified by the
  4009. @var{filename} option.
  4010. These filters accept the following options:
  4011. @table @option
  4012. @item commands, c
  4013. Set the commands to be read and sent to the other filters.
  4014. @item filename, f
  4015. Set the filename of the commands to be read and sent to the other
  4016. filters.
  4017. @end table
  4018. @subsection Commands syntax
  4019. A commands description consists of a sequence of interval
  4020. specifications, comprising a list of commands to be executed when a
  4021. particular event related to that interval occurs. The occurring event
  4022. is typically the current frame time entering or leaving a given time
  4023. interval.
  4024. An interval is specified by the following syntax:
  4025. @example
  4026. @var{START}[-@var{END}] @var{COMMANDS};
  4027. @end example
  4028. The time interval is specified by the @var{START} and @var{END} times.
  4029. @var{END} is optional and defaults to the maximum time.
  4030. The current frame time is considered within the specified interval if
  4031. it is included in the interval [@var{START}, @var{END}), that is when
  4032. the time is greater or equal to @var{START} and is lesser than
  4033. @var{END}.
  4034. @var{COMMANDS} consists of a sequence of one or more command
  4035. specifications, separated by ",", relating to that interval. The
  4036. syntax of a command specification is given by:
  4037. @example
  4038. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  4039. @end example
  4040. @var{FLAGS} is optional and specifies the type of events relating to
  4041. the time interval which enable sending the specified command, and must
  4042. be a non-null sequence of identifier flags separated by "+" or "|" and
  4043. enclosed between "[" and "]".
  4044. The following flags are recognized:
  4045. @table @option
  4046. @item enter
  4047. The command is sent when the current frame timestamp enters the
  4048. specified interval. In other words, the command is sent when the
  4049. previous frame timestamp was not in the given interval, and the
  4050. current is.
  4051. @item leave
  4052. The command is sent when the current frame timestamp leaves the
  4053. specified interval. In other words, the command is sent when the
  4054. previous frame timestamp was in the given interval, and the
  4055. current is not.
  4056. @end table
  4057. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  4058. assumed.
  4059. @var{TARGET} specifies the target of the command, usually the name of
  4060. the filter class or a specific filter instance name.
  4061. @var{COMMAND} specifies the name of the command for the target filter.
  4062. @var{ARG} is optional and specifies the optional list of argument for
  4063. the given @var{COMMAND}.
  4064. Between one interval specification and another, whitespaces, or
  4065. sequences of characters starting with @code{#} until the end of line,
  4066. are ignored and can be used to annotate comments.
  4067. A simplified BNF description of the commands specification syntax
  4068. follows:
  4069. @example
  4070. @var{COMMAND_FLAG} ::= "enter" | "leave"
  4071. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  4072. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  4073. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  4074. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  4075. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  4076. @end example
  4077. @subsection Examples
  4078. @itemize
  4079. @item
  4080. Specify audio tempo change at second 4:
  4081. @example
  4082. asendcmd=c='4.0 atempo tempo 1.5',atempo
  4083. @end example
  4084. @item
  4085. Specify a list of drawtext and hue commands in a file.
  4086. @example
  4087. # show text in the interval 5-10
  4088. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  4089. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  4090. # desaturate the image in the interval 15-20
  4091. 15.0-20.0 [enter] hue reinit s=0,
  4092. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  4093. [leave] hue reinit s=1,
  4094. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  4095. # apply an exponential saturation fade-out effect, starting from time 25
  4096. 25 [enter] hue s=exp(t-25)
  4097. @end example
  4098. A filtergraph allowing to read and process the above command list
  4099. stored in a file @file{test.cmd}, can be specified with:
  4100. @example
  4101. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  4102. @end example
  4103. @end itemize
  4104. @anchor{setpts}
  4105. @section asetpts, setpts
  4106. Change the PTS (presentation timestamp) of the input frames.
  4107. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  4108. Accept in input an expression evaluated through the eval API, which
  4109. can contain the following constants:
  4110. @table @option
  4111. @item FRAME_RATE
  4112. frame rate, only defined for constant frame-rate video
  4113. @item PTS
  4114. the presentation timestamp in input
  4115. @item N
  4116. the count of the input frame, starting from 0.
  4117. @item NB_CONSUMED_SAMPLES
  4118. the number of consumed samples, not including the current frame (only
  4119. audio)
  4120. @item NB_SAMPLES
  4121. the number of samples in the current frame (only audio)
  4122. @item SAMPLE_RATE
  4123. audio sample rate
  4124. @item STARTPTS
  4125. the PTS of the first frame
  4126. @item STARTT
  4127. the time in seconds of the first frame
  4128. @item INTERLACED
  4129. tell if the current frame is interlaced
  4130. @item T
  4131. the time in seconds of the current frame
  4132. @item TB
  4133. the time base
  4134. @item POS
  4135. original position in the file of the frame, or undefined if undefined
  4136. for the current frame
  4137. @item PREV_INPTS
  4138. previous input PTS
  4139. @item PREV_INT
  4140. previous input time in seconds
  4141. @item PREV_OUTPTS
  4142. previous output PTS
  4143. @item PREV_OUTT
  4144. previous output time in seconds
  4145. @item RTCTIME
  4146. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  4147. instead.
  4148. @item RTCSTART
  4149. wallclock (RTC) time at the start of the movie in microseconds
  4150. @end table
  4151. @subsection Examples
  4152. @itemize
  4153. @item
  4154. Start counting PTS from zero
  4155. @example
  4156. setpts=PTS-STARTPTS
  4157. @end example
  4158. @item
  4159. Apply fast motion effect:
  4160. @example
  4161. setpts=0.5*PTS
  4162. @end example
  4163. @item
  4164. Apply slow motion effect:
  4165. @example
  4166. setpts=2.0*PTS
  4167. @end example
  4168. @item
  4169. Set fixed rate of 25 frames per second:
  4170. @example
  4171. setpts=N/(25*TB)
  4172. @end example
  4173. @item
  4174. Set fixed rate 25 fps with some jitter:
  4175. @example
  4176. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4177. @end example
  4178. @item
  4179. Apply an offset of 10 seconds to the input PTS:
  4180. @example
  4181. setpts=PTS+10/TB
  4182. @end example
  4183. @item
  4184. Generate timestamps from a "live source" and rebase onto the current timebase:
  4185. @example
  4186. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  4187. @end example
  4188. @end itemize
  4189. @section ebur128
  4190. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4191. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4192. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4193. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4194. The filter also has a video output (see the @var{video} option) with a real
  4195. time graph to observe the loudness evolution. The graphic contains the logged
  4196. message mentioned above, so it is not printed anymore when this option is set,
  4197. unless the verbose logging is set. The main graphing area contains the
  4198. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4199. the momentary loudness (400 milliseconds).
  4200. More information about the Loudness Recommendation EBU R128 on
  4201. @url{http://tech.ebu.ch/loudness}.
  4202. The filter accepts the following named parameters:
  4203. @table @option
  4204. @item video
  4205. Activate the video output. The audio stream is passed unchanged whether this
  4206. option is set or no. The video stream will be the first output stream if
  4207. activated. Default is @code{0}.
  4208. @item size
  4209. Set the video size. This option is for video only. Default and minimum
  4210. resolution is @code{640x480}.
  4211. @item meter
  4212. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4213. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4214. other integer value between this range is allowed.
  4215. @end table
  4216. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4217. @example
  4218. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4219. @end example
  4220. Run an analysis with @command{ffmpeg}:
  4221. @example
  4222. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4223. @end example
  4224. @section settb, asettb
  4225. Set the timebase to use for the output frames timestamps.
  4226. It is mainly useful for testing timebase configuration.
  4227. It accepts in input an arithmetic expression representing a rational.
  4228. The expression can contain the constants "AVTB" (the
  4229. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4230. audio only).
  4231. The default value for the input is "intb".
  4232. @subsection Examples
  4233. @itemize
  4234. @item
  4235. Set the timebase to 1/25:
  4236. @example
  4237. settb=1/25
  4238. @end example
  4239. @item
  4240. Set the timebase to 1/10:
  4241. @example
  4242. settb=0.1
  4243. @end example
  4244. @item
  4245. Set the timebase to 1001/1000:
  4246. @example
  4247. settb=1+0.001
  4248. @end example
  4249. @item
  4250. Set the timebase to 2*intb:
  4251. @example
  4252. settb=2*intb
  4253. @end example
  4254. @item
  4255. Set the default timebase value:
  4256. @example
  4257. settb=AVTB
  4258. @end example
  4259. @end itemize
  4260. @section concat
  4261. Concatenate audio and video streams, joining them together one after the
  4262. other.
  4263. The filter works on segments of synchronized video and audio streams. All
  4264. segments must have the same number of streams of each type, and that will
  4265. also be the number of streams at output.
  4266. The filter accepts the following named parameters:
  4267. @table @option
  4268. @item n
  4269. Set the number of segments. Default is 2.
  4270. @item v
  4271. Set the number of output video streams, that is also the number of video
  4272. streams in each segment. Default is 1.
  4273. @item a
  4274. Set the number of output audio streams, that is also the number of video
  4275. streams in each segment. Default is 0.
  4276. @item unsafe
  4277. Activate unsafe mode: do not fail if segments have a different format.
  4278. @end table
  4279. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4280. @var{a} audio outputs.
  4281. There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first
  4282. segment, in the same order as the outputs, then the inputs for the second
  4283. segment, etc.
  4284. Related streams do not always have exactly the same duration, for various
  4285. reasons including codec frame size or sloppy authoring. For that reason,
  4286. related synchronized streams (e.g. a video and its audio track) should be
  4287. concatenated at once. The concat filter will use the duration of the longest
  4288. stream in each segment (except the last one), and if necessary pad shorter
  4289. audio streams with silence.
  4290. For this filter to work correctly, all segments must start at timestamp 0.
  4291. All corresponding streams must have the same parameters in all segments; the
  4292. filtering system will automatically select a common pixel format for video
  4293. streams, and a common sample format, sample rate and channel layout for
  4294. audio streams, but other settings, such as resolution, must be converted
  4295. explicitly by the user.
  4296. Different frame rates are acceptable but will result in variable frame rate
  4297. at output; be sure to configure the output file to handle it.
  4298. Examples:
  4299. @itemize
  4300. @item
  4301. Concatenate an opening, an episode and an ending, all in bilingual version
  4302. (video in stream 0, audio in streams 1 and 2):
  4303. @example
  4304. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4305. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4306. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4307. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4308. @end example
  4309. @item
  4310. Concatenate two parts, handling audio and video separately, using the
  4311. (a)movie sources, and adjusting the resolution:
  4312. @example
  4313. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4314. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4315. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4316. @end example
  4317. Note that a desync will happen at the stitch if the audio and video streams
  4318. do not have exactly the same duration in the first file.
  4319. @end itemize
  4320. @section showspectrum
  4321. Convert input audio to a video output, representing the audio frequency
  4322. spectrum.
  4323. The filter accepts the following named parameters:
  4324. @table @option
  4325. @item size, s
  4326. Specify the video size for the output. Default value is @code{640x480}.
  4327. @item slide
  4328. Specify if the spectrum should slide along the window. Default value is
  4329. @code{0}.
  4330. @end table
  4331. The usage is very similar to the showwaves filter; see the examples in that
  4332. section.
  4333. @section showwaves
  4334. Convert input audio to a video output, representing the samples waves.
  4335. The filter accepts the following named parameters:
  4336. @table @option
  4337. @item mode
  4338. Set display mode.
  4339. Available values are:
  4340. @table @samp
  4341. @item point
  4342. Draw a point for each sample.
  4343. @item line
  4344. Draw a vertical line for each sample.
  4345. @end table
  4346. Default value is @code{point}.
  4347. @item n
  4348. Set the number of samples which are printed on the same column. A
  4349. larger value will decrease the frame rate. Must be a positive
  4350. integer. This option can be set only if the value for @var{rate}
  4351. is not explicitly specified.
  4352. @item rate, r
  4353. Set the (approximate) output frame rate. This is done by setting the
  4354. option @var{n}. Default value is "25".
  4355. @item size, s
  4356. Specify the video size for the output. Default value is "600x240".
  4357. @end table
  4358. Some examples follow.
  4359. @itemize
  4360. @item
  4361. Output the input file audio and the corresponding video representation
  4362. at the same time:
  4363. @example
  4364. amovie=a.mp3,asplit[out0],showwaves[out1]
  4365. @end example
  4366. @item
  4367. Create a synthetic signal and show it with showwaves, forcing a
  4368. framerate of 30 frames per second:
  4369. @example
  4370. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4371. @end example
  4372. @end itemize
  4373. @c man end MULTIMEDIA FILTERS
  4374. @chapter Multimedia Sources
  4375. @c man begin MULTIMEDIA SOURCES
  4376. Below is a description of the currently available multimedia sources.
  4377. @section amovie
  4378. This is the same as @ref{movie} source, except it selects an audio
  4379. stream by default.
  4380. @anchor{movie}
  4381. @section movie
  4382. Read audio and/or video stream(s) from a movie container.
  4383. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4384. @var{movie_name} is the name of the resource to read (not necessarily
  4385. a file but also a device or a stream accessed through some protocol),
  4386. and @var{options} is an optional sequence of @var{key}=@var{value}
  4387. pairs, separated by ":".
  4388. The description of the accepted options follows.
  4389. @table @option
  4390. @item format_name, f
  4391. Specifies the format assumed for the movie to read, and can be either
  4392. the name of a container or an input device. If not specified the
  4393. format is guessed from @var{movie_name} or by probing.
  4394. @item seek_point, sp
  4395. Specifies the seek point in seconds, the frames will be output
  4396. starting from this seek point, the parameter is evaluated with
  4397. @code{av_strtod} so the numerical value may be suffixed by an IS
  4398. postfix. Default value is "0".
  4399. @item streams, s
  4400. Specifies the streams to read. Several streams can be specified,
  4401. separated by "+". The source will then have as many outputs, in the
  4402. same order. The syntax is explained in the ``Stream specifiers''
  4403. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4404. respectively the default (best suited) video and audio stream. Default
  4405. is "dv", or "da" if the filter is called as "amovie".
  4406. @item stream_index, si
  4407. Specifies the index of the video stream to read. If the value is -1,
  4408. the best suited video stream will be automatically selected. Default
  4409. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4410. audio instead of video.
  4411. @item loop
  4412. Specifies how many times to read the stream in sequence.
  4413. If the value is less than 1, the stream will be read again and again.
  4414. Default value is "1".
  4415. Note that when the movie is looped the source timestamps are not
  4416. changed, so it will generate non monotonically increasing timestamps.
  4417. @end table
  4418. This filter allows to overlay a second video on top of main input of
  4419. a filtergraph as shown in this graph:
  4420. @example
  4421. input -----------> deltapts0 --> overlay --> output
  4422. ^
  4423. |
  4424. movie --> scale--> deltapts1 -------+
  4425. @end example
  4426. Some examples follow.
  4427. @itemize
  4428. @item
  4429. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4430. on top of the input labelled as "in":
  4431. @example
  4432. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4433. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4434. @end example
  4435. @item
  4436. Read from a video4linux2 device, and overlay it on top of the input
  4437. labelled as "in":
  4438. @example
  4439. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4440. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4441. @end example
  4442. @item
  4443. Read the first video stream and the audio stream with id 0x81 from
  4444. dvd.vob; the video is connected to the pad named "video" and the audio is
  4445. connected to the pad named "audio":
  4446. @example
  4447. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4448. @end example
  4449. @end itemize
  4450. @c man end MULTIMEDIA SOURCES