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.

5747 lines
161KB

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