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.

5663 lines
158KB

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