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.

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