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.

12173 lines
331KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, a filter can have multiple inputs and multiple
  5. outputs.
  6. To illustrate the sorts of things that are possible, we consider the
  7. following filtergraph.
  8. @verbatim
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end verbatim
  15. This filtergraph splits the input stream in two streams, then sends one
  16. stream through the crop filter and the vflip filter, before merging it
  17. back with the other stream by overlaying it on top. You can use the
  18. following command to achieve this:
  19. @example
  20. ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
  21. @end example
  22. The result will be that the top half of the video is mirrored
  23. onto the bottom half of the output video.
  24. Filters in the same linear chain are separated by commas, and distinct
  25. linear chains of filters are separated by semicolons. In our example,
  26. @var{crop,vflip} are in one linear chain, @var{split} and
  27. @var{overlay} are separately in another. The points where the linear
  28. chains join are labelled by names enclosed in square brackets. In the
  29. example, the split filter generates two outputs that are associated to
  30. the labels @var{[main]} and @var{[tmp]}.
  31. The stream sent to the second output of @var{split}, labelled as
  32. @var{[tmp]}, is processed through the @var{crop} filter, which crops
  33. away the lower half part of the video, and then vertically flipped. The
  34. @var{overlay} filter takes in input the first unchanged output of the
  35. split filter (which was labelled as @var{[main]}), and overlay on its
  36. lower half the output generated by the @var{crop,vflip} filterchain.
  37. Some filters take in input a list of parameters: they are specified
  38. after the filter name and an equal sign, and are separated from each other
  39. by a colon.
  40. There exist so-called @var{source filters} that do not have an
  41. audio/video input, and @var{sink filters} that will not have audio/video
  42. output.
  43. @c man end FILTERING INTRODUCTION
  44. @chapter graph2dot
  45. @c man begin GRAPH2DOT
  46. The @file{graph2dot} program included in the FFmpeg @file{tools}
  47. directory can be used to parse a filtergraph description and issue a
  48. corresponding textual representation in the dot language.
  49. Invoke the command:
  50. @example
  51. graph2dot -h
  52. @end example
  53. to see how to use @file{graph2dot}.
  54. You can then pass the dot description to the @file{dot} program (from
  55. the graphviz suite of programs) and obtain a graphical representation
  56. of the filtergraph.
  57. For example the sequence of commands:
  58. @example
  59. echo @var{GRAPH_DESCRIPTION} | \
  60. tools/graph2dot -o graph.tmp && \
  61. dot -Tpng graph.tmp -o graph.png && \
  62. display graph.png
  63. @end example
  64. can be used to create and display an image representing the graph
  65. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  66. a complete self-contained graph, with its inputs and outputs explicitly defined.
  67. For example if your command line is of the form:
  68. @example
  69. ffmpeg -i infile -vf scale=640:360 outfile
  70. @end example
  71. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  72. @example
  73. nullsrc,scale=640:360,nullsink
  74. @end example
  75. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  76. filter in order to simulate a specific input file.
  77. @c man end GRAPH2DOT
  78. @chapter Filtergraph description
  79. @c man begin FILTERGRAPH DESCRIPTION
  80. A filtergraph is a directed graph of connected filters. It can contain
  81. cycles, and there can be multiple links between a pair of
  82. filters. Each link has one input pad on one side connecting it to one
  83. filter from which it takes its input, and one output pad on the other
  84. side connecting it to one filter accepting its output.
  85. Each filter in a filtergraph is an instance of a filter class
  86. registered in the application, which defines the features and the
  87. number of input and output pads of the filter.
  88. A filter with no input pads is called a "source", and a filter with no
  89. output pads is called a "sink".
  90. @anchor{Filtergraph syntax}
  91. @section Filtergraph syntax
  92. A filtergraph has a textual representation, which is recognized by the
  93. @option{-filter}/@option{-vf}/@option{-af} and
  94. @option{-filter_complex} options in @command{ffmpeg} and
  95. @option{-vf}/@option{-af} in @command{ffplay}, and by the
  96. @code{avfilter_graph_parse_ptr()} function defined in
  97. @file{libavfilter/avfilter.h}.
  98. A filterchain consists of a sequence of connected filters, each one
  99. connected to the previous one in the sequence. A filterchain is
  100. represented by a list of ","-separated filter descriptions.
  101. A filtergraph consists of a sequence of filterchains. A sequence of
  102. filterchains is represented by a list of ";"-separated filterchain
  103. descriptions.
  104. A filter is represented by a string of the form:
  105. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  106. @var{filter_name} is the name of the filter class of which the
  107. described filter is an instance of, and has to be the name of one of
  108. the filter classes registered in the program.
  109. The name of the filter class is optionally followed by a string
  110. "=@var{arguments}".
  111. @var{arguments} is a string which contains the parameters used to
  112. initialize the filter instance. It may have one of two forms:
  113. @itemize
  114. @item
  115. A ':'-separated list of @var{key=value} pairs.
  116. @item
  117. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  118. the option names in the order they are declared. E.g. the @code{fade} filter
  119. declares three options in this order -- @option{type}, @option{start_frame} and
  120. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  121. @var{in} is assigned to the option @option{type}, @var{0} to
  122. @option{start_frame} and @var{30} to @option{nb_frames}.
  123. @item
  124. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  125. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  126. follow the same constraints order of the previous point. The following
  127. @var{key=value} pairs can be set in any preferred order.
  128. @end itemize
  129. If the option value itself is a list of items (e.g. the @code{format} filter
  130. takes a list of pixel formats), the items in the list are usually separated by
  131. @samp{|}.
  132. The list of arguments can be quoted using the character @samp{'} as initial
  133. and ending mark, and the character @samp{\} for escaping the characters
  134. within the quoted text; otherwise the argument string is considered
  135. terminated when the next special character (belonging to the set
  136. @samp{[]=;,}) is encountered.
  137. The name and arguments of the filter are optionally preceded and
  138. followed by a list of link labels.
  139. A link label allows one to name a link and associate it to a filter output
  140. or input pad. The preceding labels @var{in_link_1}
  141. ... @var{in_link_N}, are associated to the filter input pads,
  142. the following labels @var{out_link_1} ... @var{out_link_M}, are
  143. associated to the output pads.
  144. When two link labels with the same name are found in the
  145. filtergraph, a link between the corresponding input and output pad is
  146. created.
  147. If an output pad is not labelled, it is linked by default to the first
  148. unlabelled input pad of the next filter in the filterchain.
  149. For example in the filterchain
  150. @example
  151. nullsrc, split[L1], [L2]overlay, nullsink
  152. @end example
  153. the split filter instance has two output pads, and the overlay filter
  154. instance two input pads. The first output pad of split is labelled
  155. "L1", the first input pad of overlay is labelled "L2", and the second
  156. output pad of split is linked to the second input pad of overlay,
  157. which are both unlabelled.
  158. In a filter description, if the input label of the first filter is not
  159. specified, "in" is assumed; if the output label of the last filter is not
  160. specified, "out" is assumed.
  161. In a complete filterchain all the unlabelled filter input and output
  162. pads must be connected. A filtergraph is considered valid if all the
  163. filter input and output pads of all the filterchains are connected.
  164. Libavfilter will automatically insert @ref{scale} filters where format
  165. conversion is required. It is possible to specify swscale flags
  166. for those automatically inserted scalers by prepending
  167. @code{sws_flags=@var{flags};}
  168. to the filtergraph description.
  169. Here is a BNF description of the filtergraph syntax:
  170. @example
  171. @var{NAME} ::= sequence of alphanumeric characters and '_'
  172. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  173. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  174. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  175. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  176. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  177. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  178. @end example
  179. @section Notes on filtergraph escaping
  180. Filtergraph description composition entails several levels of
  181. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  182. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  183. information about the employed escaping procedure.
  184. A first level escaping affects the content of each filter option
  185. value, which may contain the special character @code{:} used to
  186. separate values, or one of the escaping characters @code{\'}.
  187. A second level escaping affects the whole filter description, which
  188. may contain the escaping characters @code{\'} or the special
  189. characters @code{[],;} used by the filtergraph description.
  190. Finally, when you specify a filtergraph on a shell commandline, you
  191. need to perform a third level escaping for the shell special
  192. characters contained within it.
  193. For example, consider the following string to be embedded in
  194. the @ref{drawtext} filter description @option{text} value:
  195. @example
  196. this is a 'string': may contain one, or more, special characters
  197. @end example
  198. This string contains the @code{'} special escaping character, and the
  199. @code{:} special character, so it needs to be escaped in this way:
  200. @example
  201. text=this is a \'string\'\: may contain one, or more, special characters
  202. @end example
  203. A second level of escaping is required when embedding the filter
  204. description in a filtergraph description, in order to escape all the
  205. filtergraph special characters. Thus the example above becomes:
  206. @example
  207. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  208. @end example
  209. (note that in addition to the @code{\'} escaping special characters,
  210. also @code{,} needs to be escaped).
  211. Finally an additional level of escaping is needed when writing the
  212. filtergraph description in a shell command, which depends on the
  213. escaping rules of the adopted shell. For example, assuming that
  214. @code{\} is special and needs to be escaped with another @code{\}, the
  215. previous string will finally result in:
  216. @example
  217. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  218. @end example
  219. @chapter Timeline editing
  220. Some filters support a generic @option{enable} option. For the filters
  221. supporting timeline editing, this option can be set to an expression which is
  222. evaluated before sending a frame to the filter. If the evaluation is non-zero,
  223. the filter will be enabled, otherwise the frame will be sent unchanged to the
  224. next filter in the filtergraph.
  225. The expression accepts the following values:
  226. @table @samp
  227. @item t
  228. timestamp expressed in seconds, NAN if the input timestamp is unknown
  229. @item n
  230. sequential number of the input frame, starting from 0
  231. @item pos
  232. the position in the file of the input frame, NAN if unknown
  233. @item w
  234. @item h
  235. width and height of the input frame if video
  236. @end table
  237. Additionally, these filters support an @option{enable} command that can be used
  238. to re-define the expression.
  239. Like any other filtering option, the @option{enable} option follows the same
  240. rules.
  241. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  242. minutes, and a @ref{curves} filter starting at 3 seconds:
  243. @example
  244. smartblur = enable='between(t,10,3*60)',
  245. curves = enable='gte(t,3)' : preset=cross_process
  246. @end example
  247. @c man end FILTERGRAPH DESCRIPTION
  248. @chapter Audio Filters
  249. @c man begin AUDIO FILTERS
  250. When you configure your FFmpeg build, you can disable any of the
  251. existing filters using @code{--disable-filters}.
  252. The configure output will show the audio filters included in your
  253. build.
  254. Below is a description of the currently available audio filters.
  255. @section adelay
  256. Delay one or more audio channels.
  257. Samples in delayed channel are filled with silence.
  258. The filter accepts the following option:
  259. @table @option
  260. @item delays
  261. Set list of delays in milliseconds for each channel separated by '|'.
  262. At least one delay greater than 0 should be provided.
  263. Unused delays will be silently ignored. If number of given delays is
  264. smaller than number of channels all remaining channels will not be delayed.
  265. @end table
  266. @subsection Examples
  267. @itemize
  268. @item
  269. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  270. the second channel (and any other channels that may be present) unchanged.
  271. @example
  272. adelay=1500|0|500
  273. @end example
  274. @end itemize
  275. @section aecho
  276. Apply echoing to the input audio.
  277. Echoes are reflected sound and can occur naturally amongst mountains
  278. (and sometimes large buildings) when talking or shouting; digital echo
  279. effects emulate this behaviour and are often used to help fill out the
  280. sound of a single instrument or vocal. The time difference between the
  281. original signal and the reflection is the @code{delay}, and the
  282. loudness of the reflected signal is the @code{decay}.
  283. Multiple echoes can have different delays and decays.
  284. A description of the accepted parameters follows.
  285. @table @option
  286. @item in_gain
  287. Set input gain of reflected signal. Default is @code{0.6}.
  288. @item out_gain
  289. Set output gain of reflected signal. Default is @code{0.3}.
  290. @item delays
  291. Set list of time intervals in milliseconds between original signal and reflections
  292. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  293. Default is @code{1000}.
  294. @item decays
  295. Set list of loudnesses of reflected signals separated by '|'.
  296. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  297. Default is @code{0.5}.
  298. @end table
  299. @subsection Examples
  300. @itemize
  301. @item
  302. Make it sound as if there are twice as many instruments as are actually playing:
  303. @example
  304. aecho=0.8:0.88:60:0.4
  305. @end example
  306. @item
  307. If delay is very short, then it sound like a (metallic) robot playing music:
  308. @example
  309. aecho=0.8:0.88:6:0.4
  310. @end example
  311. @item
  312. A longer delay will sound like an open air concert in the mountains:
  313. @example
  314. aecho=0.8:0.9:1000:0.3
  315. @end example
  316. @item
  317. Same as above but with one more mountain:
  318. @example
  319. aecho=0.8:0.9:1000|1800:0.3|0.25
  320. @end example
  321. @end itemize
  322. @section aeval
  323. Modify an audio signal according to the specified expressions.
  324. This filter accepts one or more expressions (one for each channel),
  325. which are evaluated and used to modify a corresponding audio signal.
  326. It accepts the following parameters:
  327. @table @option
  328. @item exprs
  329. Set the '|'-separated expressions list for each separate channel. If
  330. the number of input channels is greater than the number of
  331. expressions, the last specified expression is used for the remaining
  332. output channels.
  333. @item channel_layout, c
  334. Set output channel layout. If not specified, the channel layout is
  335. specified by the number of expressions. If set to @samp{same}, it will
  336. use by default the same input channel layout.
  337. @end table
  338. Each expression in @var{exprs} can contain the following constants and functions:
  339. @table @option
  340. @item ch
  341. channel number of the current expression
  342. @item n
  343. number of the evaluated sample, starting from 0
  344. @item s
  345. sample rate
  346. @item t
  347. time of the evaluated sample expressed in seconds
  348. @item nb_in_channels
  349. @item nb_out_channels
  350. input and output number of channels
  351. @item val(CH)
  352. the value of input channel with number @var{CH}
  353. @end table
  354. Note: this filter is slow. For faster processing you should use a
  355. dedicated filter.
  356. @subsection Examples
  357. @itemize
  358. @item
  359. Half volume:
  360. @example
  361. aeval=val(ch)/2:c=same
  362. @end example
  363. @item
  364. Invert phase of the second channel:
  365. @example
  366. aeval=val(0)|-val(1)
  367. @end example
  368. @end itemize
  369. @section afade
  370. Apply fade-in/out effect to input audio.
  371. A description of the accepted parameters follows.
  372. @table @option
  373. @item type, t
  374. Specify the effect type, can be either @code{in} for fade-in, or
  375. @code{out} for a fade-out effect. Default is @code{in}.
  376. @item start_sample, ss
  377. Specify the number of the start sample for starting to apply the fade
  378. effect. Default is 0.
  379. @item nb_samples, ns
  380. Specify the number of samples for which the fade effect has to last. At
  381. the end of the fade-in effect the output audio will have the same
  382. volume as the input audio, at the end of the fade-out transition
  383. the output audio will be silence. Default is 44100.
  384. @item start_time, st
  385. Specify the start time of the fade effect. Default is 0.
  386. The value must be specified as a time duration; see
  387. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  388. for the accepted syntax.
  389. If set this option is used instead of @var{start_sample}.
  390. @item duration, d
  391. Specify the duration of the fade effect. See
  392. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  393. for the accepted syntax.
  394. At the end of the fade-in effect the output audio will have the same
  395. volume as the input audio, at the end of the fade-out transition
  396. the output audio will be silence.
  397. By default the duration is determined by @var{nb_samples}.
  398. If set this option is used instead of @var{nb_samples}.
  399. @item curve
  400. Set curve for fade transition.
  401. It accepts the following values:
  402. @table @option
  403. @item tri
  404. select triangular, linear slope (default)
  405. @item qsin
  406. select quarter of sine wave
  407. @item hsin
  408. select half of sine wave
  409. @item esin
  410. select exponential sine wave
  411. @item log
  412. select logarithmic
  413. @item par
  414. select inverted parabola
  415. @item qua
  416. select quadratic
  417. @item cub
  418. select cubic
  419. @item squ
  420. select square root
  421. @item cbr
  422. select cubic root
  423. @end table
  424. @end table
  425. @subsection Examples
  426. @itemize
  427. @item
  428. Fade in first 15 seconds of audio:
  429. @example
  430. afade=t=in:ss=0:d=15
  431. @end example
  432. @item
  433. Fade out last 25 seconds of a 900 seconds audio:
  434. @example
  435. afade=t=out:st=875:d=25
  436. @end example
  437. @end itemize
  438. @anchor{aformat}
  439. @section aformat
  440. Set output format constraints for the input audio. The framework will
  441. negotiate the most appropriate format to minimize conversions.
  442. It accepts the following parameters:
  443. @table @option
  444. @item sample_fmts
  445. A '|'-separated list of requested sample formats.
  446. @item sample_rates
  447. A '|'-separated list of requested sample rates.
  448. @item channel_layouts
  449. A '|'-separated list of requested channel layouts.
  450. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  451. for the required syntax.
  452. @end table
  453. If a parameter is omitted, all values are allowed.
  454. Force the output to either unsigned 8-bit or signed 16-bit stereo
  455. @example
  456. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  457. @end example
  458. @section allpass
  459. Apply a two-pole all-pass filter with central frequency (in Hz)
  460. @var{frequency}, and filter-width @var{width}.
  461. An all-pass filter changes the audio's frequency to phase relationship
  462. without changing its frequency to amplitude relationship.
  463. The filter accepts the following options:
  464. @table @option
  465. @item frequency, f
  466. Set frequency in Hz.
  467. @item width_type
  468. Set method to specify band-width of filter.
  469. @table @option
  470. @item h
  471. Hz
  472. @item q
  473. Q-Factor
  474. @item o
  475. octave
  476. @item s
  477. slope
  478. @end table
  479. @item width, w
  480. Specify the band-width of a filter in width_type units.
  481. @end table
  482. @section amerge
  483. Merge two or more audio streams into a single multi-channel stream.
  484. The filter accepts the following options:
  485. @table @option
  486. @item inputs
  487. Set the number of inputs. Default is 2.
  488. @end table
  489. If the channel layouts of the inputs are disjoint, and therefore compatible,
  490. the channel layout of the output will be set accordingly and the channels
  491. will be reordered as necessary. If the channel layouts of the inputs are not
  492. disjoint, the output will have all the channels of the first input then all
  493. the channels of the second input, in that order, and the channel layout of
  494. the output will be the default value corresponding to the total number of
  495. channels.
  496. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  497. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  498. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  499. first input, b1 is the first channel of the second input).
  500. On the other hand, if both input are in stereo, the output channels will be
  501. in the default order: a1, a2, b1, b2, and the channel layout will be
  502. arbitrarily set to 4.0, which may or may not be the expected value.
  503. All inputs must have the same sample rate, and format.
  504. If inputs do not have the same duration, the output will stop with the
  505. shortest.
  506. @subsection Examples
  507. @itemize
  508. @item
  509. Merge two mono files into a stereo stream:
  510. @example
  511. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  512. @end example
  513. @item
  514. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  515. @example
  516. ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
  517. @end example
  518. @end itemize
  519. @section amix
  520. Mixes multiple audio inputs into a single output.
  521. Note that this filter only supports float samples (the @var{amerge}
  522. and @var{pan} audio filters support many formats). If the @var{amix}
  523. input has integer samples then @ref{aresample} will be automatically
  524. inserted to perform the conversion to float samples.
  525. For example
  526. @example
  527. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  528. @end example
  529. will mix 3 input audio streams to a single output with the same duration as the
  530. first input and a dropout transition time of 3 seconds.
  531. It accepts the following parameters:
  532. @table @option
  533. @item inputs
  534. The number of inputs. If unspecified, it defaults to 2.
  535. @item duration
  536. How to determine the end-of-stream.
  537. @table @option
  538. @item longest
  539. The duration of the longest input. (default)
  540. @item shortest
  541. The duration of the shortest input.
  542. @item first
  543. The duration of the first input.
  544. @end table
  545. @item dropout_transition
  546. The transition time, in seconds, for volume renormalization when an input
  547. stream ends. The default value is 2 seconds.
  548. @end table
  549. @section anull
  550. Pass the audio source unchanged to the output.
  551. @section apad
  552. Pad the end of an audio stream with silence.
  553. This can be used together with @command{ffmpeg} @option{-shortest} to
  554. extend audio streams to the same length as the video stream.
  555. A description of the accepted options follows.
  556. @table @option
  557. @item packet_size
  558. Set silence packet size. Default value is 4096.
  559. @item pad_len
  560. Set the number of samples of silence to add to the end. After the
  561. value is reached, the stream is terminated. This option is mutually
  562. exclusive with @option{whole_len}.
  563. @item whole_len
  564. Set the minimum total number of samples in the output audio stream. If
  565. the value is longer than the input audio length, silence is added to
  566. the end, until the value is reached. This option is mutually exclusive
  567. with @option{pad_len}.
  568. @end table
  569. If neither the @option{pad_len} nor the @option{whole_len} option is
  570. set, the filter will add silence to the end of the input stream
  571. indefinitely.
  572. @subsection Examples
  573. @itemize
  574. @item
  575. Add 1024 samples of silence to the end of the input:
  576. @example
  577. apad=pad_len=1024
  578. @end example
  579. @item
  580. Make sure the audio output will contain at least 10000 samples, pad
  581. the input with silence if required:
  582. @example
  583. apad=whole_len=10000
  584. @end example
  585. @item
  586. Use @command{ffmpeg} to pad the audio input with silence, so that the
  587. video stream will always result the shortest and will be converted
  588. until the end in the output file when using the @option{shortest}
  589. option:
  590. @example
  591. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  592. @end example
  593. @end itemize
  594. @section aphaser
  595. Add a phasing effect to the input audio.
  596. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  597. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  598. A description of the accepted parameters follows.
  599. @table @option
  600. @item in_gain
  601. Set input gain. Default is 0.4.
  602. @item out_gain
  603. Set output gain. Default is 0.74
  604. @item delay
  605. Set delay in milliseconds. Default is 3.0.
  606. @item decay
  607. Set decay. Default is 0.4.
  608. @item speed
  609. Set modulation speed in Hz. Default is 0.5.
  610. @item type
  611. Set modulation type. Default is triangular.
  612. It accepts the following values:
  613. @table @samp
  614. @item triangular, t
  615. @item sinusoidal, s
  616. @end table
  617. @end table
  618. @anchor{aresample}
  619. @section aresample
  620. Resample the input audio to the specified parameters, using the
  621. libswresample library. If none are specified then the filter will
  622. automatically convert between its input and output.
  623. This filter is also able to stretch/squeeze the audio data to make it match
  624. the timestamps or to inject silence / cut out audio to make it match the
  625. timestamps, do a combination of both or do neither.
  626. The filter accepts the syntax
  627. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  628. expresses a sample rate and @var{resampler_options} is a list of
  629. @var{key}=@var{value} pairs, separated by ":". See the
  630. ffmpeg-resampler manual for the complete list of supported options.
  631. @subsection Examples
  632. @itemize
  633. @item
  634. Resample the input audio to 44100Hz:
  635. @example
  636. aresample=44100
  637. @end example
  638. @item
  639. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  640. samples per second compensation:
  641. @example
  642. aresample=async=1000
  643. @end example
  644. @end itemize
  645. @section asetnsamples
  646. Set the number of samples per each output audio frame.
  647. The last output packet may contain a different number of samples, as
  648. the filter will flush all the remaining samples when the input audio
  649. signal its end.
  650. The filter accepts the following options:
  651. @table @option
  652. @item nb_out_samples, n
  653. Set the number of frames per each output audio frame. The number is
  654. intended as the number of samples @emph{per each channel}.
  655. Default value is 1024.
  656. @item pad, p
  657. If set to 1, the filter will pad the last audio frame with zeroes, so
  658. that the last frame will contain the same number of samples as the
  659. previous ones. Default value is 1.
  660. @end table
  661. For example, to set the number of per-frame samples to 1234 and
  662. disable padding for the last frame, use:
  663. @example
  664. asetnsamples=n=1234:p=0
  665. @end example
  666. @section asetrate
  667. Set the sample rate without altering the PCM data.
  668. This will result in a change of speed and pitch.
  669. The filter accepts the following options:
  670. @table @option
  671. @item sample_rate, r
  672. Set the output sample rate. Default is 44100 Hz.
  673. @end table
  674. @section ashowinfo
  675. Show a line containing various information for each input audio frame.
  676. The input audio is not modified.
  677. The shown line contains a sequence of key/value pairs of the form
  678. @var{key}:@var{value}.
  679. The following values are shown in the output:
  680. @table @option
  681. @item n
  682. The (sequential) number of the input frame, starting from 0.
  683. @item pts
  684. The presentation timestamp of the input frame, in time base units; the time base
  685. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  686. @item pts_time
  687. The presentation timestamp of the input frame in seconds.
  688. @item pos
  689. position of the frame in the input stream, -1 if this information in
  690. unavailable and/or meaningless (for example in case of synthetic audio)
  691. @item fmt
  692. The sample format.
  693. @item chlayout
  694. The channel layout.
  695. @item rate
  696. The sample rate for the audio frame.
  697. @item nb_samples
  698. The number of samples (per channel) in the frame.
  699. @item checksum
  700. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  701. audio, the data is treated as if all the planes were concatenated.
  702. @item plane_checksums
  703. A list of Adler-32 checksums for each data plane.
  704. @end table
  705. @anchor{astats}
  706. @section astats
  707. Display time domain statistical information about the audio channels.
  708. Statistics are calculated and displayed for each audio channel and,
  709. where applicable, an overall figure is also given.
  710. It accepts the following option:
  711. @table @option
  712. @item length
  713. Short window length in seconds, used for peak and trough RMS measurement.
  714. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  715. @end table
  716. A description of each shown parameter follows:
  717. @table @option
  718. @item DC offset
  719. Mean amplitude displacement from zero.
  720. @item Min level
  721. Minimal sample level.
  722. @item Max level
  723. Maximal sample level.
  724. @item Peak level dB
  725. @item RMS level dB
  726. Standard peak and RMS level measured in dBFS.
  727. @item RMS peak dB
  728. @item RMS trough dB
  729. Peak and trough values for RMS level measured over a short window.
  730. @item Crest factor
  731. Standard ratio of peak to RMS level (note: not in dB).
  732. @item Flat factor
  733. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  734. (i.e. either @var{Min level} or @var{Max level}).
  735. @item Peak count
  736. Number of occasions (not the number of samples) that the signal attained either
  737. @var{Min level} or @var{Max level}.
  738. @end table
  739. @section astreamsync
  740. Forward two audio streams and control the order the buffers are forwarded.
  741. The filter accepts the following options:
  742. @table @option
  743. @item expr, e
  744. Set the expression deciding which stream should be
  745. forwarded next: if the result is negative, the first stream is forwarded; if
  746. the result is positive or zero, the second stream is forwarded. It can use
  747. the following variables:
  748. @table @var
  749. @item b1 b2
  750. number of buffers forwarded so far on each stream
  751. @item s1 s2
  752. number of samples forwarded so far on each stream
  753. @item t1 t2
  754. current timestamp of each stream
  755. @end table
  756. The default value is @code{t1-t2}, which means to always forward the stream
  757. that has a smaller timestamp.
  758. @end table
  759. @subsection Examples
  760. Stress-test @code{amerge} by randomly sending buffers on the wrong
  761. input, while avoiding too much of a desynchronization:
  762. @example
  763. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  764. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  765. [a2] [b2] amerge
  766. @end example
  767. @section asyncts
  768. Synchronize audio data with timestamps by squeezing/stretching it and/or
  769. dropping samples/adding silence when needed.
  770. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  771. It accepts the following parameters:
  772. @table @option
  773. @item compensate
  774. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  775. by default. When disabled, time gaps are covered with silence.
  776. @item min_delta
  777. The minimum difference between timestamps and audio data (in seconds) to trigger
  778. adding/dropping samples. The default value is 0.1. If you get an imperfect
  779. sync with this filter, try setting this parameter to 0.
  780. @item max_comp
  781. The maximum compensation in samples per second. Only relevant with compensate=1.
  782. The default value is 500.
  783. @item first_pts
  784. Assume that the first PTS should be this value. The time base is 1 / sample
  785. rate. This allows for padding/trimming at the start of the stream. By default,
  786. no assumption is made about the first frame's expected PTS, so no padding or
  787. trimming is done. For example, this could be set to 0 to pad the beginning with
  788. silence if an audio stream starts after the video stream or to trim any samples
  789. with a negative PTS due to encoder delay.
  790. @end table
  791. @section atempo
  792. Adjust audio tempo.
  793. The filter accepts exactly one parameter, the audio tempo. If not
  794. specified then the filter will assume nominal 1.0 tempo. Tempo must
  795. be in the [0.5, 2.0] range.
  796. @subsection Examples
  797. @itemize
  798. @item
  799. Slow down audio to 80% tempo:
  800. @example
  801. atempo=0.8
  802. @end example
  803. @item
  804. To speed up audio to 125% tempo:
  805. @example
  806. atempo=1.25
  807. @end example
  808. @end itemize
  809. @section atrim
  810. Trim the input so that the output contains one continuous subpart of the input.
  811. It accepts the following parameters:
  812. @table @option
  813. @item start
  814. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  815. sample with the timestamp @var{start} will be the first sample in the output.
  816. @item end
  817. Specify time of the first audio sample that will be dropped, i.e. the
  818. audio sample immediately preceding the one with the timestamp @var{end} will be
  819. the last sample in the output.
  820. @item start_pts
  821. Same as @var{start}, except this option sets the start timestamp in samples
  822. instead of seconds.
  823. @item end_pts
  824. Same as @var{end}, except this option sets the end timestamp in samples instead
  825. of seconds.
  826. @item duration
  827. The maximum duration of the output in seconds.
  828. @item start_sample
  829. The number of the first sample that should be output.
  830. @item end_sample
  831. The number of the first sample that should be dropped.
  832. @end table
  833. @option{start}, @option{end}, and @option{duration} are expressed as time
  834. duration specifications; see
  835. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  836. Note that the first two sets of the start/end options and the @option{duration}
  837. option look at the frame timestamp, while the _sample options simply count the
  838. samples that pass through the filter. So start/end_pts and start/end_sample will
  839. give different results when the timestamps are wrong, inexact or do not start at
  840. zero. Also note that this filter does not modify the timestamps. If you wish
  841. to have the output timestamps start at zero, insert the asetpts filter after the
  842. atrim filter.
  843. If multiple start or end options are set, this filter tries to be greedy and
  844. keep all samples that match at least one of the specified constraints. To keep
  845. only the part that matches all the constraints at once, chain multiple atrim
  846. filters.
  847. The defaults are such that all the input is kept. So it is possible to set e.g.
  848. just the end values to keep everything before the specified time.
  849. Examples:
  850. @itemize
  851. @item
  852. Drop everything except the second minute of input:
  853. @example
  854. ffmpeg -i INPUT -af atrim=60:120
  855. @end example
  856. @item
  857. Keep only the first 1000 samples:
  858. @example
  859. ffmpeg -i INPUT -af atrim=end_sample=1000
  860. @end example
  861. @end itemize
  862. @section bandpass
  863. Apply a two-pole Butterworth band-pass filter with central
  864. frequency @var{frequency}, and (3dB-point) band-width width.
  865. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  866. instead of the default: constant 0dB peak gain.
  867. The filter roll off at 6dB per octave (20dB per decade).
  868. The filter accepts the following options:
  869. @table @option
  870. @item frequency, f
  871. Set the filter's central frequency. Default is @code{3000}.
  872. @item csg
  873. Constant skirt gain if set to 1. Defaults to 0.
  874. @item width_type
  875. Set method to specify band-width of filter.
  876. @table @option
  877. @item h
  878. Hz
  879. @item q
  880. Q-Factor
  881. @item o
  882. octave
  883. @item s
  884. slope
  885. @end table
  886. @item width, w
  887. Specify the band-width of a filter in width_type units.
  888. @end table
  889. @section bandreject
  890. Apply a two-pole Butterworth band-reject filter with central
  891. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  892. The filter roll off at 6dB per octave (20dB per decade).
  893. The filter accepts the following options:
  894. @table @option
  895. @item frequency, f
  896. Set the filter's central frequency. Default is @code{3000}.
  897. @item width_type
  898. Set method to specify band-width of filter.
  899. @table @option
  900. @item h
  901. Hz
  902. @item q
  903. Q-Factor
  904. @item o
  905. octave
  906. @item s
  907. slope
  908. @end table
  909. @item width, w
  910. Specify the band-width of a filter in width_type units.
  911. @end table
  912. @section bass
  913. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  914. shelving filter with a response similar to that of a standard
  915. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  916. The filter accepts the following options:
  917. @table @option
  918. @item gain, g
  919. Give the gain at 0 Hz. Its useful range is about -20
  920. (for a large cut) to +20 (for a large boost).
  921. Beware of clipping when using a positive gain.
  922. @item frequency, f
  923. Set the filter's central frequency and so can be used
  924. to extend or reduce the frequency range to be boosted or cut.
  925. The default value is @code{100} Hz.
  926. @item width_type
  927. Set method to specify band-width of filter.
  928. @table @option
  929. @item h
  930. Hz
  931. @item q
  932. Q-Factor
  933. @item o
  934. octave
  935. @item s
  936. slope
  937. @end table
  938. @item width, w
  939. Determine how steep is the filter's shelf transition.
  940. @end table
  941. @section biquad
  942. Apply a biquad IIR filter with the given coefficients.
  943. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  944. are the numerator and denominator coefficients respectively.
  945. @section bs2b
  946. Bauer stereo to binaural transformation, which improves headphone listening of
  947. stereo audio records.
  948. It accepts the following parameters:
  949. @table @option
  950. @item profile
  951. Pre-defined crossfeed level.
  952. @table @option
  953. @item default
  954. Default level (fcut=700, feed=50).
  955. @item cmoy
  956. Chu Moy circuit (fcut=700, feed=60).
  957. @item jmeier
  958. Jan Meier circuit (fcut=650, feed=95).
  959. @end table
  960. @item fcut
  961. Cut frequency (in Hz).
  962. @item feed
  963. Feed level (in Hz).
  964. @end table
  965. @section channelmap
  966. Remap input channels to new locations.
  967. It accepts the following parameters:
  968. @table @option
  969. @item channel_layout
  970. The channel layout of the output stream.
  971. @item map
  972. Map channels from input to output. The argument is a '|'-separated list of
  973. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  974. @var{in_channel} form. @var{in_channel} can be either the name of the input
  975. channel (e.g. FL for front left) or its index in the input channel layout.
  976. @var{out_channel} is the name of the output channel or its index in the output
  977. channel layout. If @var{out_channel} is not given then it is implicitly an
  978. index, starting with zero and increasing by one for each mapping.
  979. @end table
  980. If no mapping is present, the filter will implicitly map input channels to
  981. output channels, preserving indices.
  982. For example, assuming a 5.1+downmix input MOV file,
  983. @example
  984. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  985. @end example
  986. will create an output WAV file tagged as stereo from the downmix channels of
  987. the input.
  988. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  989. @example
  990. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
  991. @end example
  992. @section channelsplit
  993. Split each channel from an input audio stream into a separate output stream.
  994. It accepts the following parameters:
  995. @table @option
  996. @item channel_layout
  997. The channel layout of the input stream. The default is "stereo".
  998. @end table
  999. For example, assuming a stereo input MP3 file,
  1000. @example
  1001. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1002. @end example
  1003. will create an output Matroska file with two audio streams, one containing only
  1004. the left channel and the other the right channel.
  1005. Split a 5.1 WAV file into per-channel files:
  1006. @example
  1007. ffmpeg -i in.wav -filter_complex
  1008. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1009. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1010. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1011. side_right.wav
  1012. @end example
  1013. @section chorus
  1014. Add a chorus effect to the audio.
  1015. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1016. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1017. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1018. The modulation depth defines the range the modulated delay is played before or after
  1019. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1020. sound tuned around the original one, like in a chorus where some vocals are slightly
  1021. off key.
  1022. It accepts the following parameters:
  1023. @table @option
  1024. @item in_gain
  1025. Set input gain. Default is 0.4.
  1026. @item out_gain
  1027. Set output gain. Default is 0.4.
  1028. @item delays
  1029. Set delays. A typical delay is around 40ms to 60ms.
  1030. @item decays
  1031. Set decays.
  1032. @item speeds
  1033. Set speeds.
  1034. @item depths
  1035. Set depths.
  1036. @end table
  1037. @subsection Examples
  1038. @itemize
  1039. @item
  1040. A single delay:
  1041. @example
  1042. chorus=0.7:0.9:55:0.4:0.25:2
  1043. @end example
  1044. @item
  1045. Two delays:
  1046. @example
  1047. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1048. @end example
  1049. @item
  1050. Fuller sounding chorus with three delays:
  1051. @example
  1052. chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
  1053. @end example
  1054. @end itemize
  1055. @section compand
  1056. Compress or expand the audio's dynamic range.
  1057. It accepts the following parameters:
  1058. @table @option
  1059. @item attacks
  1060. @item decays
  1061. A list of times in seconds for each channel over which the instantaneous level
  1062. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1063. increase of volume and @var{decays} refers to decrease of volume. For most
  1064. situations, the attack time (response to the audio getting louder) should be
  1065. shorter than the decay time, because the human ear is more sensitive to sudden
  1066. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1067. a typical value for decay is 0.8 seconds.
  1068. @item points
  1069. A list of points for the transfer function, specified in dB relative to the
  1070. maximum possible signal amplitude. Each key points list must be defined using
  1071. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1072. @code{x0/y0 x1/y1 x2/y2 ....}
  1073. The input values must be in strictly increasing order but the transfer function
  1074. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1075. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1076. function are @code{-70/-70|-60/-20}.
  1077. @item soft-knee
  1078. Set the curve radius in dB for all joints. It defaults to 0.01.
  1079. @item gain
  1080. Set the additional gain in dB to be applied at all points on the transfer
  1081. function. This allows for easy adjustment of the overall gain.
  1082. It defaults to 0.
  1083. @item volume
  1084. Set an initial volume, in dB, to be assumed for each channel when filtering
  1085. starts. This permits the user to supply a nominal level initially, so that, for
  1086. example, a very large gain is not applied to initial signal levels before the
  1087. companding has begun to operate. A typical value for audio which is initially
  1088. quiet is -90 dB. It defaults to 0.
  1089. @item delay
  1090. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1091. delayed before being fed to the volume adjuster. Specifying a delay
  1092. approximately equal to the attack/decay times allows the filter to effectively
  1093. operate in predictive rather than reactive mode. It defaults to 0.
  1094. @end table
  1095. @subsection Examples
  1096. @itemize
  1097. @item
  1098. Make music with both quiet and loud passages suitable for listening to in a
  1099. noisy environment:
  1100. @example
  1101. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1102. @end example
  1103. @item
  1104. A noise gate for when the noise is at a lower level than the signal:
  1105. @example
  1106. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1107. @end example
  1108. @item
  1109. Here is another noise gate, this time for when the noise is at a higher level
  1110. than the signal (making it, in some ways, similar to squelch):
  1111. @example
  1112. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1113. @end example
  1114. @end itemize
  1115. @section dcshift
  1116. Apply a DC shift to the audio.
  1117. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1118. in the recording chain) from the audio. The effect of a DC offset is reduced
  1119. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1120. a signal has a DC offset.
  1121. @table @option
  1122. @item shift
  1123. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1124. the audio.
  1125. @item limitergain
  1126. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1127. used to prevent clipping.
  1128. @end table
  1129. @section earwax
  1130. Make audio easier to listen to on headphones.
  1131. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1132. so that when listened to on headphones the stereo image is moved from
  1133. inside your head (standard for headphones) to outside and in front of
  1134. the listener (standard for speakers).
  1135. Ported from SoX.
  1136. @section equalizer
  1137. Apply a two-pole peaking equalisation (EQ) filter. With this
  1138. filter, the signal-level at and around a selected frequency can
  1139. be increased or decreased, whilst (unlike bandpass and bandreject
  1140. filters) that at all other frequencies is unchanged.
  1141. In order to produce complex equalisation curves, this filter can
  1142. be given several times, each with a different central frequency.
  1143. The filter accepts the following options:
  1144. @table @option
  1145. @item frequency, f
  1146. Set the filter's central frequency in Hz.
  1147. @item width_type
  1148. Set method to specify band-width of filter.
  1149. @table @option
  1150. @item h
  1151. Hz
  1152. @item q
  1153. Q-Factor
  1154. @item o
  1155. octave
  1156. @item s
  1157. slope
  1158. @end table
  1159. @item width, w
  1160. Specify the band-width of a filter in width_type units.
  1161. @item gain, g
  1162. Set the required gain or attenuation in dB.
  1163. Beware of clipping when using a positive gain.
  1164. @end table
  1165. @subsection Examples
  1166. @itemize
  1167. @item
  1168. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1169. @example
  1170. equalizer=f=1000:width_type=h:width=200:g=-10
  1171. @end example
  1172. @item
  1173. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1174. @example
  1175. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1176. @end example
  1177. @end itemize
  1178. @section flanger
  1179. Apply a flanging effect to the audio.
  1180. The filter accepts the following options:
  1181. @table @option
  1182. @item delay
  1183. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1184. @item depth
  1185. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1186. @item regen
  1187. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1188. Default value is 0.
  1189. @item width
  1190. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1191. Default value is 71.
  1192. @item speed
  1193. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1194. @item shape
  1195. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1196. Default value is @var{sinusoidal}.
  1197. @item phase
  1198. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1199. Default value is 25.
  1200. @item interp
  1201. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1202. Default is @var{linear}.
  1203. @end table
  1204. @section highpass
  1205. Apply a high-pass filter with 3dB point frequency.
  1206. The filter can be either single-pole, or double-pole (the default).
  1207. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1208. The filter accepts the following options:
  1209. @table @option
  1210. @item frequency, f
  1211. Set frequency in Hz. Default is 3000.
  1212. @item poles, p
  1213. Set number of poles. Default is 2.
  1214. @item width_type
  1215. Set method to specify band-width of filter.
  1216. @table @option
  1217. @item h
  1218. Hz
  1219. @item q
  1220. Q-Factor
  1221. @item o
  1222. octave
  1223. @item s
  1224. slope
  1225. @end table
  1226. @item width, w
  1227. Specify the band-width of a filter in width_type units.
  1228. Applies only to double-pole filter.
  1229. The default is 0.707q and gives a Butterworth response.
  1230. @end table
  1231. @section join
  1232. Join multiple input streams into one multi-channel stream.
  1233. It accepts the following parameters:
  1234. @table @option
  1235. @item inputs
  1236. The number of input streams. It defaults to 2.
  1237. @item channel_layout
  1238. The desired output channel layout. It defaults to stereo.
  1239. @item map
  1240. Map channels from inputs to output. The argument is a '|'-separated list of
  1241. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1242. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1243. can be either the name of the input channel (e.g. FL for front left) or its
  1244. index in the specified input stream. @var{out_channel} is the name of the output
  1245. channel.
  1246. @end table
  1247. The filter will attempt to guess the mappings when they are not specified
  1248. explicitly. It does so by first trying to find an unused matching input channel
  1249. and if that fails it picks the first unused input channel.
  1250. Join 3 inputs (with properly set channel layouts):
  1251. @example
  1252. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1253. @end example
  1254. Build a 5.1 output from 6 single-channel streams:
  1255. @example
  1256. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1257. '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'
  1258. out
  1259. @end example
  1260. @section ladspa
  1261. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1262. To enable compilation of this filter you need to configure FFmpeg with
  1263. @code{--enable-ladspa}.
  1264. @table @option
  1265. @item file, f
  1266. Specifies the name of LADSPA plugin library to load. If the environment
  1267. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1268. each one of the directories specified by the colon separated list in
  1269. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1270. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1271. @file{/usr/lib/ladspa/}.
  1272. @item plugin, p
  1273. Specifies the plugin within the library. Some libraries contain only
  1274. one plugin, but others contain many of them. If this is not set filter
  1275. will list all available plugins within the specified library.
  1276. @item controls, c
  1277. Set the '|' separated list of controls which are zero or more floating point
  1278. values that determine the behavior of the loaded plugin (for example delay,
  1279. threshold or gain).
  1280. Controls need to be defined using the following syntax:
  1281. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1282. @var{valuei} is the value set on the @var{i}-th control.
  1283. If @option{controls} is set to @code{help}, all available controls and
  1284. their valid ranges are printed.
  1285. @item sample_rate, s
  1286. Specify the sample rate, default to 44100. Only used if plugin have
  1287. zero inputs.
  1288. @item nb_samples, n
  1289. Set the number of samples per channel per each output frame, default
  1290. is 1024. Only used if plugin have zero inputs.
  1291. @item duration, d
  1292. Set the minimum duration of the sourced audio. See
  1293. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1294. for the accepted syntax.
  1295. Note that the resulting duration may be greater than the specified duration,
  1296. as the generated audio is always cut at the end of a complete frame.
  1297. If not specified, or the expressed duration is negative, the audio is
  1298. supposed to be generated forever.
  1299. Only used if plugin have zero inputs.
  1300. @end table
  1301. @subsection Examples
  1302. @itemize
  1303. @item
  1304. List all available plugins within amp (LADSPA example plugin) library:
  1305. @example
  1306. ladspa=file=amp
  1307. @end example
  1308. @item
  1309. List all available controls and their valid ranges for @code{vcf_notch}
  1310. plugin from @code{VCF} library:
  1311. @example
  1312. ladspa=f=vcf:p=vcf_notch:c=help
  1313. @end example
  1314. @item
  1315. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1316. plugin library:
  1317. @example
  1318. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1319. @end example
  1320. @item
  1321. Add reverberation to the audio using TAP-plugins
  1322. (Tom's Audio Processing plugins):
  1323. @example
  1324. ladspa=file=tap_reverb:tap_reverb
  1325. @end example
  1326. @item
  1327. Generate white noise, with 0.2 amplitude:
  1328. @example
  1329. ladspa=file=cmt:noise_source_white:c=c0=.2
  1330. @end example
  1331. @item
  1332. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1333. @code{C* Audio Plugin Suite} (CAPS) library:
  1334. @example
  1335. ladspa=file=caps:Click:c=c1=20'
  1336. @end example
  1337. @item
  1338. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1339. @example
  1340. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1341. @end example
  1342. @end itemize
  1343. @subsection Commands
  1344. This filter supports the following commands:
  1345. @table @option
  1346. @item cN
  1347. Modify the @var{N}-th control value.
  1348. If the specified value is not valid, it is ignored and prior one is kept.
  1349. @end table
  1350. @section lowpass
  1351. Apply a low-pass filter with 3dB point frequency.
  1352. The filter can be either single-pole or double-pole (the default).
  1353. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1354. The filter accepts the following options:
  1355. @table @option
  1356. @item frequency, f
  1357. Set frequency in Hz. Default is 500.
  1358. @item poles, p
  1359. Set number of poles. Default is 2.
  1360. @item width_type
  1361. Set method to specify band-width of filter.
  1362. @table @option
  1363. @item h
  1364. Hz
  1365. @item q
  1366. Q-Factor
  1367. @item o
  1368. octave
  1369. @item s
  1370. slope
  1371. @end table
  1372. @item width, w
  1373. Specify the band-width of a filter in width_type units.
  1374. Applies only to double-pole filter.
  1375. The default is 0.707q and gives a Butterworth response.
  1376. @end table
  1377. @section pan
  1378. Mix channels with specific gain levels. The filter accepts the output
  1379. channel layout followed by a set of channels definitions.
  1380. This filter is also designed to efficiently remap the channels of an audio
  1381. stream.
  1382. The filter accepts parameters of the form:
  1383. "@var{l}|@var{outdef}|@var{outdef}|..."
  1384. @table @option
  1385. @item l
  1386. output channel layout or number of channels
  1387. @item outdef
  1388. output channel specification, of the form:
  1389. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1390. @item out_name
  1391. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1392. number (c0, c1, etc.)
  1393. @item gain
  1394. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1395. @item in_name
  1396. input channel to use, see out_name for details; it is not possible to mix
  1397. named and numbered input channels
  1398. @end table
  1399. If the `=' in a channel specification is replaced by `<', then the gains for
  1400. that specification will be renormalized so that the total is 1, thus
  1401. avoiding clipping noise.
  1402. @subsection Mixing examples
  1403. For example, if you want to down-mix from stereo to mono, but with a bigger
  1404. factor for the left channel:
  1405. @example
  1406. pan=1c|c0=0.9*c0+0.1*c1
  1407. @end example
  1408. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1409. 7-channels surround:
  1410. @example
  1411. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1412. @end example
  1413. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1414. that should be preferred (see "-ac" option) unless you have very specific
  1415. needs.
  1416. @subsection Remapping examples
  1417. The channel remapping will be effective if, and only if:
  1418. @itemize
  1419. @item gain coefficients are zeroes or ones,
  1420. @item only one input per channel output,
  1421. @end itemize
  1422. If all these conditions are satisfied, the filter will notify the user ("Pure
  1423. channel mapping detected"), and use an optimized and lossless method to do the
  1424. remapping.
  1425. For example, if you have a 5.1 source and want a stereo audio stream by
  1426. dropping the extra channels:
  1427. @example
  1428. pan="stereo| c0=FL | c1=FR"
  1429. @end example
  1430. Given the same source, you can also switch front left and front right channels
  1431. and keep the input channel layout:
  1432. @example
  1433. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1434. @end example
  1435. If the input is a stereo audio stream, you can mute the front left channel (and
  1436. still keep the stereo channel layout) with:
  1437. @example
  1438. pan="stereo|c1=c1"
  1439. @end example
  1440. Still with a stereo audio stream input, you can copy the right channel in both
  1441. front left and right:
  1442. @example
  1443. pan="stereo| c0=FR | c1=FR"
  1444. @end example
  1445. @section replaygain
  1446. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1447. outputs it unchanged.
  1448. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1449. @section resample
  1450. Convert the audio sample format, sample rate and channel layout. It is
  1451. not meant to be used directly.
  1452. @section silencedetect
  1453. Detect silence in an audio stream.
  1454. This filter logs a message when it detects that the input audio volume is less
  1455. or equal to a noise tolerance value for a duration greater or equal to the
  1456. minimum detected noise duration.
  1457. The printed times and duration are expressed in seconds.
  1458. The filter accepts the following options:
  1459. @table @option
  1460. @item duration, d
  1461. Set silence duration until notification (default is 2 seconds).
  1462. @item noise, n
  1463. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1464. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1465. @end table
  1466. @subsection Examples
  1467. @itemize
  1468. @item
  1469. Detect 5 seconds of silence with -50dB noise tolerance:
  1470. @example
  1471. silencedetect=n=-50dB:d=5
  1472. @end example
  1473. @item
  1474. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1475. tolerance in @file{silence.mp3}:
  1476. @example
  1477. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1478. @end example
  1479. @end itemize
  1480. @section silenceremove
  1481. Remove silence from the beginning, middle or end of the audio.
  1482. The filter accepts the following options:
  1483. @table @option
  1484. @item start_periods
  1485. This value is used to indicate if audio should be trimmed at beginning of
  1486. the audio. A value of zero indicates no silence should be trimmed from the
  1487. beginning. When specifying a non-zero value, it trims audio up until it
  1488. finds non-silence. Normally, when trimming silence from beginning of audio
  1489. the @var{start_periods} will be @code{1} but it can be increased to higher
  1490. values to trim all audio up to specific count of non-silence periods.
  1491. Default value is @code{0}.
  1492. @item start_duration
  1493. Specify the amount of time that non-silence must be detected before it stops
  1494. trimming audio. By increasing the duration, bursts of noises can be treated
  1495. as silence and trimmed off. Default value is @code{0}.
  1496. @item start_threshold
  1497. This indicates what sample value should be treated as silence. For digital
  1498. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1499. you may wish to increase the value to account for background noise.
  1500. Can be specified in dB (in case "dB" is appended to the specified value)
  1501. or amplitude ratio. Default value is @code{0}.
  1502. @item stop_periods
  1503. Set the count for trimming silence from the end of audio.
  1504. To remove silence from the middle of a file, specify a @var{stop_periods}
  1505. that is negative. This value is then treated as a positive value and is
  1506. used to indicate the effect should restart processing as specified by
  1507. @var{start_periods}, making it suitable for removing periods of silence
  1508. in the middle of the audio.
  1509. Default value is @code{0}.
  1510. @item stop_duration
  1511. Specify a duration of silence that must exist before audio is not copied any
  1512. more. By specifying a higher duration, silence that is wanted can be left in
  1513. the audio.
  1514. Default value is @code{0}.
  1515. @item stop_threshold
  1516. This is the same as @option{start_threshold} but for trimming silence from
  1517. the end of audio.
  1518. Can be specified in dB (in case "dB" is appended to the specified value)
  1519. or amplitude ratio. Default value is @code{0}.
  1520. @item leave_silence
  1521. This indicate that @var{stop_duration} length of audio should be left intact
  1522. at the beginning of each period of silence.
  1523. For example, if you want to remove long pauses between words but do not want
  1524. to remove the pauses completely. Default value is @code{0}.
  1525. @end table
  1526. @subsection Examples
  1527. @itemize
  1528. @item
  1529. The following example shows how this filter can be used to start a recording
  1530. that does not contain the delay at the start which usually occurs between
  1531. pressing the record button and the start of the performance:
  1532. @example
  1533. silenceremove=1:5:0.02
  1534. @end example
  1535. @end itemize
  1536. @section treble
  1537. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1538. shelving filter with a response similar to that of a standard
  1539. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1540. The filter accepts the following options:
  1541. @table @option
  1542. @item gain, g
  1543. Give the gain at whichever is the lower of ~22 kHz and the
  1544. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1545. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1546. @item frequency, f
  1547. Set the filter's central frequency and so can be used
  1548. to extend or reduce the frequency range to be boosted or cut.
  1549. The default value is @code{3000} Hz.
  1550. @item width_type
  1551. Set method to specify band-width of filter.
  1552. @table @option
  1553. @item h
  1554. Hz
  1555. @item q
  1556. Q-Factor
  1557. @item o
  1558. octave
  1559. @item s
  1560. slope
  1561. @end table
  1562. @item width, w
  1563. Determine how steep is the filter's shelf transition.
  1564. @end table
  1565. @section volume
  1566. Adjust the input audio volume.
  1567. It accepts the following parameters:
  1568. @table @option
  1569. @item volume
  1570. Set audio volume expression.
  1571. Output values are clipped to the maximum value.
  1572. The output audio volume is given by the relation:
  1573. @example
  1574. @var{output_volume} = @var{volume} * @var{input_volume}
  1575. @end example
  1576. The default value for @var{volume} is "1.0".
  1577. @item precision
  1578. This parameter represents the mathematical precision.
  1579. It determines which input sample formats will be allowed, which affects the
  1580. precision of the volume scaling.
  1581. @table @option
  1582. @item fixed
  1583. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1584. @item float
  1585. 32-bit floating-point; this limits input sample format to FLT. (default)
  1586. @item double
  1587. 64-bit floating-point; this limits input sample format to DBL.
  1588. @end table
  1589. @item replaygain
  1590. Choose the behaviour on encountering ReplayGain side data in input frames.
  1591. @table @option
  1592. @item drop
  1593. Remove ReplayGain side data, ignoring its contents (the default).
  1594. @item ignore
  1595. Ignore ReplayGain side data, but leave it in the frame.
  1596. @item track
  1597. Prefer the track gain, if present.
  1598. @item album
  1599. Prefer the album gain, if present.
  1600. @end table
  1601. @item replaygain_preamp
  1602. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1603. Default value for @var{replaygain_preamp} is 0.0.
  1604. @item eval
  1605. Set when the volume expression is evaluated.
  1606. It accepts the following values:
  1607. @table @samp
  1608. @item once
  1609. only evaluate expression once during the filter initialization, or
  1610. when the @samp{volume} command is sent
  1611. @item frame
  1612. evaluate expression for each incoming frame
  1613. @end table
  1614. Default value is @samp{once}.
  1615. @end table
  1616. The volume expression can contain the following parameters.
  1617. @table @option
  1618. @item n
  1619. frame number (starting at zero)
  1620. @item nb_channels
  1621. number of channels
  1622. @item nb_consumed_samples
  1623. number of samples consumed by the filter
  1624. @item nb_samples
  1625. number of samples in the current frame
  1626. @item pos
  1627. original frame position in the file
  1628. @item pts
  1629. frame PTS
  1630. @item sample_rate
  1631. sample rate
  1632. @item startpts
  1633. PTS at start of stream
  1634. @item startt
  1635. time at start of stream
  1636. @item t
  1637. frame time
  1638. @item tb
  1639. timestamp timebase
  1640. @item volume
  1641. last set volume value
  1642. @end table
  1643. Note that when @option{eval} is set to @samp{once} only the
  1644. @var{sample_rate} and @var{tb} variables are available, all other
  1645. variables will evaluate to NAN.
  1646. @subsection Commands
  1647. This filter supports the following commands:
  1648. @table @option
  1649. @item volume
  1650. Modify the volume expression.
  1651. The command accepts the same syntax of the corresponding option.
  1652. If the specified expression is not valid, it is kept at its current
  1653. value.
  1654. @item replaygain_noclip
  1655. Prevent clipping by limiting the gain applied.
  1656. Default value for @var{replaygain_noclip} is 1.
  1657. @end table
  1658. @subsection Examples
  1659. @itemize
  1660. @item
  1661. Halve the input audio volume:
  1662. @example
  1663. volume=volume=0.5
  1664. volume=volume=1/2
  1665. volume=volume=-6.0206dB
  1666. @end example
  1667. In all the above example the named key for @option{volume} can be
  1668. omitted, for example like in:
  1669. @example
  1670. volume=0.5
  1671. @end example
  1672. @item
  1673. Increase input audio power by 6 decibels using fixed-point precision:
  1674. @example
  1675. volume=volume=6dB:precision=fixed
  1676. @end example
  1677. @item
  1678. Fade volume after time 10 with an annihilation period of 5 seconds:
  1679. @example
  1680. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  1681. @end example
  1682. @end itemize
  1683. @section volumedetect
  1684. Detect the volume of the input video.
  1685. The filter has no parameters. The input is not modified. Statistics about
  1686. the volume will be printed in the log when the input stream end is reached.
  1687. In particular it will show the mean volume (root mean square), maximum
  1688. volume (on a per-sample basis), and the beginning of a histogram of the
  1689. registered volume values (from the maximum value to a cumulated 1/1000 of
  1690. the samples).
  1691. All volumes are in decibels relative to the maximum PCM value.
  1692. @subsection Examples
  1693. Here is an excerpt of the output:
  1694. @example
  1695. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1696. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1697. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1698. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1699. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1700. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  1701. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  1702. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  1703. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  1704. @end example
  1705. It means that:
  1706. @itemize
  1707. @item
  1708. The mean square energy is approximately -27 dB, or 10^-2.7.
  1709. @item
  1710. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  1711. @item
  1712. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  1713. @end itemize
  1714. In other words, raising the volume by +4 dB does not cause any clipping,
  1715. raising it by +5 dB causes clipping for 6 samples, etc.
  1716. @c man end AUDIO FILTERS
  1717. @chapter Audio Sources
  1718. @c man begin AUDIO SOURCES
  1719. Below is a description of the currently available audio sources.
  1720. @section abuffer
  1721. Buffer audio frames, and make them available to the filter chain.
  1722. This source is mainly intended for a programmatic use, in particular
  1723. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  1724. It accepts the following parameters:
  1725. @table @option
  1726. @item time_base
  1727. The timebase which will be used for timestamps of submitted frames. It must be
  1728. either a floating-point number or in @var{numerator}/@var{denominator} form.
  1729. @item sample_rate
  1730. The sample rate of the incoming audio buffers.
  1731. @item sample_fmt
  1732. The sample format of the incoming audio buffers.
  1733. Either a sample format name or its corresponding integer representation from
  1734. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  1735. @item channel_layout
  1736. The channel layout of the incoming audio buffers.
  1737. Either a channel layout name from channel_layout_map in
  1738. @file{libavutil/channel_layout.c} or its corresponding integer representation
  1739. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  1740. @item channels
  1741. The number of channels of the incoming audio buffers.
  1742. If both @var{channels} and @var{channel_layout} are specified, then they
  1743. must be consistent.
  1744. @end table
  1745. @subsection Examples
  1746. @example
  1747. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  1748. @end example
  1749. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  1750. Since the sample format with name "s16p" corresponds to the number
  1751. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  1752. equivalent to:
  1753. @example
  1754. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  1755. @end example
  1756. @section aevalsrc
  1757. Generate an audio signal specified by an expression.
  1758. This source accepts in input one or more expressions (one for each
  1759. channel), which are evaluated and used to generate a corresponding
  1760. audio signal.
  1761. This source accepts the following options:
  1762. @table @option
  1763. @item exprs
  1764. Set the '|'-separated expressions list for each separate channel. In case the
  1765. @option{channel_layout} option is not specified, the selected channel layout
  1766. depends on the number of provided expressions. Otherwise the last
  1767. specified expression is applied to the remaining output channels.
  1768. @item channel_layout, c
  1769. Set the channel layout. The number of channels in the specified layout
  1770. must be equal to the number of specified expressions.
  1771. @item duration, d
  1772. Set the minimum duration of the sourced audio. See
  1773. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1774. for the accepted syntax.
  1775. Note that the resulting duration may be greater than the specified
  1776. duration, as the generated audio is always cut at the end of a
  1777. complete frame.
  1778. If not specified, or the expressed duration is negative, the audio is
  1779. supposed to be generated forever.
  1780. @item nb_samples, n
  1781. Set the number of samples per channel per each output frame,
  1782. default to 1024.
  1783. @item sample_rate, s
  1784. Specify the sample rate, default to 44100.
  1785. @end table
  1786. Each expression in @var{exprs} can contain the following constants:
  1787. @table @option
  1788. @item n
  1789. number of the evaluated sample, starting from 0
  1790. @item t
  1791. time of the evaluated sample expressed in seconds, starting from 0
  1792. @item s
  1793. sample rate
  1794. @end table
  1795. @subsection Examples
  1796. @itemize
  1797. @item
  1798. Generate silence:
  1799. @example
  1800. aevalsrc=0
  1801. @end example
  1802. @item
  1803. Generate a sin signal with frequency of 440 Hz, set sample rate to
  1804. 8000 Hz:
  1805. @example
  1806. aevalsrc="sin(440*2*PI*t):s=8000"
  1807. @end example
  1808. @item
  1809. Generate a two channels signal, specify the channel layout (Front
  1810. Center + Back Center) explicitly:
  1811. @example
  1812. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  1813. @end example
  1814. @item
  1815. Generate white noise:
  1816. @example
  1817. aevalsrc="-2+random(0)"
  1818. @end example
  1819. @item
  1820. Generate an amplitude modulated signal:
  1821. @example
  1822. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  1823. @end example
  1824. @item
  1825. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  1826. @example
  1827. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  1828. @end example
  1829. @end itemize
  1830. @section anullsrc
  1831. The null audio source, return unprocessed audio frames. It is mainly useful
  1832. as a template and to be employed in analysis / debugging tools, or as
  1833. the source for filters which ignore the input data (for example the sox
  1834. synth filter).
  1835. This source accepts the following options:
  1836. @table @option
  1837. @item channel_layout, cl
  1838. Specifies the channel layout, and can be either an integer or a string
  1839. representing a channel layout. The default value of @var{channel_layout}
  1840. is "stereo".
  1841. Check the channel_layout_map definition in
  1842. @file{libavutil/channel_layout.c} for the mapping between strings and
  1843. channel layout values.
  1844. @item sample_rate, r
  1845. Specifies the sample rate, and defaults to 44100.
  1846. @item nb_samples, n
  1847. Set the number of samples per requested frames.
  1848. @end table
  1849. @subsection Examples
  1850. @itemize
  1851. @item
  1852. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  1853. @example
  1854. anullsrc=r=48000:cl=4
  1855. @end example
  1856. @item
  1857. Do the same operation with a more obvious syntax:
  1858. @example
  1859. anullsrc=r=48000:cl=mono
  1860. @end example
  1861. @end itemize
  1862. All the parameters need to be explicitly defined.
  1863. @section flite
  1864. Synthesize a voice utterance using the libflite library.
  1865. To enable compilation of this filter you need to configure FFmpeg with
  1866. @code{--enable-libflite}.
  1867. Note that the flite library is not thread-safe.
  1868. The filter accepts the following options:
  1869. @table @option
  1870. @item list_voices
  1871. If set to 1, list the names of the available voices and exit
  1872. immediately. Default value is 0.
  1873. @item nb_samples, n
  1874. Set the maximum number of samples per frame. Default value is 512.
  1875. @item textfile
  1876. Set the filename containing the text to speak.
  1877. @item text
  1878. Set the text to speak.
  1879. @item voice, v
  1880. Set the voice to use for the speech synthesis. Default value is
  1881. @code{kal}. See also the @var{list_voices} option.
  1882. @end table
  1883. @subsection Examples
  1884. @itemize
  1885. @item
  1886. Read from file @file{speech.txt}, and synthesize the text using the
  1887. standard flite voice:
  1888. @example
  1889. flite=textfile=speech.txt
  1890. @end example
  1891. @item
  1892. Read the specified text selecting the @code{slt} voice:
  1893. @example
  1894. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1895. @end example
  1896. @item
  1897. Input text to ffmpeg:
  1898. @example
  1899. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1900. @end example
  1901. @item
  1902. Make @file{ffplay} speak the specified text, using @code{flite} and
  1903. the @code{lavfi} device:
  1904. @example
  1905. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  1906. @end example
  1907. @end itemize
  1908. For more information about libflite, check:
  1909. @url{http://www.speech.cs.cmu.edu/flite/}
  1910. @section sine
  1911. Generate an audio signal made of a sine wave with amplitude 1/8.
  1912. The audio signal is bit-exact.
  1913. The filter accepts the following options:
  1914. @table @option
  1915. @item frequency, f
  1916. Set the carrier frequency. Default is 440 Hz.
  1917. @item beep_factor, b
  1918. Enable a periodic beep every second with frequency @var{beep_factor} times
  1919. the carrier frequency. Default is 0, meaning the beep is disabled.
  1920. @item sample_rate, r
  1921. Specify the sample rate, default is 44100.
  1922. @item duration, d
  1923. Specify the duration of the generated audio stream.
  1924. @item samples_per_frame
  1925. Set the number of samples per output frame, default is 1024.
  1926. @end table
  1927. @subsection Examples
  1928. @itemize
  1929. @item
  1930. Generate a simple 440 Hz sine wave:
  1931. @example
  1932. sine
  1933. @end example
  1934. @item
  1935. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  1936. @example
  1937. sine=220:4:d=5
  1938. sine=f=220:b=4:d=5
  1939. sine=frequency=220:beep_factor=4:duration=5
  1940. @end example
  1941. @end itemize
  1942. @c man end AUDIO SOURCES
  1943. @chapter Audio Sinks
  1944. @c man begin AUDIO SINKS
  1945. Below is a description of the currently available audio sinks.
  1946. @section abuffersink
  1947. Buffer audio frames, and make them available to the end of filter chain.
  1948. This sink is mainly intended for programmatic use, in particular
  1949. through the interface defined in @file{libavfilter/buffersink.h}
  1950. or the options system.
  1951. It accepts a pointer to an AVABufferSinkContext structure, which
  1952. defines the incoming buffers' formats, to be passed as the opaque
  1953. parameter to @code{avfilter_init_filter} for initialization.
  1954. @section anullsink
  1955. Null audio sink; do absolutely nothing with the input audio. It is
  1956. mainly useful as a template and for use in analysis / debugging
  1957. tools.
  1958. @c man end AUDIO SINKS
  1959. @chapter Video Filters
  1960. @c man begin VIDEO FILTERS
  1961. When you configure your FFmpeg build, you can disable any of the
  1962. existing filters using @code{--disable-filters}.
  1963. The configure output will show the video filters included in your
  1964. build.
  1965. Below is a description of the currently available video filters.
  1966. @section alphaextract
  1967. Extract the alpha component from the input as a grayscale video. This
  1968. is especially useful with the @var{alphamerge} filter.
  1969. @section alphamerge
  1970. Add or replace the alpha component of the primary input with the
  1971. grayscale value of a second input. This is intended for use with
  1972. @var{alphaextract} to allow the transmission or storage of frame
  1973. sequences that have alpha in a format that doesn't support an alpha
  1974. channel.
  1975. For example, to reconstruct full frames from a normal YUV-encoded video
  1976. and a separate video created with @var{alphaextract}, you might use:
  1977. @example
  1978. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  1979. @end example
  1980. Since this filter is designed for reconstruction, it operates on frame
  1981. sequences without considering timestamps, and terminates when either
  1982. input reaches end of stream. This will cause problems if your encoding
  1983. pipeline drops frames. If you're trying to apply an image as an
  1984. overlay to a video stream, consider the @var{overlay} filter instead.
  1985. @section ass
  1986. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  1987. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  1988. Substation Alpha) subtitles files.
  1989. This filter accepts the following option in addition to the common options from
  1990. the @ref{subtitles} filter:
  1991. @table @option
  1992. @item shaping
  1993. Set the shaping engine
  1994. Available values are:
  1995. @table @samp
  1996. @item auto
  1997. The default libass shaping engine, which is the best available.
  1998. @item simple
  1999. Fast, font-agnostic shaper that can do only substitutions
  2000. @item complex
  2001. Slower shaper using OpenType for substitutions and positioning
  2002. @end table
  2003. The default is @code{auto}.
  2004. @end table
  2005. @section bbox
  2006. Compute the bounding box for the non-black pixels in the input frame
  2007. luminance plane.
  2008. This filter computes the bounding box containing all the pixels with a
  2009. luminance value greater than the minimum allowed value.
  2010. The parameters describing the bounding box are printed on the filter
  2011. log.
  2012. The filter accepts the following option:
  2013. @table @option
  2014. @item min_val
  2015. Set the minimal luminance value. Default is @code{16}.
  2016. @end table
  2017. @section blackdetect
  2018. Detect video intervals that are (almost) completely black. Can be
  2019. useful to detect chapter transitions, commercials, or invalid
  2020. recordings. Output lines contains the time for the start, end and
  2021. duration of the detected black interval expressed in seconds.
  2022. In order to display the output lines, you need to set the loglevel at
  2023. least to the AV_LOG_INFO value.
  2024. The filter accepts the following options:
  2025. @table @option
  2026. @item black_min_duration, d
  2027. Set the minimum detected black duration expressed in seconds. It must
  2028. be a non-negative floating point number.
  2029. Default value is 2.0.
  2030. @item picture_black_ratio_th, pic_th
  2031. Set the threshold for considering a picture "black".
  2032. Express the minimum value for the ratio:
  2033. @example
  2034. @var{nb_black_pixels} / @var{nb_pixels}
  2035. @end example
  2036. for which a picture is considered black.
  2037. Default value is 0.98.
  2038. @item pixel_black_th, pix_th
  2039. Set the threshold for considering a pixel "black".
  2040. The threshold expresses the maximum pixel luminance value for which a
  2041. pixel is considered "black". The provided value is scaled according to
  2042. the following equation:
  2043. @example
  2044. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2045. @end example
  2046. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2047. the input video format, the range is [0-255] for YUV full-range
  2048. formats and [16-235] for YUV non full-range formats.
  2049. Default value is 0.10.
  2050. @end table
  2051. The following example sets the maximum pixel threshold to the minimum
  2052. value, and detects only black intervals of 2 or more seconds:
  2053. @example
  2054. blackdetect=d=2:pix_th=0.00
  2055. @end example
  2056. @section blackframe
  2057. Detect frames that are (almost) completely black. Can be useful to
  2058. detect chapter transitions or commercials. Output lines consist of
  2059. the frame number of the detected frame, the percentage of blackness,
  2060. the position in the file if known or -1 and the timestamp in seconds.
  2061. In order to display the output lines, you need to set the loglevel at
  2062. least to the AV_LOG_INFO value.
  2063. It accepts the following parameters:
  2064. @table @option
  2065. @item amount
  2066. The percentage of the pixels that have to be below the threshold; it defaults to
  2067. @code{98}.
  2068. @item threshold, thresh
  2069. The threshold below which a pixel value is considered black; it defaults to
  2070. @code{32}.
  2071. @end table
  2072. @section blend, tblend
  2073. Blend two video frames into each other.
  2074. The @code{blend} filter takes two input streams and outputs one
  2075. stream, the first input is the "top" layer and second input is
  2076. "bottom" layer. Output terminates when shortest input terminates.
  2077. The @code{tblend} (time blend) filter takes two consecutive frames
  2078. from one single stream, and outputs the result obtained by blending
  2079. the new frame on top of the old frame.
  2080. A description of the accepted options follows.
  2081. @table @option
  2082. @item c0_mode
  2083. @item c1_mode
  2084. @item c2_mode
  2085. @item c3_mode
  2086. @item all_mode
  2087. Set blend mode for specific pixel component or all pixel components in case
  2088. of @var{all_mode}. Default value is @code{normal}.
  2089. Available values for component modes are:
  2090. @table @samp
  2091. @item addition
  2092. @item and
  2093. @item average
  2094. @item burn
  2095. @item darken
  2096. @item difference
  2097. @item difference128
  2098. @item divide
  2099. @item dodge
  2100. @item exclusion
  2101. @item glow
  2102. @item hardlight
  2103. @item hardmix
  2104. @item lighten
  2105. @item linearlight
  2106. @item multiply
  2107. @item negation
  2108. @item normal
  2109. @item or
  2110. @item overlay
  2111. @item phoenix
  2112. @item pinlight
  2113. @item reflect
  2114. @item screen
  2115. @item softlight
  2116. @item subtract
  2117. @item vividlight
  2118. @item xor
  2119. @end table
  2120. @item c0_opacity
  2121. @item c1_opacity
  2122. @item c2_opacity
  2123. @item c3_opacity
  2124. @item all_opacity
  2125. Set blend opacity for specific pixel component or all pixel components in case
  2126. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2127. @item c0_expr
  2128. @item c1_expr
  2129. @item c2_expr
  2130. @item c3_expr
  2131. @item all_expr
  2132. Set blend expression for specific pixel component or all pixel components in case
  2133. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2134. The expressions can use the following variables:
  2135. @table @option
  2136. @item N
  2137. The sequential number of the filtered frame, starting from @code{0}.
  2138. @item X
  2139. @item Y
  2140. the coordinates of the current sample
  2141. @item W
  2142. @item H
  2143. the width and height of currently filtered plane
  2144. @item SW
  2145. @item SH
  2146. Width and height scale depending on the currently filtered plane. It is the
  2147. ratio between the corresponding luma plane number of pixels and the current
  2148. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2149. @code{0.5,0.5} for chroma planes.
  2150. @item T
  2151. Time of the current frame, expressed in seconds.
  2152. @item TOP, A
  2153. Value of pixel component at current location for first video frame (top layer).
  2154. @item BOTTOM, B
  2155. Value of pixel component at current location for second video frame (bottom layer).
  2156. @end table
  2157. @item shortest
  2158. Force termination when the shortest input terminates. Default is
  2159. @code{0}. This option is only defined for the @code{blend} filter.
  2160. @item repeatlast
  2161. Continue applying the last bottom frame after the end of the stream. A value of
  2162. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2163. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2164. @end table
  2165. @subsection Examples
  2166. @itemize
  2167. @item
  2168. Apply transition from bottom layer to top layer in first 10 seconds:
  2169. @example
  2170. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2171. @end example
  2172. @item
  2173. Apply 1x1 checkerboard effect:
  2174. @example
  2175. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2176. @end example
  2177. @item
  2178. Apply uncover left effect:
  2179. @example
  2180. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2181. @end example
  2182. @item
  2183. Apply uncover down effect:
  2184. @example
  2185. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2186. @end example
  2187. @item
  2188. Apply uncover up-left effect:
  2189. @example
  2190. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2191. @end example
  2192. @item
  2193. Display differences between the current and the previous frame:
  2194. @example
  2195. tblend=all_mode=difference128
  2196. @end example
  2197. @end itemize
  2198. @section boxblur
  2199. Apply a boxblur algorithm to the input video.
  2200. It accepts the following parameters:
  2201. @table @option
  2202. @item luma_radius, lr
  2203. @item luma_power, lp
  2204. @item chroma_radius, cr
  2205. @item chroma_power, cp
  2206. @item alpha_radius, ar
  2207. @item alpha_power, ap
  2208. @end table
  2209. A description of the accepted options follows.
  2210. @table @option
  2211. @item luma_radius, lr
  2212. @item chroma_radius, cr
  2213. @item alpha_radius, ar
  2214. Set an expression for the box radius in pixels used for blurring the
  2215. corresponding input plane.
  2216. The radius value must be a non-negative number, and must not be
  2217. greater than the value of the expression @code{min(w,h)/2} for the
  2218. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2219. planes.
  2220. Default value for @option{luma_radius} is "2". If not specified,
  2221. @option{chroma_radius} and @option{alpha_radius} default to the
  2222. corresponding value set for @option{luma_radius}.
  2223. The expressions can contain the following constants:
  2224. @table @option
  2225. @item w
  2226. @item h
  2227. The input width and height in pixels.
  2228. @item cw
  2229. @item ch
  2230. The input chroma image width and height in pixels.
  2231. @item hsub
  2232. @item vsub
  2233. The horizontal and vertical chroma subsample values. For example, for the
  2234. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2235. @end table
  2236. @item luma_power, lp
  2237. @item chroma_power, cp
  2238. @item alpha_power, ap
  2239. Specify how many times the boxblur filter is applied to the
  2240. corresponding plane.
  2241. Default value for @option{luma_power} is 2. If not specified,
  2242. @option{chroma_power} and @option{alpha_power} default to the
  2243. corresponding value set for @option{luma_power}.
  2244. A value of 0 will disable the effect.
  2245. @end table
  2246. @subsection Examples
  2247. @itemize
  2248. @item
  2249. Apply a boxblur filter with the luma, chroma, and alpha radii
  2250. set to 2:
  2251. @example
  2252. boxblur=luma_radius=2:luma_power=1
  2253. boxblur=2:1
  2254. @end example
  2255. @item
  2256. Set the luma radius to 2, and alpha and chroma radius to 0:
  2257. @example
  2258. boxblur=2:1:cr=0:ar=0
  2259. @end example
  2260. @item
  2261. Set the luma and chroma radii to a fraction of the video dimension:
  2262. @example
  2263. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2264. @end example
  2265. @end itemize
  2266. @section codecview
  2267. Visualize information exported by some codecs.
  2268. Some codecs can export information through frames using side-data or other
  2269. means. For example, some MPEG based codecs export motion vectors through the
  2270. @var{export_mvs} flag in the codec @option{flags2} option.
  2271. The filter accepts the following option:
  2272. @table @option
  2273. @item mv
  2274. Set motion vectors to visualize.
  2275. Available flags for @var{mv} are:
  2276. @table @samp
  2277. @item pf
  2278. forward predicted MVs of P-frames
  2279. @item bf
  2280. forward predicted MVs of B-frames
  2281. @item bb
  2282. backward predicted MVs of B-frames
  2283. @end table
  2284. @end table
  2285. @subsection Examples
  2286. @itemize
  2287. @item
  2288. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2289. @example
  2290. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2291. @end example
  2292. @end itemize
  2293. @section colorbalance
  2294. Modify intensity of primary colors (red, green and blue) of input frames.
  2295. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2296. regions for the red-cyan, green-magenta or blue-yellow balance.
  2297. A positive adjustment value shifts the balance towards the primary color, a negative
  2298. value towards the complementary color.
  2299. The filter accepts the following options:
  2300. @table @option
  2301. @item rs
  2302. @item gs
  2303. @item bs
  2304. Adjust red, green and blue shadows (darkest pixels).
  2305. @item rm
  2306. @item gm
  2307. @item bm
  2308. Adjust red, green and blue midtones (medium pixels).
  2309. @item rh
  2310. @item gh
  2311. @item bh
  2312. Adjust red, green and blue highlights (brightest pixels).
  2313. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2314. @end table
  2315. @subsection Examples
  2316. @itemize
  2317. @item
  2318. Add red color cast to shadows:
  2319. @example
  2320. colorbalance=rs=.3
  2321. @end example
  2322. @end itemize
  2323. @section colorlevels
  2324. Adjust video input frames using levels.
  2325. The filter accepts the following options:
  2326. @table @option
  2327. @item rimin
  2328. @item gimin
  2329. @item bimin
  2330. @item aimin
  2331. Adjust red, green, blue and alpha input black point.
  2332. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2333. @item rimax
  2334. @item gimax
  2335. @item bimax
  2336. @item aimax
  2337. Adjust red, green, blue and alpha input white point.
  2338. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2339. Input levels are used to lighten highlights (bright tones), darken shadows
  2340. (dark tones), change the balance of bright and dark tones.
  2341. @item romin
  2342. @item gomin
  2343. @item bomin
  2344. @item aomin
  2345. Adjust red, green, blue and alpha output black point.
  2346. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2347. @item romax
  2348. @item gomax
  2349. @item bomax
  2350. @item aomax
  2351. Adjust red, green, blue and alpha output white point.
  2352. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  2353. Output levels allows manual selection of a constrained output level range.
  2354. @end table
  2355. @subsection Examples
  2356. @itemize
  2357. @item
  2358. Make video output darker:
  2359. @example
  2360. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  2361. @end example
  2362. @item
  2363. Increase contrast:
  2364. @example
  2365. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  2366. @end example
  2367. @item
  2368. Make video output lighter:
  2369. @example
  2370. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  2371. @end example
  2372. @item
  2373. Increase brightness:
  2374. @example
  2375. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  2376. @end example
  2377. @end itemize
  2378. @section colorchannelmixer
  2379. Adjust video input frames by re-mixing color channels.
  2380. This filter modifies a color channel by adding the values associated to
  2381. the other channels of the same pixels. For example if the value to
  2382. modify is red, the output value will be:
  2383. @example
  2384. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2385. @end example
  2386. The filter accepts the following options:
  2387. @table @option
  2388. @item rr
  2389. @item rg
  2390. @item rb
  2391. @item ra
  2392. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2393. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2394. @item gr
  2395. @item gg
  2396. @item gb
  2397. @item ga
  2398. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2399. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2400. @item br
  2401. @item bg
  2402. @item bb
  2403. @item ba
  2404. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2405. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2406. @item ar
  2407. @item ag
  2408. @item ab
  2409. @item aa
  2410. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2411. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2412. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2413. @end table
  2414. @subsection Examples
  2415. @itemize
  2416. @item
  2417. Convert source to grayscale:
  2418. @example
  2419. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2420. @end example
  2421. @item
  2422. Simulate sepia tones:
  2423. @example
  2424. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2425. @end example
  2426. @end itemize
  2427. @section colormatrix
  2428. Convert color matrix.
  2429. The filter accepts the following options:
  2430. @table @option
  2431. @item src
  2432. @item dst
  2433. Specify the source and destination color matrix. Both values must be
  2434. specified.
  2435. The accepted values are:
  2436. @table @samp
  2437. @item bt709
  2438. BT.709
  2439. @item bt601
  2440. BT.601
  2441. @item smpte240m
  2442. SMPTE-240M
  2443. @item fcc
  2444. FCC
  2445. @end table
  2446. @end table
  2447. For example to convert from BT.601 to SMPTE-240M, use the command:
  2448. @example
  2449. colormatrix=bt601:smpte240m
  2450. @end example
  2451. @section copy
  2452. Copy the input source unchanged to the output. This is mainly useful for
  2453. testing purposes.
  2454. @section crop
  2455. Crop the input video to given dimensions.
  2456. It accepts the following parameters:
  2457. @table @option
  2458. @item w, out_w
  2459. The width of the output video. It defaults to @code{iw}.
  2460. This expression is evaluated only once during the filter
  2461. configuration.
  2462. @item h, out_h
  2463. The height of the output video. It defaults to @code{ih}.
  2464. This expression is evaluated only once during the filter
  2465. configuration.
  2466. @item x
  2467. The horizontal position, in the input video, of the left edge of the output
  2468. video. It defaults to @code{(in_w-out_w)/2}.
  2469. This expression is evaluated per-frame.
  2470. @item y
  2471. The vertical position, in the input video, of the top edge of the output video.
  2472. It defaults to @code{(in_h-out_h)/2}.
  2473. This expression is evaluated per-frame.
  2474. @item keep_aspect
  2475. If set to 1 will force the output display aspect ratio
  2476. to be the same of the input, by changing the output sample aspect
  2477. ratio. It defaults to 0.
  2478. @end table
  2479. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2480. expressions containing the following constants:
  2481. @table @option
  2482. @item x
  2483. @item y
  2484. The computed values for @var{x} and @var{y}. They are evaluated for
  2485. each new frame.
  2486. @item in_w
  2487. @item in_h
  2488. The input width and height.
  2489. @item iw
  2490. @item ih
  2491. These are the same as @var{in_w} and @var{in_h}.
  2492. @item out_w
  2493. @item out_h
  2494. The output (cropped) width and height.
  2495. @item ow
  2496. @item oh
  2497. These are the same as @var{out_w} and @var{out_h}.
  2498. @item a
  2499. same as @var{iw} / @var{ih}
  2500. @item sar
  2501. input sample aspect ratio
  2502. @item dar
  2503. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2504. @item hsub
  2505. @item vsub
  2506. horizontal and vertical chroma subsample values. For example for the
  2507. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2508. @item n
  2509. The number of the input frame, starting from 0.
  2510. @item pos
  2511. the position in the file of the input frame, NAN if unknown
  2512. @item t
  2513. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2514. @end table
  2515. The expression for @var{out_w} may depend on the value of @var{out_h},
  2516. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2517. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2518. evaluated after @var{out_w} and @var{out_h}.
  2519. The @var{x} and @var{y} parameters specify the expressions for the
  2520. position of the top-left corner of the output (non-cropped) area. They
  2521. are evaluated for each frame. If the evaluated value is not valid, it
  2522. is approximated to the nearest valid value.
  2523. The expression for @var{x} may depend on @var{y}, and the expression
  2524. for @var{y} may depend on @var{x}.
  2525. @subsection Examples
  2526. @itemize
  2527. @item
  2528. Crop area with size 100x100 at position (12,34).
  2529. @example
  2530. crop=100:100:12:34
  2531. @end example
  2532. Using named options, the example above becomes:
  2533. @example
  2534. crop=w=100:h=100:x=12:y=34
  2535. @end example
  2536. @item
  2537. Crop the central input area with size 100x100:
  2538. @example
  2539. crop=100:100
  2540. @end example
  2541. @item
  2542. Crop the central input area with size 2/3 of the input video:
  2543. @example
  2544. crop=2/3*in_w:2/3*in_h
  2545. @end example
  2546. @item
  2547. Crop the input video central square:
  2548. @example
  2549. crop=out_w=in_h
  2550. crop=in_h
  2551. @end example
  2552. @item
  2553. Delimit the rectangle with the top-left corner placed at position
  2554. 100:100 and the right-bottom corner corresponding to the right-bottom
  2555. corner of the input image.
  2556. @example
  2557. crop=in_w-100:in_h-100:100:100
  2558. @end example
  2559. @item
  2560. Crop 10 pixels from the left and right borders, and 20 pixels from
  2561. the top and bottom borders
  2562. @example
  2563. crop=in_w-2*10:in_h-2*20
  2564. @end example
  2565. @item
  2566. Keep only the bottom right quarter of the input image:
  2567. @example
  2568. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2569. @end example
  2570. @item
  2571. Crop height for getting Greek harmony:
  2572. @example
  2573. crop=in_w:1/PHI*in_w
  2574. @end example
  2575. @item
  2576. Apply trembling effect:
  2577. @example
  2578. 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)
  2579. @end example
  2580. @item
  2581. Apply erratic camera effect depending on timestamp:
  2582. @example
  2583. 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)"
  2584. @end example
  2585. @item
  2586. Set x depending on the value of y:
  2587. @example
  2588. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2589. @end example
  2590. @end itemize
  2591. @section cropdetect
  2592. Auto-detect the crop size.
  2593. It calculates the necessary cropping parameters and prints the
  2594. recommended parameters via the logging system. The detected dimensions
  2595. correspond to the non-black area of the input video.
  2596. It accepts the following parameters:
  2597. @table @option
  2598. @item limit
  2599. Set higher black value threshold, which can be optionally specified
  2600. from nothing (0) to everything (255 for 8bit based formats). An intensity
  2601. value greater to the set value is considered non-black. It defaults to 24.
  2602. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  2603. on the bitdepth of the pixel format.
  2604. @item round
  2605. The value which the width/height should be divisible by. It defaults to
  2606. 16. The offset is automatically adjusted to center the video. Use 2 to
  2607. get only even dimensions (needed for 4:2:2 video). 16 is best when
  2608. encoding to most video codecs.
  2609. @item reset_count, reset
  2610. Set the counter that determines after how many frames cropdetect will
  2611. reset the previously detected largest video area and start over to
  2612. detect the current optimal crop area. Default value is 0.
  2613. This can be useful when channel logos distort the video area. 0
  2614. indicates 'never reset', and returns the largest area encountered during
  2615. playback.
  2616. @end table
  2617. @anchor{curves}
  2618. @section curves
  2619. Apply color adjustments using curves.
  2620. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  2621. component (red, green and blue) has its values defined by @var{N} key points
  2622. tied from each other using a smooth curve. The x-axis represents the pixel
  2623. values from the input frame, and the y-axis the new pixel values to be set for
  2624. the output frame.
  2625. By default, a component curve is defined by the two points @var{(0;0)} and
  2626. @var{(1;1)}. This creates a straight line where each original pixel value is
  2627. "adjusted" to its own value, which means no change to the image.
  2628. The filter allows you to redefine these two points and add some more. A new
  2629. curve (using a natural cubic spline interpolation) will be define to pass
  2630. smoothly through all these new coordinates. The new defined points needs to be
  2631. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  2632. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  2633. the vector spaces, the values will be clipped accordingly.
  2634. If there is no key point defined in @code{x=0}, the filter will automatically
  2635. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  2636. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  2637. The filter accepts the following options:
  2638. @table @option
  2639. @item preset
  2640. Select one of the available color presets. This option can be used in addition
  2641. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  2642. options takes priority on the preset values.
  2643. Available presets are:
  2644. @table @samp
  2645. @item none
  2646. @item color_negative
  2647. @item cross_process
  2648. @item darker
  2649. @item increase_contrast
  2650. @item lighter
  2651. @item linear_contrast
  2652. @item medium_contrast
  2653. @item negative
  2654. @item strong_contrast
  2655. @item vintage
  2656. @end table
  2657. Default is @code{none}.
  2658. @item master, m
  2659. Set the master key points. These points will define a second pass mapping. It
  2660. is sometimes called a "luminance" or "value" mapping. It can be used with
  2661. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  2662. post-processing LUT.
  2663. @item red, r
  2664. Set the key points for the red component.
  2665. @item green, g
  2666. Set the key points for the green component.
  2667. @item blue, b
  2668. Set the key points for the blue component.
  2669. @item all
  2670. Set the key points for all components (not including master).
  2671. Can be used in addition to the other key points component
  2672. options. In this case, the unset component(s) will fallback on this
  2673. @option{all} setting.
  2674. @item psfile
  2675. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  2676. @end table
  2677. To avoid some filtergraph syntax conflicts, each key points list need to be
  2678. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  2679. @subsection Examples
  2680. @itemize
  2681. @item
  2682. Increase slightly the middle level of blue:
  2683. @example
  2684. curves=blue='0.5/0.58'
  2685. @end example
  2686. @item
  2687. Vintage effect:
  2688. @example
  2689. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  2690. @end example
  2691. Here we obtain the following coordinates for each components:
  2692. @table @var
  2693. @item red
  2694. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  2695. @item green
  2696. @code{(0;0) (0.50;0.48) (1;1)}
  2697. @item blue
  2698. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  2699. @end table
  2700. @item
  2701. The previous example can also be achieved with the associated built-in preset:
  2702. @example
  2703. curves=preset=vintage
  2704. @end example
  2705. @item
  2706. Or simply:
  2707. @example
  2708. curves=vintage
  2709. @end example
  2710. @item
  2711. Use a Photoshop preset and redefine the points of the green component:
  2712. @example
  2713. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  2714. @end example
  2715. @end itemize
  2716. @section dctdnoiz
  2717. Denoise frames using 2D DCT (frequency domain filtering).
  2718. This filter is not designed for real time.
  2719. The filter accepts the following options:
  2720. @table @option
  2721. @item sigma, s
  2722. Set the noise sigma constant.
  2723. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  2724. coefficient (absolute value) below this threshold with be dropped.
  2725. If you need a more advanced filtering, see @option{expr}.
  2726. Default is @code{0}.
  2727. @item overlap
  2728. Set number overlapping pixels for each block. Since the filter can be slow, you
  2729. may want to reduce this value, at the cost of a less effective filter and the
  2730. risk of various artefacts.
  2731. If the overlapping value doesn't permit processing the whole input width or
  2732. height, a warning will be displayed and according borders won't be denoised.
  2733. Default value is @var{blocksize}-1, which is the best possible setting.
  2734. @item expr, e
  2735. Set the coefficient factor expression.
  2736. For each coefficient of a DCT block, this expression will be evaluated as a
  2737. multiplier value for the coefficient.
  2738. If this is option is set, the @option{sigma} option will be ignored.
  2739. The absolute value of the coefficient can be accessed through the @var{c}
  2740. variable.
  2741. @item n
  2742. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  2743. @var{blocksize}, which is the width and height of the processed blocks.
  2744. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  2745. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  2746. on the speed processing. Also, a larger block size does not necessarily means a
  2747. better de-noising.
  2748. @end table
  2749. @subsection Examples
  2750. Apply a denoise with a @option{sigma} of @code{4.5}:
  2751. @example
  2752. dctdnoiz=4.5
  2753. @end example
  2754. The same operation can be achieved using the expression system:
  2755. @example
  2756. dctdnoiz=e='gte(c, 4.5*3)'
  2757. @end example
  2758. Violent denoise using a block size of @code{16x16}:
  2759. @example
  2760. dctdnoiz=15:n=4
  2761. @end example
  2762. @anchor{decimate}
  2763. @section decimate
  2764. Drop duplicated frames at regular intervals.
  2765. The filter accepts the following options:
  2766. @table @option
  2767. @item cycle
  2768. Set the number of frames from which one will be dropped. Setting this to
  2769. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  2770. Default is @code{5}.
  2771. @item dupthresh
  2772. Set the threshold for duplicate detection. If the difference metric for a frame
  2773. is less than or equal to this value, then it is declared as duplicate. Default
  2774. is @code{1.1}
  2775. @item scthresh
  2776. Set scene change threshold. Default is @code{15}.
  2777. @item blockx
  2778. @item blocky
  2779. Set the size of the x and y-axis blocks used during metric calculations.
  2780. Larger blocks give better noise suppression, but also give worse detection of
  2781. small movements. Must be a power of two. Default is @code{32}.
  2782. @item ppsrc
  2783. Mark main input as a pre-processed input and activate clean source input
  2784. stream. This allows the input to be pre-processed with various filters to help
  2785. the metrics calculation while keeping the frame selection lossless. When set to
  2786. @code{1}, the first stream is for the pre-processed input, and the second
  2787. stream is the clean source from where the kept frames are chosen. Default is
  2788. @code{0}.
  2789. @item chroma
  2790. Set whether or not chroma is considered in the metric calculations. Default is
  2791. @code{1}.
  2792. @end table
  2793. @section dejudder
  2794. Remove judder produced by partially interlaced telecined content.
  2795. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  2796. source was partially telecined content then the output of @code{pullup,dejudder}
  2797. will have a variable frame rate. May change the recorded frame rate of the
  2798. container. Aside from that change, this filter will not affect constant frame
  2799. rate video.
  2800. The option available in this filter is:
  2801. @table @option
  2802. @item cycle
  2803. Specify the length of the window over which the judder repeats.
  2804. Accepts any integer greater than 1. Useful values are:
  2805. @table @samp
  2806. @item 4
  2807. If the original was telecined from 24 to 30 fps (Film to NTSC).
  2808. @item 5
  2809. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  2810. @item 20
  2811. If a mixture of the two.
  2812. @end table
  2813. The default is @samp{4}.
  2814. @end table
  2815. @section delogo
  2816. Suppress a TV station logo by a simple interpolation of the surrounding
  2817. pixels. Just set a rectangle covering the logo and watch it disappear
  2818. (and sometimes something even uglier appear - your mileage may vary).
  2819. It accepts the following parameters:
  2820. @table @option
  2821. @item x
  2822. @item y
  2823. Specify the top left corner coordinates of the logo. They must be
  2824. specified.
  2825. @item w
  2826. @item h
  2827. Specify the width and height of the logo to clear. They must be
  2828. specified.
  2829. @item band, t
  2830. Specify the thickness of the fuzzy edge of the rectangle (added to
  2831. @var{w} and @var{h}). The default value is 4.
  2832. @item show
  2833. When set to 1, a green rectangle is drawn on the screen to simplify
  2834. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  2835. The default value is 0.
  2836. The rectangle is drawn on the outermost pixels which will be (partly)
  2837. replaced with interpolated values. The values of the next pixels
  2838. immediately outside this rectangle in each direction will be used to
  2839. compute the interpolated pixel values inside the rectangle.
  2840. @end table
  2841. @subsection Examples
  2842. @itemize
  2843. @item
  2844. Set a rectangle covering the area with top left corner coordinates 0,0
  2845. and size 100x77, and a band of size 10:
  2846. @example
  2847. delogo=x=0:y=0:w=100:h=77:band=10
  2848. @end example
  2849. @end itemize
  2850. @section deshake
  2851. Attempt to fix small changes in horizontal and/or vertical shift. This
  2852. filter helps remove camera shake from hand-holding a camera, bumping a
  2853. tripod, moving on a vehicle, etc.
  2854. The filter accepts the following options:
  2855. @table @option
  2856. @item x
  2857. @item y
  2858. @item w
  2859. @item h
  2860. Specify a rectangular area where to limit the search for motion
  2861. vectors.
  2862. If desired the search for motion vectors can be limited to a
  2863. rectangular area of the frame defined by its top left corner, width
  2864. and height. These parameters have the same meaning as the drawbox
  2865. filter which can be used to visualise the position of the bounding
  2866. box.
  2867. This is useful when simultaneous movement of subjects within the frame
  2868. might be confused for camera motion by the motion vector search.
  2869. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  2870. then the full frame is used. This allows later options to be set
  2871. without specifying the bounding box for the motion vector search.
  2872. Default - search the whole frame.
  2873. @item rx
  2874. @item ry
  2875. Specify the maximum extent of movement in x and y directions in the
  2876. range 0-64 pixels. Default 16.
  2877. @item edge
  2878. Specify how to generate pixels to fill blanks at the edge of the
  2879. frame. Available values are:
  2880. @table @samp
  2881. @item blank, 0
  2882. Fill zeroes at blank locations
  2883. @item original, 1
  2884. Original image at blank locations
  2885. @item clamp, 2
  2886. Extruded edge value at blank locations
  2887. @item mirror, 3
  2888. Mirrored edge at blank locations
  2889. @end table
  2890. Default value is @samp{mirror}.
  2891. @item blocksize
  2892. Specify the blocksize to use for motion search. Range 4-128 pixels,
  2893. default 8.
  2894. @item contrast
  2895. Specify the contrast threshold for blocks. Only blocks with more than
  2896. the specified contrast (difference between darkest and lightest
  2897. pixels) will be considered. Range 1-255, default 125.
  2898. @item search
  2899. Specify the search strategy. Available values are:
  2900. @table @samp
  2901. @item exhaustive, 0
  2902. Set exhaustive search
  2903. @item less, 1
  2904. Set less exhaustive search.
  2905. @end table
  2906. Default value is @samp{exhaustive}.
  2907. @item filename
  2908. If set then a detailed log of the motion search is written to the
  2909. specified file.
  2910. @item opencl
  2911. If set to 1, specify using OpenCL capabilities, only available if
  2912. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  2913. @end table
  2914. @section detelecine
  2915. Apply an exact inverse of the telecine operation. It requires a predefined
  2916. pattern specified using the pattern option which must be the same as that passed
  2917. to the telecine filter.
  2918. This filter accepts the following options:
  2919. @table @option
  2920. @item first_field
  2921. @table @samp
  2922. @item top, t
  2923. top field first
  2924. @item bottom, b
  2925. bottom field first
  2926. The default value is @code{top}.
  2927. @end table
  2928. @item pattern
  2929. A string of numbers representing the pulldown pattern you wish to apply.
  2930. The default value is @code{23}.
  2931. @item start_frame
  2932. A number representing position of the first frame with respect to the telecine
  2933. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  2934. @end table
  2935. @section drawbox
  2936. Draw a colored box on the input image.
  2937. It accepts the following parameters:
  2938. @table @option
  2939. @item x
  2940. @item y
  2941. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  2942. @item width, w
  2943. @item height, h
  2944. The expressions which specify the width and height of the box; if 0 they are interpreted as
  2945. the input width and height. It defaults to 0.
  2946. @item color, c
  2947. Specify the color of the box to write. For the general syntax of this option,
  2948. check the "Color" section in the ffmpeg-utils manual. If the special
  2949. value @code{invert} is used, the box edge color is the same as the
  2950. video with inverted luma.
  2951. @item thickness, t
  2952. The expression which sets the thickness of the box edge. Default value is @code{3}.
  2953. See below for the list of accepted constants.
  2954. @end table
  2955. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  2956. following constants:
  2957. @table @option
  2958. @item dar
  2959. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  2960. @item hsub
  2961. @item vsub
  2962. horizontal and vertical chroma subsample values. For example for the
  2963. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2964. @item in_h, ih
  2965. @item in_w, iw
  2966. The input width and height.
  2967. @item sar
  2968. The input sample aspect ratio.
  2969. @item x
  2970. @item y
  2971. The x and y offset coordinates where the box is drawn.
  2972. @item w
  2973. @item h
  2974. The width and height of the drawn box.
  2975. @item t
  2976. The thickness of the drawn box.
  2977. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  2978. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  2979. @end table
  2980. @subsection Examples
  2981. @itemize
  2982. @item
  2983. Draw a black box around the edge of the input image:
  2984. @example
  2985. drawbox
  2986. @end example
  2987. @item
  2988. Draw a box with color red and an opacity of 50%:
  2989. @example
  2990. drawbox=10:20:200:60:red@@0.5
  2991. @end example
  2992. The previous example can be specified as:
  2993. @example
  2994. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  2995. @end example
  2996. @item
  2997. Fill the box with pink color:
  2998. @example
  2999. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3000. @end example
  3001. @item
  3002. Draw a 2-pixel red 2.40:1 mask:
  3003. @example
  3004. drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
  3005. @end example
  3006. @end itemize
  3007. @section drawgrid
  3008. Draw a grid on the input image.
  3009. It accepts the following parameters:
  3010. @table @option
  3011. @item x
  3012. @item y
  3013. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3014. @item width, w
  3015. @item height, h
  3016. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3017. input width and height, respectively, minus @code{thickness}, so image gets
  3018. framed. Default to 0.
  3019. @item color, c
  3020. Specify the color of the grid. For the general syntax of this option,
  3021. check the "Color" section in the ffmpeg-utils manual. If the special
  3022. value @code{invert} is used, the grid color is the same as the
  3023. video with inverted luma.
  3024. @item thickness, t
  3025. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3026. See below for the list of accepted constants.
  3027. @end table
  3028. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3029. following constants:
  3030. @table @option
  3031. @item dar
  3032. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3033. @item hsub
  3034. @item vsub
  3035. horizontal and vertical chroma subsample values. For example for the
  3036. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3037. @item in_h, ih
  3038. @item in_w, iw
  3039. The input grid cell width and height.
  3040. @item sar
  3041. The input sample aspect ratio.
  3042. @item x
  3043. @item y
  3044. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3045. @item w
  3046. @item h
  3047. The width and height of the drawn cell.
  3048. @item t
  3049. The thickness of the drawn cell.
  3050. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3051. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3052. @end table
  3053. @subsection Examples
  3054. @itemize
  3055. @item
  3056. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3057. @example
  3058. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3059. @end example
  3060. @item
  3061. Draw a white 3x3 grid with an opacity of 50%:
  3062. @example
  3063. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3064. @end example
  3065. @end itemize
  3066. @anchor{drawtext}
  3067. @section drawtext
  3068. Draw a text string or text from a specified file on top of a video, using the
  3069. libfreetype library.
  3070. To enable compilation of this filter, you need to configure FFmpeg with
  3071. @code{--enable-libfreetype}.
  3072. To enable default font fallback and the @var{font} option you need to
  3073. configure FFmpeg with @code{--enable-libfontconfig}.
  3074. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3075. @code{--enable-libfribidi}.
  3076. @subsection Syntax
  3077. It accepts the following parameters:
  3078. @table @option
  3079. @item box
  3080. Used to draw a box around text using the background color.
  3081. The value must be either 1 (enable) or 0 (disable).
  3082. The default value of @var{box} is 0.
  3083. @item boxborderw
  3084. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3085. The default value of @var{boxborderw} is 0.
  3086. @item boxcolor
  3087. The color to be used for drawing box around text. For the syntax of this
  3088. option, check the "Color" section in the ffmpeg-utils manual.
  3089. The default value of @var{boxcolor} is "white".
  3090. @item borderw
  3091. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3092. The default value of @var{borderw} is 0.
  3093. @item bordercolor
  3094. Set the color to be used for drawing border around text. For the syntax of this
  3095. option, check the "Color" section in the ffmpeg-utils manual.
  3096. The default value of @var{bordercolor} is "black".
  3097. @item expansion
  3098. Select how the @var{text} is expanded. Can be either @code{none},
  3099. @code{strftime} (deprecated) or
  3100. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3101. below for details.
  3102. @item fix_bounds
  3103. If true, check and fix text coords to avoid clipping.
  3104. @item fontcolor
  3105. The color to be used for drawing fonts. For the syntax of this option, check
  3106. the "Color" section in the ffmpeg-utils manual.
  3107. The default value of @var{fontcolor} is "black".
  3108. @item fontcolor_expr
  3109. String which is expanded the same way as @var{text} to obtain dynamic
  3110. @var{fontcolor} value. By default this option has empty value and is not
  3111. processed. When this option is set, it overrides @var{fontcolor} option.
  3112. @item font
  3113. The font family to be used for drawing text. By default Sans.
  3114. @item fontfile
  3115. The font file to be used for drawing text. The path must be included.
  3116. This parameter is mandatory if the fontconfig support is disabled.
  3117. @item draw
  3118. This option does not exist, please see the timeline system
  3119. @item alpha
  3120. Draw the text applying alpha blending. The value can
  3121. be either a number between 0.0 and 1.0
  3122. The expression accepts the same variables @var{x, y} do.
  3123. The default value is 1.
  3124. Please see fontcolor_expr
  3125. @item fontsize
  3126. The font size to be used for drawing text.
  3127. The default value of @var{fontsize} is 16.
  3128. @item text_shaping
  3129. If set to 1, attempt to shape the text (for example, reverse the order of
  3130. right-to-left text and join Arabic characters) before drawing it.
  3131. Otherwise, just draw the text exactly as given.
  3132. By default 1 (if supported).
  3133. @item ft_load_flags
  3134. The flags to be used for loading the fonts.
  3135. The flags map the corresponding flags supported by libfreetype, and are
  3136. a combination of the following values:
  3137. @table @var
  3138. @item default
  3139. @item no_scale
  3140. @item no_hinting
  3141. @item render
  3142. @item no_bitmap
  3143. @item vertical_layout
  3144. @item force_autohint
  3145. @item crop_bitmap
  3146. @item pedantic
  3147. @item ignore_global_advance_width
  3148. @item no_recurse
  3149. @item ignore_transform
  3150. @item monochrome
  3151. @item linear_design
  3152. @item no_autohint
  3153. @end table
  3154. Default value is "default".
  3155. For more information consult the documentation for the FT_LOAD_*
  3156. libfreetype flags.
  3157. @item shadowcolor
  3158. The color to be used for drawing a shadow behind the drawn text. For the
  3159. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3160. The default value of @var{shadowcolor} is "black".
  3161. @item shadowx
  3162. @item shadowy
  3163. The x and y offsets for the text shadow position with respect to the
  3164. position of the text. They can be either positive or negative
  3165. values. The default value for both is "0".
  3166. @item start_number
  3167. The starting frame number for the n/frame_num variable. The default value
  3168. is "0".
  3169. @item tabsize
  3170. The size in number of spaces to use for rendering the tab.
  3171. Default value is 4.
  3172. @item timecode
  3173. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  3174. format. It can be used with or without text parameter. @var{timecode_rate}
  3175. option must be specified.
  3176. @item timecode_rate, rate, r
  3177. Set the timecode frame rate (timecode only).
  3178. @item text
  3179. The text string to be drawn. The text must be a sequence of UTF-8
  3180. encoded characters.
  3181. This parameter is mandatory if no file is specified with the parameter
  3182. @var{textfile}.
  3183. @item textfile
  3184. A text file containing text to be drawn. The text must be a sequence
  3185. of UTF-8 encoded characters.
  3186. This parameter is mandatory if no text string is specified with the
  3187. parameter @var{text}.
  3188. If both @var{text} and @var{textfile} are specified, an error is thrown.
  3189. @item reload
  3190. If set to 1, the @var{textfile} will be reloaded before each frame.
  3191. Be sure to update it atomically, or it may be read partially, or even fail.
  3192. @item x
  3193. @item y
  3194. The expressions which specify the offsets where text will be drawn
  3195. within the video frame. They are relative to the top/left border of the
  3196. output image.
  3197. The default value of @var{x} and @var{y} is "0".
  3198. See below for the list of accepted constants and functions.
  3199. @end table
  3200. The parameters for @var{x} and @var{y} are expressions containing the
  3201. following constants and functions:
  3202. @table @option
  3203. @item dar
  3204. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  3205. @item hsub
  3206. @item vsub
  3207. horizontal and vertical chroma subsample values. For example for the
  3208. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3209. @item line_h, lh
  3210. the height of each text line
  3211. @item main_h, h, H
  3212. the input height
  3213. @item main_w, w, W
  3214. the input width
  3215. @item max_glyph_a, ascent
  3216. the maximum distance from the baseline to the highest/upper grid
  3217. coordinate used to place a glyph outline point, for all the rendered
  3218. glyphs.
  3219. It is a positive value, due to the grid's orientation with the Y axis
  3220. upwards.
  3221. @item max_glyph_d, descent
  3222. the maximum distance from the baseline to the lowest grid coordinate
  3223. used to place a glyph outline point, for all the rendered glyphs.
  3224. This is a negative value, due to the grid's orientation, with the Y axis
  3225. upwards.
  3226. @item max_glyph_h
  3227. maximum glyph height, that is the maximum height for all the glyphs
  3228. contained in the rendered text, it is equivalent to @var{ascent} -
  3229. @var{descent}.
  3230. @item max_glyph_w
  3231. maximum glyph width, that is the maximum width for all the glyphs
  3232. contained in the rendered text
  3233. @item n
  3234. the number of input frame, starting from 0
  3235. @item rand(min, max)
  3236. return a random number included between @var{min} and @var{max}
  3237. @item sar
  3238. The input sample aspect ratio.
  3239. @item t
  3240. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3241. @item text_h, th
  3242. the height of the rendered text
  3243. @item text_w, tw
  3244. the width of the rendered text
  3245. @item x
  3246. @item y
  3247. the x and y offset coordinates where the text is drawn.
  3248. These parameters allow the @var{x} and @var{y} expressions to refer
  3249. each other, so you can for example specify @code{y=x/dar}.
  3250. @end table
  3251. @anchor{drawtext_expansion}
  3252. @subsection Text expansion
  3253. If @option{expansion} is set to @code{strftime},
  3254. the filter recognizes strftime() sequences in the provided text and
  3255. expands them accordingly. Check the documentation of strftime(). This
  3256. feature is deprecated.
  3257. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3258. If @option{expansion} is set to @code{normal} (which is the default),
  3259. the following expansion mechanism is used.
  3260. The backslash character @samp{\}, followed by any character, always expands to
  3261. the second character.
  3262. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3263. braces is a function name, possibly followed by arguments separated by ':'.
  3264. If the arguments contain special characters or delimiters (':' or '@}'),
  3265. they should be escaped.
  3266. Note that they probably must also be escaped as the value for the
  3267. @option{text} option in the filter argument string and as the filter
  3268. argument in the filtergraph description, and possibly also for the shell,
  3269. that makes up to four levels of escaping; using a text file avoids these
  3270. problems.
  3271. The following functions are available:
  3272. @table @command
  3273. @item expr, e
  3274. The expression evaluation result.
  3275. It must take one argument specifying the expression to be evaluated,
  3276. which accepts the same constants and functions as the @var{x} and
  3277. @var{y} values. Note that not all constants should be used, for
  3278. example the text size is not known when evaluating the expression, so
  3279. the constants @var{text_w} and @var{text_h} will have an undefined
  3280. value.
  3281. @item expr_int_format, eif
  3282. Evaluate the expression's value and output as formatted integer.
  3283. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  3284. The second argument specifies the output format. Allowed values are @samp{x},
  3285. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  3286. @code{printf} function.
  3287. The third parameter is optional and sets the number of positions taken by the output.
  3288. It can be used to add padding with zeros from the left.
  3289. @item gmtime
  3290. The time at which the filter is running, expressed in UTC.
  3291. It can accept an argument: a strftime() format string.
  3292. @item localtime
  3293. The time at which the filter is running, expressed in the local time zone.
  3294. It can accept an argument: a strftime() format string.
  3295. @item metadata
  3296. Frame metadata. It must take one argument specifying metadata key.
  3297. @item n, frame_num
  3298. The frame number, starting from 0.
  3299. @item pict_type
  3300. A 1 character description of the current picture type.
  3301. @item pts
  3302. The timestamp of the current frame.
  3303. It can take up to two arguments.
  3304. The first argument is the format of the timestamp; it defaults to @code{flt}
  3305. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3306. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3307. The second argument is an offset added to the timestamp.
  3308. @end table
  3309. @subsection Examples
  3310. @itemize
  3311. @item
  3312. Draw "Test Text" with font FreeSerif, using the default values for the
  3313. optional parameters.
  3314. @example
  3315. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3316. @end example
  3317. @item
  3318. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3319. and y=50 (counting from the top-left corner of the screen), text is
  3320. yellow with a red box around it. Both the text and the box have an
  3321. opacity of 20%.
  3322. @example
  3323. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3324. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3325. @end example
  3326. Note that the double quotes are not necessary if spaces are not used
  3327. within the parameter list.
  3328. @item
  3329. Show the text at the center of the video frame:
  3330. @example
  3331. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3332. @end example
  3333. @item
  3334. Show a text line sliding from right to left in the last row of the video
  3335. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3336. with no newlines.
  3337. @example
  3338. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3339. @end example
  3340. @item
  3341. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3342. @example
  3343. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3344. @end example
  3345. @item
  3346. Draw a single green letter "g", at the center of the input video.
  3347. The glyph baseline is placed at half screen height.
  3348. @example
  3349. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3350. @end example
  3351. @item
  3352. Show text for 1 second every 3 seconds:
  3353. @example
  3354. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3355. @end example
  3356. @item
  3357. Use fontconfig to set the font. Note that the colons need to be escaped.
  3358. @example
  3359. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3360. @end example
  3361. @item
  3362. Print the date of a real-time encoding (see strftime(3)):
  3363. @example
  3364. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  3365. @end example
  3366. @item
  3367. Show text fading in and out (appearing/disappearing):
  3368. @example
  3369. #!/bin/sh
  3370. DS=1.0 # display start
  3371. DE=10.0 # display end
  3372. FID=1.5 # fade in duration
  3373. FOD=5 # fade out duration
  3374. ffplay -f lavfi "color,drawtext=text=TEST:fontsize=50:fontfile=FreeSerif.ttf:fontcolor_expr=ff0000%@{eif\\\\: clip(255*(1*between(t\\, $DS + $FID\\, $DE - $FOD) + ((t - $DS)/$FID)*between(t\\, $DS\\, $DS + $FID) + (-(t - $DE)/$FOD)*between(t\\, $DE - $FOD\\, $DE) )\\, 0\\, 255) \\\\: x\\\\: 2 @}"
  3375. @end example
  3376. @end itemize
  3377. For more information about libfreetype, check:
  3378. @url{http://www.freetype.org/}.
  3379. For more information about fontconfig, check:
  3380. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3381. For more information about libfribidi, check:
  3382. @url{http://fribidi.org/}.
  3383. @section edgedetect
  3384. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3385. The filter accepts the following options:
  3386. @table @option
  3387. @item low
  3388. @item high
  3389. Set low and high threshold values used by the Canny thresholding
  3390. algorithm.
  3391. The high threshold selects the "strong" edge pixels, which are then
  3392. connected through 8-connectivity with the "weak" edge pixels selected
  3393. by the low threshold.
  3394. @var{low} and @var{high} threshold values must be chosen in the range
  3395. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3396. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3397. is @code{50/255}.
  3398. @item mode
  3399. Define the drawing mode.
  3400. @table @samp
  3401. @item wires
  3402. Draw white/gray wires on black background.
  3403. @item colormix
  3404. Mix the colors to create a paint/cartoon effect.
  3405. @end table
  3406. Default value is @var{wires}.
  3407. @end table
  3408. @subsection Examples
  3409. @itemize
  3410. @item
  3411. Standard edge detection with custom values for the hysteresis thresholding:
  3412. @example
  3413. edgedetect=low=0.1:high=0.4
  3414. @end example
  3415. @item
  3416. Painting effect without thresholding:
  3417. @example
  3418. edgedetect=mode=colormix:high=0
  3419. @end example
  3420. @end itemize
  3421. @section eq
  3422. Set brightness, contrast, saturation and approximate gamma adjustment.
  3423. The filter accepts the following options:
  3424. @table @option
  3425. @item contrast
  3426. Set the contrast expression. The value must be a float value in range
  3427. @code{-2.0} to @code{2.0}. The default value is "0".
  3428. @item brightness
  3429. Set the brightness expression. The value must be a float value in
  3430. range @code{-1.0} to @code{1.0}. The default value is "0".
  3431. @item saturation
  3432. Set the saturation expression. The value must be a float in
  3433. range @code{0.0} to @code{3.0}. The default value is "1".
  3434. @item gamma
  3435. Set the gamma expression. The value must be a float in range
  3436. @code{0.1} to @code{10.0}. The default value is "1".
  3437. @item gamma_r
  3438. Set the gamma expression for red. The value must be a float in
  3439. range @code{0.1} to @code{10.0}. The default value is "1".
  3440. @item gamma_g
  3441. Set the gamma expression for green. The value must be a float in range
  3442. @code{0.1} to @code{10.0}. The default value is "1".
  3443. @item gamma_b
  3444. Set the gamma expression for blue. The value must be a float in range
  3445. @code{0.1} to @code{10.0}. The default value is "1".
  3446. @item gamma_weight
  3447. Set the gamma weight expression. It can be used to reduce the effect
  3448. of a high gamma value on bright image areas, e.g. keep them from
  3449. getting overamplified and just plain white. The value must be a float
  3450. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  3451. gamma correction all the way down while @code{1.0} leaves it at its
  3452. full strength. Default is "1".
  3453. @item eval
  3454. Set when the expressions for brightness, contrast, saturation and
  3455. gamma expressions are evaluated.
  3456. It accepts the following values:
  3457. @table @samp
  3458. @item init
  3459. only evaluate expressions once during the filter initialization or
  3460. when a command is processed
  3461. @item frame
  3462. evaluate expressions for each incoming frame
  3463. @end table
  3464. Default value is @samp{init}.
  3465. @end table
  3466. The expressions accept the following parameters:
  3467. @table @option
  3468. @item n
  3469. frame count of the input frame starting from 0
  3470. @item pos
  3471. byte position of the corresponding packet in the input file, NAN if
  3472. unspecified
  3473. @item r
  3474. frame rate of the input video, NAN if the input frame rate is unknown
  3475. @item t
  3476. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3477. @end table
  3478. @subsection Commands
  3479. The filter supports the following commands:
  3480. @table @option
  3481. @item contrast
  3482. Set the contrast expression.
  3483. @item brightness
  3484. Set the brightness expression.
  3485. @item saturation
  3486. Set the saturation expression.
  3487. @item gamma
  3488. Set the gamma expression.
  3489. @item gamma_r
  3490. Set the gamma_r expression.
  3491. @item gamma_g
  3492. Set gamma_g expression.
  3493. @item gamma_b
  3494. Set gamma_b expression.
  3495. @item gamma_weight
  3496. Set gamma_weight expression.
  3497. The command accepts the same syntax of the corresponding option.
  3498. If the specified expression is not valid, it is kept at its current
  3499. value.
  3500. @end table
  3501. @section extractplanes
  3502. Extract color channel components from input video stream into
  3503. separate grayscale video streams.
  3504. The filter accepts the following option:
  3505. @table @option
  3506. @item planes
  3507. Set plane(s) to extract.
  3508. Available values for planes are:
  3509. @table @samp
  3510. @item y
  3511. @item u
  3512. @item v
  3513. @item a
  3514. @item r
  3515. @item g
  3516. @item b
  3517. @end table
  3518. Choosing planes not available in the input will result in an error.
  3519. That means you cannot select @code{r}, @code{g}, @code{b} planes
  3520. with @code{y}, @code{u}, @code{v} planes at same time.
  3521. @end table
  3522. @subsection Examples
  3523. @itemize
  3524. @item
  3525. Extract luma, u and v color channel component from input video frame
  3526. into 3 grayscale outputs:
  3527. @example
  3528. ffmpeg -i video.avi -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi
  3529. @end example
  3530. @end itemize
  3531. @section elbg
  3532. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  3533. For each input image, the filter will compute the optimal mapping from
  3534. the input to the output given the codebook length, that is the number
  3535. of distinct output colors.
  3536. This filter accepts the following options.
  3537. @table @option
  3538. @item codebook_length, l
  3539. Set codebook length. The value must be a positive integer, and
  3540. represents the number of distinct output colors. Default value is 256.
  3541. @item nb_steps, n
  3542. Set the maximum number of iterations to apply for computing the optimal
  3543. mapping. The higher the value the better the result and the higher the
  3544. computation time. Default value is 1.
  3545. @item seed, s
  3546. Set a random seed, must be an integer included between 0 and
  3547. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  3548. will try to use a good random seed on a best effort basis.
  3549. @end table
  3550. @section fade
  3551. Apply a fade-in/out effect to the input video.
  3552. It accepts the following parameters:
  3553. @table @option
  3554. @item type, t
  3555. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  3556. effect.
  3557. Default is @code{in}.
  3558. @item start_frame, s
  3559. Specify the number of the frame to start applying the fade
  3560. effect at. Default is 0.
  3561. @item nb_frames, n
  3562. The number of frames that the fade effect lasts. At the end of the
  3563. fade-in effect, the output video will have the same intensity as the input video.
  3564. At the end of the fade-out transition, the output video will be filled with the
  3565. selected @option{color}.
  3566. Default is 25.
  3567. @item alpha
  3568. If set to 1, fade only alpha channel, if one exists on the input.
  3569. Default value is 0.
  3570. @item start_time, st
  3571. Specify the timestamp (in seconds) of the frame to start to apply the fade
  3572. effect. If both start_frame and start_time are specified, the fade will start at
  3573. whichever comes last. Default is 0.
  3574. @item duration, d
  3575. The number of seconds for which the fade effect has to last. At the end of the
  3576. fade-in effect the output video will have the same intensity as the input video,
  3577. at the end of the fade-out transition the output video will be filled with the
  3578. selected @option{color}.
  3579. If both duration and nb_frames are specified, duration is used. Default is 0
  3580. (nb_frames is used by default).
  3581. @item color, c
  3582. Specify the color of the fade. Default is "black".
  3583. @end table
  3584. @subsection Examples
  3585. @itemize
  3586. @item
  3587. Fade in the first 30 frames of video:
  3588. @example
  3589. fade=in:0:30
  3590. @end example
  3591. The command above is equivalent to:
  3592. @example
  3593. fade=t=in:s=0:n=30
  3594. @end example
  3595. @item
  3596. Fade out the last 45 frames of a 200-frame video:
  3597. @example
  3598. fade=out:155:45
  3599. fade=type=out:start_frame=155:nb_frames=45
  3600. @end example
  3601. @item
  3602. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  3603. @example
  3604. fade=in:0:25, fade=out:975:25
  3605. @end example
  3606. @item
  3607. Make the first 5 frames yellow, then fade in from frame 5-24:
  3608. @example
  3609. fade=in:5:20:color=yellow
  3610. @end example
  3611. @item
  3612. Fade in alpha over first 25 frames of video:
  3613. @example
  3614. fade=in:0:25:alpha=1
  3615. @end example
  3616. @item
  3617. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  3618. @example
  3619. fade=t=in:st=5.5:d=0.5
  3620. @end example
  3621. @end itemize
  3622. @section fftfilt
  3623. Apply arbitrary expressions to samples in frequency domain
  3624. @table @option
  3625. @item dc_Y
  3626. Adjust the dc value (gain) of the luma plane of the image. The filter
  3627. accepts an integer value in range @code{0} to @code{1000}. The default
  3628. value is set to @code{0}.
  3629. @item dc_U
  3630. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  3631. filter accepts an integer value in range @code{0} to @code{1000}. The
  3632. default value is set to @code{0}.
  3633. @item dc_V
  3634. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  3635. filter accepts an integer value in range @code{0} to @code{1000}. The
  3636. default value is set to @code{0}.
  3637. @item weight_Y
  3638. Set the frequency domain weight expression for the luma plane.
  3639. @item weight_U
  3640. Set the frequency domain weight expression for the 1st chroma plane.
  3641. @item weight_V
  3642. Set the frequency domain weight expression for the 2nd chroma plane.
  3643. The filter accepts the following variables:
  3644. @item X
  3645. @item Y
  3646. The coordinates of the current sample.
  3647. @item W
  3648. @item H
  3649. The width and height of the image.
  3650. @end table
  3651. @subsection Examples
  3652. @itemize
  3653. @item
  3654. High-pass:
  3655. @example
  3656. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  3657. @end example
  3658. @item
  3659. Low-pass:
  3660. @example
  3661. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  3662. @end example
  3663. @item
  3664. Sharpen:
  3665. @example
  3666. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  3667. @end example
  3668. @end itemize
  3669. @section field
  3670. Extract a single field from an interlaced image using stride
  3671. arithmetic to avoid wasting CPU time. The output frames are marked as
  3672. non-interlaced.
  3673. The filter accepts the following options:
  3674. @table @option
  3675. @item type
  3676. Specify whether to extract the top (if the value is @code{0} or
  3677. @code{top}) or the bottom field (if the value is @code{1} or
  3678. @code{bottom}).
  3679. @end table
  3680. @section fieldmatch
  3681. Field matching filter for inverse telecine. It is meant to reconstruct the
  3682. progressive frames from a telecined stream. The filter does not drop duplicated
  3683. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  3684. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  3685. The separation of the field matching and the decimation is notably motivated by
  3686. the possibility of inserting a de-interlacing filter fallback between the two.
  3687. If the source has mixed telecined and real interlaced content,
  3688. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  3689. But these remaining combed frames will be marked as interlaced, and thus can be
  3690. de-interlaced by a later filter such as @ref{yadif} before decimation.
  3691. In addition to the various configuration options, @code{fieldmatch} can take an
  3692. optional second stream, activated through the @option{ppsrc} option. If
  3693. enabled, the frames reconstruction will be based on the fields and frames from
  3694. this second stream. This allows the first input to be pre-processed in order to
  3695. help the various algorithms of the filter, while keeping the output lossless
  3696. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  3697. or brightness/contrast adjustments can help.
  3698. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  3699. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  3700. which @code{fieldmatch} is based on. While the semantic and usage are very
  3701. close, some behaviour and options names can differ.
  3702. The @ref{decimate} filter currently only works for constant frame rate input.
  3703. Do not use @code{fieldmatch} and @ref{decimate} if your input has mixed
  3704. telecined and progressive content with changing framerate.
  3705. The filter accepts the following options:
  3706. @table @option
  3707. @item order
  3708. Specify the assumed field order of the input stream. Available values are:
  3709. @table @samp
  3710. @item auto
  3711. Auto detect parity (use FFmpeg's internal parity value).
  3712. @item bff
  3713. Assume bottom field first.
  3714. @item tff
  3715. Assume top field first.
  3716. @end table
  3717. Note that it is sometimes recommended not to trust the parity announced by the
  3718. stream.
  3719. Default value is @var{auto}.
  3720. @item mode
  3721. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  3722. sense that it won't risk creating jerkiness due to duplicate frames when
  3723. possible, but if there are bad edits or blended fields it will end up
  3724. outputting combed frames when a good match might actually exist. On the other
  3725. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  3726. but will almost always find a good frame if there is one. The other values are
  3727. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  3728. jerkiness and creating duplicate frames versus finding good matches in sections
  3729. with bad edits, orphaned fields, blended fields, etc.
  3730. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  3731. Available values are:
  3732. @table @samp
  3733. @item pc
  3734. 2-way matching (p/c)
  3735. @item pc_n
  3736. 2-way matching, and trying 3rd match if still combed (p/c + n)
  3737. @item pc_u
  3738. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  3739. @item pc_n_ub
  3740. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  3741. still combed (p/c + n + u/b)
  3742. @item pcn
  3743. 3-way matching (p/c/n)
  3744. @item pcn_ub
  3745. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  3746. detected as combed (p/c/n + u/b)
  3747. @end table
  3748. The parenthesis at the end indicate the matches that would be used for that
  3749. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  3750. @var{top}).
  3751. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  3752. the slowest.
  3753. Default value is @var{pc_n}.
  3754. @item ppsrc
  3755. Mark the main input stream as a pre-processed input, and enable the secondary
  3756. input stream as the clean source to pick the fields from. See the filter
  3757. introduction for more details. It is similar to the @option{clip2} feature from
  3758. VFM/TFM.
  3759. Default value is @code{0} (disabled).
  3760. @item field
  3761. Set the field to match from. It is recommended to set this to the same value as
  3762. @option{order} unless you experience matching failures with that setting. In
  3763. certain circumstances changing the field that is used to match from can have a
  3764. large impact on matching performance. Available values are:
  3765. @table @samp
  3766. @item auto
  3767. Automatic (same value as @option{order}).
  3768. @item bottom
  3769. Match from the bottom field.
  3770. @item top
  3771. Match from the top field.
  3772. @end table
  3773. Default value is @var{auto}.
  3774. @item mchroma
  3775. Set whether or not chroma is included during the match comparisons. In most
  3776. cases it is recommended to leave this enabled. You should set this to @code{0}
  3777. only if your clip has bad chroma problems such as heavy rainbowing or other
  3778. artifacts. Setting this to @code{0} could also be used to speed things up at
  3779. the cost of some accuracy.
  3780. Default value is @code{1}.
  3781. @item y0
  3782. @item y1
  3783. These define an exclusion band which excludes the lines between @option{y0} and
  3784. @option{y1} from being included in the field matching decision. An exclusion
  3785. band can be used to ignore subtitles, a logo, or other things that may
  3786. interfere with the matching. @option{y0} sets the starting scan line and
  3787. @option{y1} sets the ending line; all lines in between @option{y0} and
  3788. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  3789. @option{y0} and @option{y1} to the same value will disable the feature.
  3790. @option{y0} and @option{y1} defaults to @code{0}.
  3791. @item scthresh
  3792. Set the scene change detection threshold as a percentage of maximum change on
  3793. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  3794. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  3795. @option{scthresh} is @code{[0.0, 100.0]}.
  3796. Default value is @code{12.0}.
  3797. @item combmatch
  3798. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  3799. account the combed scores of matches when deciding what match to use as the
  3800. final match. Available values are:
  3801. @table @samp
  3802. @item none
  3803. No final matching based on combed scores.
  3804. @item sc
  3805. Combed scores are only used when a scene change is detected.
  3806. @item full
  3807. Use combed scores all the time.
  3808. @end table
  3809. Default is @var{sc}.
  3810. @item combdbg
  3811. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  3812. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  3813. Available values are:
  3814. @table @samp
  3815. @item none
  3816. No forced calculation.
  3817. @item pcn
  3818. Force p/c/n calculations.
  3819. @item pcnub
  3820. Force p/c/n/u/b calculations.
  3821. @end table
  3822. Default value is @var{none}.
  3823. @item cthresh
  3824. This is the area combing threshold used for combed frame detection. This
  3825. essentially controls how "strong" or "visible" combing must be to be detected.
  3826. Larger values mean combing must be more visible and smaller values mean combing
  3827. can be less visible or strong and still be detected. Valid settings are from
  3828. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3829. be detected as combed). This is basically a pixel difference value. A good
  3830. range is @code{[8, 12]}.
  3831. Default value is @code{9}.
  3832. @item chroma
  3833. Sets whether or not chroma is considered in the combed frame decision. Only
  3834. disable this if your source has chroma problems (rainbowing, etc.) that are
  3835. causing problems for the combed frame detection with chroma enabled. Actually,
  3836. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3837. where there is chroma only combing in the source.
  3838. Default value is @code{0}.
  3839. @item blockx
  3840. @item blocky
  3841. Respectively set the x-axis and y-axis size of the window used during combed
  3842. frame detection. This has to do with the size of the area in which
  3843. @option{combpel} pixels are required to be detected as combed for a frame to be
  3844. declared combed. See the @option{combpel} parameter description for more info.
  3845. Possible values are any number that is a power of 2 starting at 4 and going up
  3846. to 512.
  3847. Default value is @code{16}.
  3848. @item combpel
  3849. The number of combed pixels inside any of the @option{blocky} by
  3850. @option{blockx} size blocks on the frame for the frame to be detected as
  3851. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3852. setting controls "how much" combing there must be in any localized area (a
  3853. window defined by the @option{blockx} and @option{blocky} settings) on the
  3854. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3855. which point no frames will ever be detected as combed). This setting is known
  3856. as @option{MI} in TFM/VFM vocabulary.
  3857. Default value is @code{80}.
  3858. @end table
  3859. @anchor{p/c/n/u/b meaning}
  3860. @subsection p/c/n/u/b meaning
  3861. @subsubsection p/c/n
  3862. We assume the following telecined stream:
  3863. @example
  3864. Top fields: 1 2 2 3 4
  3865. Bottom fields: 1 2 3 4 4
  3866. @end example
  3867. The numbers correspond to the progressive frame the fields relate to. Here, the
  3868. first two frames are progressive, the 3rd and 4th are combed, and so on.
  3869. When @code{fieldmatch} is configured to run a matching from bottom
  3870. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  3871. @example
  3872. Input stream:
  3873. T 1 2 2 3 4
  3874. B 1 2 3 4 4 <-- matching reference
  3875. Matches: c c n n c
  3876. Output stream:
  3877. T 1 2 3 4 4
  3878. B 1 2 3 4 4
  3879. @end example
  3880. As a result of the field matching, we can see that some frames get duplicated.
  3881. To perform a complete inverse telecine, you need to rely on a decimation filter
  3882. after this operation. See for instance the @ref{decimate} filter.
  3883. The same operation now matching from top fields (@option{field}=@var{top})
  3884. looks like this:
  3885. @example
  3886. Input stream:
  3887. T 1 2 2 3 4 <-- matching reference
  3888. B 1 2 3 4 4
  3889. Matches: c c p p c
  3890. Output stream:
  3891. T 1 2 2 3 4
  3892. B 1 2 2 3 4
  3893. @end example
  3894. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  3895. basically, they refer to the frame and field of the opposite parity:
  3896. @itemize
  3897. @item @var{p} matches the field of the opposite parity in the previous frame
  3898. @item @var{c} matches the field of the opposite parity in the current frame
  3899. @item @var{n} matches the field of the opposite parity in the next frame
  3900. @end itemize
  3901. @subsubsection u/b
  3902. The @var{u} and @var{b} matching are a bit special in the sense that they match
  3903. from the opposite parity flag. In the following examples, we assume that we are
  3904. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  3905. 'x' is placed above and below each matched fields.
  3906. With bottom matching (@option{field}=@var{bottom}):
  3907. @example
  3908. Match: c p n b u
  3909. x x x x x
  3910. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3911. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3912. x x x x x
  3913. Output frames:
  3914. 2 1 2 2 2
  3915. 2 2 2 1 3
  3916. @end example
  3917. With top matching (@option{field}=@var{top}):
  3918. @example
  3919. Match: c p n b u
  3920. x x x x x
  3921. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3922. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3923. x x x x x
  3924. Output frames:
  3925. 2 2 2 1 2
  3926. 2 1 3 2 2
  3927. @end example
  3928. @subsection Examples
  3929. Simple IVTC of a top field first telecined stream:
  3930. @example
  3931. fieldmatch=order=tff:combmatch=none, decimate
  3932. @end example
  3933. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  3934. @example
  3935. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  3936. @end example
  3937. @section fieldorder
  3938. Transform the field order of the input video.
  3939. It accepts the following parameters:
  3940. @table @option
  3941. @item order
  3942. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  3943. for bottom field first.
  3944. @end table
  3945. The default value is @samp{tff}.
  3946. The transformation is done by shifting the picture content up or down
  3947. by one line, and filling the remaining line with appropriate picture content.
  3948. This method is consistent with most broadcast field order converters.
  3949. If the input video is not flagged as being interlaced, or it is already
  3950. flagged as being of the required output field order, then this filter does
  3951. not alter the incoming video.
  3952. It is very useful when converting to or from PAL DV material,
  3953. which is bottom field first.
  3954. For example:
  3955. @example
  3956. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  3957. @end example
  3958. @section fifo
  3959. Buffer input images and send them when they are requested.
  3960. It is mainly useful when auto-inserted by the libavfilter
  3961. framework.
  3962. It does not take parameters.
  3963. @section find_rect
  3964. Find a rectangular object
  3965. It accepts the following options:
  3966. @table @option
  3967. @item object
  3968. Filepath of the object image, needs to be in gray8.
  3969. @item threshold
  3970. Detection threshold, default is 0.5.
  3971. @item mipmaps
  3972. Number of mipmaps, default is 3.
  3973. @item xmin, ymin, xmax, ymax
  3974. Specifies the rectangle in which to search.
  3975. @end table
  3976. @subsection Examples
  3977. @itemize
  3978. @item
  3979. Generate a representative palette of a given video using @command{ffmpeg}:
  3980. @example
  3981. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  3982. @end example
  3983. @end itemize
  3984. @section cover_rect
  3985. Cover a rectangular object
  3986. It accepts the following options:
  3987. @table @option
  3988. @item cover
  3989. Filepath of the optional cover image, needs to be in yuv420.
  3990. @item mode
  3991. Set covering mode.
  3992. It accepts the following values:
  3993. @table @samp
  3994. @item cover
  3995. cover it by the supplied image
  3996. @item blur
  3997. cover it by interpolating the surrounding pixels
  3998. @end table
  3999. Default value is @var{blur}.
  4000. @end table
  4001. @subsection Examples
  4002. @itemize
  4003. @item
  4004. Generate a representative palette of a given video using @command{ffmpeg}:
  4005. @example
  4006. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4007. @end example
  4008. @end itemize
  4009. @anchor{format}
  4010. @section format
  4011. Convert the input video to one of the specified pixel formats.
  4012. Libavfilter will try to pick one that is suitable as input to
  4013. the next filter.
  4014. It accepts the following parameters:
  4015. @table @option
  4016. @item pix_fmts
  4017. A '|'-separated list of pixel format names, such as
  4018. "pix_fmts=yuv420p|monow|rgb24".
  4019. @end table
  4020. @subsection Examples
  4021. @itemize
  4022. @item
  4023. Convert the input video to the @var{yuv420p} format
  4024. @example
  4025. format=pix_fmts=yuv420p
  4026. @end example
  4027. Convert the input video to any of the formats in the list
  4028. @example
  4029. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4030. @end example
  4031. @end itemize
  4032. @anchor{fps}
  4033. @section fps
  4034. Convert the video to specified constant frame rate by duplicating or dropping
  4035. frames as necessary.
  4036. It accepts the following parameters:
  4037. @table @option
  4038. @item fps
  4039. The desired output frame rate. The default is @code{25}.
  4040. @item round
  4041. Rounding method.
  4042. Possible values are:
  4043. @table @option
  4044. @item zero
  4045. zero round towards 0
  4046. @item inf
  4047. round away from 0
  4048. @item down
  4049. round towards -infinity
  4050. @item up
  4051. round towards +infinity
  4052. @item near
  4053. round to nearest
  4054. @end table
  4055. The default is @code{near}.
  4056. @item start_time
  4057. Assume the first PTS should be the given value, in seconds. This allows for
  4058. padding/trimming at the start of stream. By default, no assumption is made
  4059. about the first frame's expected PTS, so no padding or trimming is done.
  4060. For example, this could be set to 0 to pad the beginning with duplicates of
  4061. the first frame if a video stream starts after the audio stream or to trim any
  4062. frames with a negative PTS.
  4063. @end table
  4064. Alternatively, the options can be specified as a flat string:
  4065. @var{fps}[:@var{round}].
  4066. See also the @ref{setpts} filter.
  4067. @subsection Examples
  4068. @itemize
  4069. @item
  4070. A typical usage in order to set the fps to 25:
  4071. @example
  4072. fps=fps=25
  4073. @end example
  4074. @item
  4075. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4076. @example
  4077. fps=fps=film:round=near
  4078. @end example
  4079. @end itemize
  4080. @section framepack
  4081. Pack two different video streams into a stereoscopic video, setting proper
  4082. metadata on supported codecs. The two views should have the same size and
  4083. framerate and processing will stop when the shorter video ends. Please note
  4084. that you may conveniently adjust view properties with the @ref{scale} and
  4085. @ref{fps} filters.
  4086. It accepts the following parameters:
  4087. @table @option
  4088. @item format
  4089. The desired packing format. Supported values are:
  4090. @table @option
  4091. @item sbs
  4092. The views are next to each other (default).
  4093. @item tab
  4094. The views are on top of each other.
  4095. @item lines
  4096. The views are packed by line.
  4097. @item columns
  4098. The views are packed by column.
  4099. @item frameseq
  4100. The views are temporally interleaved.
  4101. @end table
  4102. @end table
  4103. Some examples:
  4104. @example
  4105. # Convert left and right views into a frame-sequential video
  4106. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4107. # Convert views into a side-by-side video with the same output resolution as the input
  4108. ffmpeg -i LEFT -i RIGHT -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT
  4109. @end example
  4110. @section framestep
  4111. Select one frame every N-th frame.
  4112. This filter accepts the following option:
  4113. @table @option
  4114. @item step
  4115. Select frame after every @code{step} frames.
  4116. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4117. @end table
  4118. @anchor{frei0r}
  4119. @section frei0r
  4120. Apply a frei0r effect to the input video.
  4121. To enable the compilation of this filter, you need to install the frei0r
  4122. header and configure FFmpeg with @code{--enable-frei0r}.
  4123. It accepts the following parameters:
  4124. @table @option
  4125. @item filter_name
  4126. The name of the frei0r effect to load. If the environment variable
  4127. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4128. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4129. Otherwise, the standard frei0r paths are searched, in this order:
  4130. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4131. @file{/usr/lib/frei0r-1/}.
  4132. @item filter_params
  4133. A '|'-separated list of parameters to pass to the frei0r effect.
  4134. @end table
  4135. A frei0r effect parameter can be a boolean (its value is either
  4136. "y" or "n"), a double, a color (specified as
  4137. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4138. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4139. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4140. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4141. The number and types of parameters depend on the loaded effect. If an
  4142. effect parameter is not specified, the default value is set.
  4143. @subsection Examples
  4144. @itemize
  4145. @item
  4146. Apply the distort0r effect, setting the first two double parameters:
  4147. @example
  4148. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4149. @end example
  4150. @item
  4151. Apply the colordistance effect, taking a color as the first parameter:
  4152. @example
  4153. frei0r=colordistance:0.2/0.3/0.4
  4154. frei0r=colordistance:violet
  4155. frei0r=colordistance:0x112233
  4156. @end example
  4157. @item
  4158. Apply the perspective effect, specifying the top left and top right image
  4159. positions:
  4160. @example
  4161. frei0r=perspective:0.2/0.2|0.8/0.2
  4162. @end example
  4163. @end itemize
  4164. For more information, see
  4165. @url{http://frei0r.dyne.org}
  4166. @section fspp
  4167. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4168. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4169. processing filter, one of them is performed once per block, not per pixel.
  4170. This allows for much higher speed.
  4171. The filter accepts the following options:
  4172. @table @option
  4173. @item quality
  4174. Set quality. This option defines the number of levels for averaging. It accepts
  4175. an integer in the range 4-5. Default value is @code{4}.
  4176. @item qp
  4177. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4178. If not set, the filter will use the QP from the video stream (if available).
  4179. @item strength
  4180. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4181. more details but also more artifacts, while higher values make the image smoother
  4182. but also blurrier. Default value is @code{0} − PSNR optimal.
  4183. @item use_bframe_qp
  4184. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4185. option may cause flicker since the B-Frames have often larger QP. Default is
  4186. @code{0} (not enabled).
  4187. @end table
  4188. @section geq
  4189. The filter accepts the following options:
  4190. @table @option
  4191. @item lum_expr, lum
  4192. Set the luminance expression.
  4193. @item cb_expr, cb
  4194. Set the chrominance blue expression.
  4195. @item cr_expr, cr
  4196. Set the chrominance red expression.
  4197. @item alpha_expr, a
  4198. Set the alpha expression.
  4199. @item red_expr, r
  4200. Set the red expression.
  4201. @item green_expr, g
  4202. Set the green expression.
  4203. @item blue_expr, b
  4204. Set the blue expression.
  4205. @end table
  4206. The colorspace is selected according to the specified options. If one
  4207. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4208. options is specified, the filter will automatically select a YCbCr
  4209. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4210. @option{blue_expr} options is specified, it will select an RGB
  4211. colorspace.
  4212. If one of the chrominance expression is not defined, it falls back on the other
  4213. one. If no alpha expression is specified it will evaluate to opaque value.
  4214. If none of chrominance expressions are specified, they will evaluate
  4215. to the luminance expression.
  4216. The expressions can use the following variables and functions:
  4217. @table @option
  4218. @item N
  4219. The sequential number of the filtered frame, starting from @code{0}.
  4220. @item X
  4221. @item Y
  4222. The coordinates of the current sample.
  4223. @item W
  4224. @item H
  4225. The width and height of the image.
  4226. @item SW
  4227. @item SH
  4228. Width and height scale depending on the currently filtered plane. It is the
  4229. ratio between the corresponding luma plane number of pixels and the current
  4230. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4231. @code{0.5,0.5} for chroma planes.
  4232. @item T
  4233. Time of the current frame, expressed in seconds.
  4234. @item p(x, y)
  4235. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4236. plane.
  4237. @item lum(x, y)
  4238. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4239. plane.
  4240. @item cb(x, y)
  4241. Return the value of the pixel at location (@var{x},@var{y}) of the
  4242. blue-difference chroma plane. Return 0 if there is no such plane.
  4243. @item cr(x, y)
  4244. Return the value of the pixel at location (@var{x},@var{y}) of the
  4245. red-difference chroma plane. Return 0 if there is no such plane.
  4246. @item r(x, y)
  4247. @item g(x, y)
  4248. @item b(x, y)
  4249. Return the value of the pixel at location (@var{x},@var{y}) of the
  4250. red/green/blue component. Return 0 if there is no such component.
  4251. @item alpha(x, y)
  4252. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4253. plane. Return 0 if there is no such plane.
  4254. @end table
  4255. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4256. automatically clipped to the closer edge.
  4257. @subsection Examples
  4258. @itemize
  4259. @item
  4260. Flip the image horizontally:
  4261. @example
  4262. geq=p(W-X\,Y)
  4263. @end example
  4264. @item
  4265. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4266. wavelength of 100 pixels:
  4267. @example
  4268. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4269. @end example
  4270. @item
  4271. Generate a fancy enigmatic moving light:
  4272. @example
  4273. 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
  4274. @end example
  4275. @item
  4276. Generate a quick emboss effect:
  4277. @example
  4278. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4279. @end example
  4280. @item
  4281. Modify RGB components depending on pixel position:
  4282. @example
  4283. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4284. @end example
  4285. @item
  4286. Create a radial gradient that is the same size as the input (also see
  4287. the @ref{vignette} filter):
  4288. @example
  4289. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4290. @end example
  4291. @item
  4292. Create a linear gradient to use as a mask for another filter, then
  4293. compose with @ref{overlay}. In this example the video will gradually
  4294. become more blurry from the top to the bottom of the y-axis as defined
  4295. by the linear gradient:
  4296. @example
  4297. ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
  4298. @end example
  4299. @end itemize
  4300. @section gradfun
  4301. Fix the banding artifacts that are sometimes introduced into nearly flat
  4302. regions by truncation to 8bit color depth.
  4303. Interpolate the gradients that should go where the bands are, and
  4304. dither them.
  4305. It is designed for playback only. Do not use it prior to
  4306. lossy compression, because compression tends to lose the dither and
  4307. bring back the bands.
  4308. It accepts the following parameters:
  4309. @table @option
  4310. @item strength
  4311. The maximum amount by which the filter will change any one pixel. This is also
  4312. the threshold for detecting nearly flat regions. Acceptable values range from
  4313. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4314. valid range.
  4315. @item radius
  4316. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4317. gradients, but also prevents the filter from modifying the pixels near detailed
  4318. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4319. values will be clipped to the valid range.
  4320. @end table
  4321. Alternatively, the options can be specified as a flat string:
  4322. @var{strength}[:@var{radius}]
  4323. @subsection Examples
  4324. @itemize
  4325. @item
  4326. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4327. @example
  4328. gradfun=3.5:8
  4329. @end example
  4330. @item
  4331. Specify radius, omitting the strength (which will fall-back to the default
  4332. value):
  4333. @example
  4334. gradfun=radius=8
  4335. @end example
  4336. @end itemize
  4337. @anchor{haldclut}
  4338. @section haldclut
  4339. Apply a Hald CLUT to a video stream.
  4340. First input is the video stream to process, and second one is the Hald CLUT.
  4341. The Hald CLUT input can be a simple picture or a complete video stream.
  4342. The filter accepts the following options:
  4343. @table @option
  4344. @item shortest
  4345. Force termination when the shortest input terminates. Default is @code{0}.
  4346. @item repeatlast
  4347. Continue applying the last CLUT after the end of the stream. A value of
  4348. @code{0} disable the filter after the last frame of the CLUT is reached.
  4349. Default is @code{1}.
  4350. @end table
  4351. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  4352. filters share the same internals).
  4353. More information about the Hald CLUT can be found on Eskil Steenberg's website
  4354. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  4355. @subsection Workflow examples
  4356. @subsubsection Hald CLUT video stream
  4357. Generate an identity Hald CLUT stream altered with various effects:
  4358. @example
  4359. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "hue=H=2*PI*t:s=sin(2*PI*t)+1, curves=cross_process" -t 10 -c:v ffv1 clut.nut
  4360. @end example
  4361. Note: make sure you use a lossless codec.
  4362. Then use it with @code{haldclut} to apply it on some random stream:
  4363. @example
  4364. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  4365. @end example
  4366. The Hald CLUT will be applied to the 10 first seconds (duration of
  4367. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  4368. to the remaining frames of the @code{mandelbrot} stream.
  4369. @subsubsection Hald CLUT with preview
  4370. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  4371. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  4372. biggest possible square starting at the top left of the picture. The remaining
  4373. padding pixels (bottom or right) will be ignored. This area can be used to add
  4374. a preview of the Hald CLUT.
  4375. Typically, the following generated Hald CLUT will be supported by the
  4376. @code{haldclut} filter:
  4377. @example
  4378. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  4379. pad=iw+320 [padded_clut];
  4380. smptebars=s=320x256, split [a][b];
  4381. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  4382. [main][b] overlay=W-320" -frames:v 1 clut.png
  4383. @end example
  4384. It contains the original and a preview of the effect of the CLUT: SMPTE color
  4385. bars are displayed on the right-top, and below the same color bars processed by
  4386. the color changes.
  4387. Then, the effect of this Hald CLUT can be visualized with:
  4388. @example
  4389. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  4390. @end example
  4391. @section hflip
  4392. Flip the input video horizontally.
  4393. For example, to horizontally flip the input video with @command{ffmpeg}:
  4394. @example
  4395. ffmpeg -i in.avi -vf "hflip" out.avi
  4396. @end example
  4397. @section histeq
  4398. This filter applies a global color histogram equalization on a
  4399. per-frame basis.
  4400. It can be used to correct video that has a compressed range of pixel
  4401. intensities. The filter redistributes the pixel intensities to
  4402. equalize their distribution across the intensity range. It may be
  4403. viewed as an "automatically adjusting contrast filter". This filter is
  4404. useful only for correcting degraded or poorly captured source
  4405. video.
  4406. The filter accepts the following options:
  4407. @table @option
  4408. @item strength
  4409. Determine the amount of equalization to be applied. As the strength
  4410. is reduced, the distribution of pixel intensities more-and-more
  4411. approaches that of the input frame. The value must be a float number
  4412. in the range [0,1] and defaults to 0.200.
  4413. @item intensity
  4414. Set the maximum intensity that can generated and scale the output
  4415. values appropriately. The strength should be set as desired and then
  4416. the intensity can be limited if needed to avoid washing-out. The value
  4417. must be a float number in the range [0,1] and defaults to 0.210.
  4418. @item antibanding
  4419. Set the antibanding level. If enabled the filter will randomly vary
  4420. the luminance of output pixels by a small amount to avoid banding of
  4421. the histogram. Possible values are @code{none}, @code{weak} or
  4422. @code{strong}. It defaults to @code{none}.
  4423. @end table
  4424. @section histogram
  4425. Compute and draw a color distribution histogram for the input video.
  4426. The computed histogram is a representation of the color component
  4427. distribution in an image.
  4428. The filter accepts the following options:
  4429. @table @option
  4430. @item mode
  4431. Set histogram mode.
  4432. It accepts the following values:
  4433. @table @samp
  4434. @item levels
  4435. Standard histogram that displays the color components distribution in an
  4436. image. Displays color graph for each color component. Shows distribution of
  4437. the Y, U, V, A or R, G, B components, depending on input format, in the
  4438. current frame. Below each graph a color component scale meter is shown.
  4439. @item color
  4440. Displays chroma values (U/V color placement) in a two dimensional
  4441. graph (which is called a vectorscope). The brighter a pixel in the
  4442. vectorscope, the more pixels of the input frame correspond to that pixel
  4443. (i.e., more pixels have this chroma value). The V component is displayed on
  4444. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  4445. side being V = 255. The U component is displayed on the vertical (Y) axis,
  4446. with the top representing U = 0 and the bottom representing U = 255.
  4447. The position of a white pixel in the graph corresponds to the chroma value of
  4448. a pixel of the input clip. The graph can therefore be used to read the hue
  4449. (color flavor) and the saturation (the dominance of the hue in the color). As
  4450. the hue of a color changes, it moves around the square. At the center of the
  4451. square the saturation is zero, which means that the corresponding pixel has no
  4452. color. If the amount of a specific color is increased (while leaving the other
  4453. colors unchanged) the saturation increases, and the indicator moves towards
  4454. the edge of the square.
  4455. @item color2
  4456. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  4457. are displayed.
  4458. @item waveform
  4459. Per row/column color component graph. In row mode, the graph on the left side
  4460. represents color component value 0 and the right side represents value = 255.
  4461. In column mode, the top side represents color component value = 0 and bottom
  4462. side represents value = 255.
  4463. @end table
  4464. Default value is @code{levels}.
  4465. @item level_height
  4466. Set height of level in @code{levels}. Default value is @code{200}.
  4467. Allowed range is [50, 2048].
  4468. @item scale_height
  4469. Set height of color scale in @code{levels}. Default value is @code{12}.
  4470. Allowed range is [0, 40].
  4471. @item step
  4472. Set step for @code{waveform} mode. Smaller values are useful to find out how
  4473. many values of the same luminance are distributed across input rows/columns.
  4474. Default value is @code{10}. Allowed range is [1, 255].
  4475. @item waveform_mode
  4476. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  4477. Default is @code{row}.
  4478. @item waveform_mirror
  4479. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  4480. means mirrored. In mirrored mode, higher values will be represented on the left
  4481. side for @code{row} mode and at the top for @code{column} mode. Default is
  4482. @code{0} (unmirrored).
  4483. @item display_mode
  4484. Set display mode for @code{waveform} and @code{levels}.
  4485. It accepts the following values:
  4486. @table @samp
  4487. @item parade
  4488. Display separate graph for the color components side by side in
  4489. @code{row} waveform mode or one below the other in @code{column} waveform mode
  4490. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  4491. per color component graphs are placed below each other.
  4492. Using this display mode in @code{waveform} histogram mode makes it easy to
  4493. spot color casts in the highlights and shadows of an image, by comparing the
  4494. contours of the top and the bottom graphs of each waveform. Since whites,
  4495. grays, and blacks are characterized by exactly equal amounts of red, green,
  4496. and blue, neutral areas of the picture should display three waveforms of
  4497. roughly equal width/height. If not, the correction is easy to perform by
  4498. making level adjustments the three waveforms.
  4499. @item overlay
  4500. Presents information identical to that in the @code{parade}, except
  4501. that the graphs representing color components are superimposed directly
  4502. over one another.
  4503. This display mode in @code{waveform} histogram mode makes it easier to spot
  4504. relative differences or similarities in overlapping areas of the color
  4505. components that are supposed to be identical, such as neutral whites, grays,
  4506. or blacks.
  4507. @end table
  4508. Default is @code{parade}.
  4509. @item levels_mode
  4510. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  4511. Default is @code{linear}.
  4512. @end table
  4513. @subsection Examples
  4514. @itemize
  4515. @item
  4516. Calculate and draw histogram:
  4517. @example
  4518. ffplay -i input -vf histogram
  4519. @end example
  4520. @end itemize
  4521. @anchor{hqdn3d}
  4522. @section hqdn3d
  4523. This is a high precision/quality 3d denoise filter. It aims to reduce
  4524. image noise, producing smooth images and making still images really
  4525. still. It should enhance compressibility.
  4526. It accepts the following optional parameters:
  4527. @table @option
  4528. @item luma_spatial
  4529. A non-negative floating point number which specifies spatial luma strength.
  4530. It defaults to 4.0.
  4531. @item chroma_spatial
  4532. A non-negative floating point number which specifies spatial chroma strength.
  4533. It defaults to 3.0*@var{luma_spatial}/4.0.
  4534. @item luma_tmp
  4535. A floating point number which specifies luma temporal strength. It defaults to
  4536. 6.0*@var{luma_spatial}/4.0.
  4537. @item chroma_tmp
  4538. A floating point number which specifies chroma temporal strength. It defaults to
  4539. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  4540. @end table
  4541. @section hqx
  4542. Apply a high-quality magnification filter designed for pixel art. This filter
  4543. was originally created by Maxim Stepin.
  4544. It accepts the following option:
  4545. @table @option
  4546. @item n
  4547. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  4548. @code{hq3x} and @code{4} for @code{hq4x}.
  4549. Default is @code{3}.
  4550. @end table
  4551. @section hue
  4552. Modify the hue and/or the saturation of the input.
  4553. It accepts the following parameters:
  4554. @table @option
  4555. @item h
  4556. Specify the hue angle as a number of degrees. It accepts an expression,
  4557. and defaults to "0".
  4558. @item s
  4559. Specify the saturation in the [-10,10] range. It accepts an expression and
  4560. defaults to "1".
  4561. @item H
  4562. Specify the hue angle as a number of radians. It accepts an
  4563. expression, and defaults to "0".
  4564. @item b
  4565. Specify the brightness in the [-10,10] range. It accepts an expression and
  4566. defaults to "0".
  4567. @end table
  4568. @option{h} and @option{H} are mutually exclusive, and can't be
  4569. specified at the same time.
  4570. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  4571. expressions containing the following constants:
  4572. @table @option
  4573. @item n
  4574. frame count of the input frame starting from 0
  4575. @item pts
  4576. presentation timestamp of the input frame expressed in time base units
  4577. @item r
  4578. frame rate of the input video, NAN if the input frame rate is unknown
  4579. @item t
  4580. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4581. @item tb
  4582. time base of the input video
  4583. @end table
  4584. @subsection Examples
  4585. @itemize
  4586. @item
  4587. Set the hue to 90 degrees and the saturation to 1.0:
  4588. @example
  4589. hue=h=90:s=1
  4590. @end example
  4591. @item
  4592. Same command but expressing the hue in radians:
  4593. @example
  4594. hue=H=PI/2:s=1
  4595. @end example
  4596. @item
  4597. Rotate hue and make the saturation swing between 0
  4598. and 2 over a period of 1 second:
  4599. @example
  4600. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  4601. @end example
  4602. @item
  4603. Apply a 3 seconds saturation fade-in effect starting at 0:
  4604. @example
  4605. hue="s=min(t/3\,1)"
  4606. @end example
  4607. The general fade-in expression can be written as:
  4608. @example
  4609. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  4610. @end example
  4611. @item
  4612. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  4613. @example
  4614. hue="s=max(0\, min(1\, (8-t)/3))"
  4615. @end example
  4616. The general fade-out expression can be written as:
  4617. @example
  4618. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  4619. @end example
  4620. @end itemize
  4621. @subsection Commands
  4622. This filter supports the following commands:
  4623. @table @option
  4624. @item b
  4625. @item s
  4626. @item h
  4627. @item H
  4628. Modify the hue and/or the saturation and/or brightness of the input video.
  4629. The command accepts the same syntax of the corresponding option.
  4630. If the specified expression is not valid, it is kept at its current
  4631. value.
  4632. @end table
  4633. @section idet
  4634. Detect video interlacing type.
  4635. This filter tries to detect if the input frames as interlaced, progressive,
  4636. top or bottom field first. It will also try and detect fields that are
  4637. repeated between adjacent frames (a sign of telecine).
  4638. Single frame detection considers only immediately adjacent frames when classifying each frame.
  4639. Multiple frame detection incorporates the classification history of previous frames.
  4640. The filter will log these metadata values:
  4641. @table @option
  4642. @item single.current_frame
  4643. Detected type of current frame using single-frame detection. One of:
  4644. ``tff'' (top field first), ``bff'' (bottom field first),
  4645. ``progressive'', or ``undetermined''
  4646. @item single.tff
  4647. Cumulative number of frames detected as top field first using single-frame detection.
  4648. @item multiple.tff
  4649. Cumulative number of frames detected as top field first using multiple-frame detection.
  4650. @item single.bff
  4651. Cumulative number of frames detected as bottom field first using single-frame detection.
  4652. @item multiple.current_frame
  4653. Detected type of current frame using multiple-frame detection. One of:
  4654. ``tff'' (top field first), ``bff'' (bottom field first),
  4655. ``progressive'', or ``undetermined''
  4656. @item multiple.bff
  4657. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  4658. @item single.progressive
  4659. Cumulative number of frames detected as progressive using single-frame detection.
  4660. @item multiple.progressive
  4661. Cumulative number of frames detected as progressive using multiple-frame detection.
  4662. @item single.undetermined
  4663. Cumulative number of frames that could not be classified using single-frame detection.
  4664. @item multiple.undetermined
  4665. Cumulative number of frames that could not be classified using multiple-frame detection.
  4666. @item repeated.current_frame
  4667. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  4668. @item repeated.neither
  4669. Cumulative number of frames with no repeated field.
  4670. @item repeated.top
  4671. Cumulative number of frames with the top field repeated from the previous frame's top field.
  4672. @item repeated.bottom
  4673. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  4674. @end table
  4675. The filter accepts the following options:
  4676. @table @option
  4677. @item intl_thres
  4678. Set interlacing threshold.
  4679. @item prog_thres
  4680. Set progressive threshold.
  4681. @item repeat_thres
  4682. Threshold for repeated field detection.
  4683. @item half_life
  4684. Number of frames after which a given frame's contribution to the
  4685. statistics is halved (i.e., it contributes only 0.5 to it's
  4686. classification). The default of 0 means that all frames seen are given
  4687. full weight of 1.0 forever.
  4688. @item analyze_interlaced_flag
  4689. When this is not 0 then idet will use the specified number of frames to determine
  4690. if the interlaced flag is accurate, it will not count undetermined frames.
  4691. If the flag is found to be accurate it will be used without any further
  4692. computations, if it is found to be inaccurate it will be cleared without any
  4693. further computations. This allows inserting the idet filter as a low computational
  4694. method to clean up the interlaced flag
  4695. @end table
  4696. @section il
  4697. Deinterleave or interleave fields.
  4698. This filter allows one to process interlaced images fields without
  4699. deinterlacing them. Deinterleaving splits the input frame into 2
  4700. fields (so called half pictures). Odd lines are moved to the top
  4701. half of the output image, even lines to the bottom half.
  4702. You can process (filter) them independently and then re-interleave them.
  4703. The filter accepts the following options:
  4704. @table @option
  4705. @item luma_mode, l
  4706. @item chroma_mode, c
  4707. @item alpha_mode, a
  4708. Available values for @var{luma_mode}, @var{chroma_mode} and
  4709. @var{alpha_mode} are:
  4710. @table @samp
  4711. @item none
  4712. Do nothing.
  4713. @item deinterleave, d
  4714. Deinterleave fields, placing one above the other.
  4715. @item interleave, i
  4716. Interleave fields. Reverse the effect of deinterleaving.
  4717. @end table
  4718. Default value is @code{none}.
  4719. @item luma_swap, ls
  4720. @item chroma_swap, cs
  4721. @item alpha_swap, as
  4722. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  4723. @end table
  4724. @section interlace
  4725. Simple interlacing filter from progressive contents. This interleaves upper (or
  4726. lower) lines from odd frames with lower (or upper) lines from even frames,
  4727. halving the frame rate and preserving image height.
  4728. @example
  4729. Original Original New Frame
  4730. Frame 'j' Frame 'j+1' (tff)
  4731. ========== =========== ==================
  4732. Line 0 --------------------> Frame 'j' Line 0
  4733. Line 1 Line 1 ----> Frame 'j+1' Line 1
  4734. Line 2 ---------------------> Frame 'j' Line 2
  4735. Line 3 Line 3 ----> Frame 'j+1' Line 3
  4736. ... ... ...
  4737. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  4738. @end example
  4739. It accepts the following optional parameters:
  4740. @table @option
  4741. @item scan
  4742. This determines whether the interlaced frame is taken from the even
  4743. (tff - default) or odd (bff) lines of the progressive frame.
  4744. @item lowpass
  4745. Enable (default) or disable the vertical lowpass filter to avoid twitter
  4746. interlacing and reduce moire patterns.
  4747. @end table
  4748. @section kerndeint
  4749. Deinterlace input video by applying Donald Graft's adaptive kernel
  4750. deinterling. Work on interlaced parts of a video to produce
  4751. progressive frames.
  4752. The description of the accepted parameters follows.
  4753. @table @option
  4754. @item thresh
  4755. Set the threshold which affects the filter's tolerance when
  4756. determining if a pixel line must be processed. It must be an integer
  4757. in the range [0,255] and defaults to 10. A value of 0 will result in
  4758. applying the process on every pixels.
  4759. @item map
  4760. Paint pixels exceeding the threshold value to white if set to 1.
  4761. Default is 0.
  4762. @item order
  4763. Set the fields order. Swap fields if set to 1, leave fields alone if
  4764. 0. Default is 0.
  4765. @item sharp
  4766. Enable additional sharpening if set to 1. Default is 0.
  4767. @item twoway
  4768. Enable twoway sharpening if set to 1. Default is 0.
  4769. @end table
  4770. @subsection Examples
  4771. @itemize
  4772. @item
  4773. Apply default values:
  4774. @example
  4775. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  4776. @end example
  4777. @item
  4778. Enable additional sharpening:
  4779. @example
  4780. kerndeint=sharp=1
  4781. @end example
  4782. @item
  4783. Paint processed pixels in white:
  4784. @example
  4785. kerndeint=map=1
  4786. @end example
  4787. @end itemize
  4788. @section lenscorrection
  4789. Correct radial lens distortion
  4790. This filter can be used to correct for radial distortion as can result from the use
  4791. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  4792. one can use tools available for example as part of opencv or simply trial-and-error.
  4793. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  4794. and extract the k1 and k2 coefficients from the resulting matrix.
  4795. Note that effectively the same filter is available in the open-source tools Krita and
  4796. Digikam from the KDE project.
  4797. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  4798. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  4799. brightness distribution, so you may want to use both filters together in certain
  4800. cases, though you will have to take care of ordering, i.e. whether vignetting should
  4801. be applied before or after lens correction.
  4802. @subsection Options
  4803. The filter accepts the following options:
  4804. @table @option
  4805. @item cx
  4806. Relative x-coordinate of the focal point of the image, and thereby the center of the
  4807. distortion. This value has a range [0,1] and is expressed as fractions of the image
  4808. width.
  4809. @item cy
  4810. Relative y-coordinate of the focal point of the image, and thereby the center of the
  4811. distortion. This value has a range [0,1] and is expressed as fractions of the image
  4812. height.
  4813. @item k1
  4814. Coefficient of the quadratic correction term. 0.5 means no correction.
  4815. @item k2
  4816. Coefficient of the double quadratic correction term. 0.5 means no correction.
  4817. @end table
  4818. The formula that generates the correction is:
  4819. @var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4)
  4820. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  4821. distances from the focal point in the source and target images, respectively.
  4822. @anchor{lut3d}
  4823. @section lut3d
  4824. Apply a 3D LUT to an input video.
  4825. The filter accepts the following options:
  4826. @table @option
  4827. @item file
  4828. Set the 3D LUT file name.
  4829. Currently supported formats:
  4830. @table @samp
  4831. @item 3dl
  4832. AfterEffects
  4833. @item cube
  4834. Iridas
  4835. @item dat
  4836. DaVinci
  4837. @item m3d
  4838. Pandora
  4839. @end table
  4840. @item interp
  4841. Select interpolation mode.
  4842. Available values are:
  4843. @table @samp
  4844. @item nearest
  4845. Use values from the nearest defined point.
  4846. @item trilinear
  4847. Interpolate values using the 8 points defining a cube.
  4848. @item tetrahedral
  4849. Interpolate values using a tetrahedron.
  4850. @end table
  4851. @end table
  4852. @section lut, lutrgb, lutyuv
  4853. Compute a look-up table for binding each pixel component input value
  4854. to an output value, and apply it to the input video.
  4855. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  4856. to an RGB input video.
  4857. These filters accept the following parameters:
  4858. @table @option
  4859. @item c0
  4860. set first pixel component expression
  4861. @item c1
  4862. set second pixel component expression
  4863. @item c2
  4864. set third pixel component expression
  4865. @item c3
  4866. set fourth pixel component expression, corresponds to the alpha component
  4867. @item r
  4868. set red component expression
  4869. @item g
  4870. set green component expression
  4871. @item b
  4872. set blue component expression
  4873. @item a
  4874. alpha component expression
  4875. @item y
  4876. set Y/luminance component expression
  4877. @item u
  4878. set U/Cb component expression
  4879. @item v
  4880. set V/Cr component expression
  4881. @end table
  4882. Each of them specifies the expression to use for computing the lookup table for
  4883. the corresponding pixel component values.
  4884. The exact component associated to each of the @var{c*} options depends on the
  4885. format in input.
  4886. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  4887. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  4888. The expressions can contain the following constants and functions:
  4889. @table @option
  4890. @item w
  4891. @item h
  4892. The input width and height.
  4893. @item val
  4894. The input value for the pixel component.
  4895. @item clipval
  4896. The input value, clipped to the @var{minval}-@var{maxval} range.
  4897. @item maxval
  4898. The maximum value for the pixel component.
  4899. @item minval
  4900. The minimum value for the pixel component.
  4901. @item negval
  4902. The negated value for the pixel component value, clipped to the
  4903. @var{minval}-@var{maxval} range; it corresponds to the expression
  4904. "maxval-clipval+minval".
  4905. @item clip(val)
  4906. The computed value in @var{val}, clipped to the
  4907. @var{minval}-@var{maxval} range.
  4908. @item gammaval(gamma)
  4909. The computed gamma correction value of the pixel component value,
  4910. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  4911. expression
  4912. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  4913. @end table
  4914. All expressions default to "val".
  4915. @subsection Examples
  4916. @itemize
  4917. @item
  4918. Negate input video:
  4919. @example
  4920. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  4921. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  4922. @end example
  4923. The above is the same as:
  4924. @example
  4925. lutrgb="r=negval:g=negval:b=negval"
  4926. lutyuv="y=negval:u=negval:v=negval"
  4927. @end example
  4928. @item
  4929. Negate luminance:
  4930. @example
  4931. lutyuv=y=negval
  4932. @end example
  4933. @item
  4934. Remove chroma components, turning the video into a graytone image:
  4935. @example
  4936. lutyuv="u=128:v=128"
  4937. @end example
  4938. @item
  4939. Apply a luma burning effect:
  4940. @example
  4941. lutyuv="y=2*val"
  4942. @end example
  4943. @item
  4944. Remove green and blue components:
  4945. @example
  4946. lutrgb="g=0:b=0"
  4947. @end example
  4948. @item
  4949. Set a constant alpha channel value on input:
  4950. @example
  4951. format=rgba,lutrgb=a="maxval-minval/2"
  4952. @end example
  4953. @item
  4954. Correct luminance gamma by a factor of 0.5:
  4955. @example
  4956. lutyuv=y=gammaval(0.5)
  4957. @end example
  4958. @item
  4959. Discard least significant bits of luma:
  4960. @example
  4961. lutyuv=y='bitand(val, 128+64+32)'
  4962. @end example
  4963. @end itemize
  4964. @section mergeplanes
  4965. Merge color channel components from several video streams.
  4966. The filter accepts up to 4 input streams, and merge selected input
  4967. planes to the output video.
  4968. This filter accepts the following options:
  4969. @table @option
  4970. @item mapping
  4971. Set input to output plane mapping. Default is @code{0}.
  4972. The mappings is specified as a bitmap. It should be specified as a
  4973. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  4974. mapping for the first plane of the output stream. 'A' sets the number of
  4975. the input stream to use (from 0 to 3), and 'a' the plane number of the
  4976. corresponding input to use (from 0 to 3). The rest of the mappings is
  4977. similar, 'Bb' describes the mapping for the output stream second
  4978. plane, 'Cc' describes the mapping for the output stream third plane and
  4979. 'Dd' describes the mapping for the output stream fourth plane.
  4980. @item format
  4981. Set output pixel format. Default is @code{yuva444p}.
  4982. @end table
  4983. @subsection Examples
  4984. @itemize
  4985. @item
  4986. Merge three gray video streams of same width and height into single video stream:
  4987. @example
  4988. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  4989. @end example
  4990. @item
  4991. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  4992. @example
  4993. [a0][a1]mergeplanes=0x00010210:yuva444p
  4994. @end example
  4995. @item
  4996. Swap Y and A plane in yuva444p stream:
  4997. @example
  4998. format=yuva444p,mergeplanes=0x03010200:yuva444p
  4999. @end example
  5000. @item
  5001. Swap U and V plane in yuv420p stream:
  5002. @example
  5003. format=yuv420p,mergeplanes=0x000201:yuv420p
  5004. @end example
  5005. @item
  5006. Cast a rgb24 clip to yuv444p:
  5007. @example
  5008. format=rgb24,mergeplanes=0x000102:yuv444p
  5009. @end example
  5010. @end itemize
  5011. @section mcdeint
  5012. Apply motion-compensation deinterlacing.
  5013. It needs one field per frame as input and must thus be used together
  5014. with yadif=1/3 or equivalent.
  5015. This filter accepts the following options:
  5016. @table @option
  5017. @item mode
  5018. Set the deinterlacing mode.
  5019. It accepts one of the following values:
  5020. @table @samp
  5021. @item fast
  5022. @item medium
  5023. @item slow
  5024. use iterative motion estimation
  5025. @item extra_slow
  5026. like @samp{slow}, but use multiple reference frames.
  5027. @end table
  5028. Default value is @samp{fast}.
  5029. @item parity
  5030. Set the picture field parity assumed for the input video. It must be
  5031. one of the following values:
  5032. @table @samp
  5033. @item 0, tff
  5034. assume top field first
  5035. @item 1, bff
  5036. assume bottom field first
  5037. @end table
  5038. Default value is @samp{bff}.
  5039. @item qp
  5040. Set per-block quantization parameter (QP) used by the internal
  5041. encoder.
  5042. Higher values should result in a smoother motion vector field but less
  5043. optimal individual vectors. Default value is 1.
  5044. @end table
  5045. @section mpdecimate
  5046. Drop frames that do not differ greatly from the previous frame in
  5047. order to reduce frame rate.
  5048. The main use of this filter is for very-low-bitrate encoding
  5049. (e.g. streaming over dialup modem), but it could in theory be used for
  5050. fixing movies that were inverse-telecined incorrectly.
  5051. A description of the accepted options follows.
  5052. @table @option
  5053. @item max
  5054. Set the maximum number of consecutive frames which can be dropped (if
  5055. positive), or the minimum interval between dropped frames (if
  5056. negative). If the value is 0, the frame is dropped unregarding the
  5057. number of previous sequentially dropped frames.
  5058. Default value is 0.
  5059. @item hi
  5060. @item lo
  5061. @item frac
  5062. Set the dropping threshold values.
  5063. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5064. represent actual pixel value differences, so a threshold of 64
  5065. corresponds to 1 unit of difference for each pixel, or the same spread
  5066. out differently over the block.
  5067. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5068. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5069. meaning the whole image) differ by more than a threshold of @option{lo}.
  5070. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5071. 64*5, and default value for @option{frac} is 0.33.
  5072. @end table
  5073. @section negate
  5074. Negate input video.
  5075. It accepts an integer in input; if non-zero it negates the
  5076. alpha component (if available). The default value in input is 0.
  5077. @section noformat
  5078. Force libavfilter not to use any of the specified pixel formats for the
  5079. input to the next filter.
  5080. It accepts the following parameters:
  5081. @table @option
  5082. @item pix_fmts
  5083. A '|'-separated list of pixel format names, such as
  5084. apix_fmts=yuv420p|monow|rgb24".
  5085. @end table
  5086. @subsection Examples
  5087. @itemize
  5088. @item
  5089. Force libavfilter to use a format different from @var{yuv420p} for the
  5090. input to the vflip filter:
  5091. @example
  5092. noformat=pix_fmts=yuv420p,vflip
  5093. @end example
  5094. @item
  5095. Convert the input video to any of the formats not contained in the list:
  5096. @example
  5097. noformat=yuv420p|yuv444p|yuv410p
  5098. @end example
  5099. @end itemize
  5100. @section noise
  5101. Add noise on video input frame.
  5102. The filter accepts the following options:
  5103. @table @option
  5104. @item all_seed
  5105. @item c0_seed
  5106. @item c1_seed
  5107. @item c2_seed
  5108. @item c3_seed
  5109. Set noise seed for specific pixel component or all pixel components in case
  5110. of @var{all_seed}. Default value is @code{123457}.
  5111. @item all_strength, alls
  5112. @item c0_strength, c0s
  5113. @item c1_strength, c1s
  5114. @item c2_strength, c2s
  5115. @item c3_strength, c3s
  5116. Set noise strength for specific pixel component or all pixel components in case
  5117. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5118. @item all_flags, allf
  5119. @item c0_flags, c0f
  5120. @item c1_flags, c1f
  5121. @item c2_flags, c2f
  5122. @item c3_flags, c3f
  5123. Set pixel component flags or set flags for all components if @var{all_flags}.
  5124. Available values for component flags are:
  5125. @table @samp
  5126. @item a
  5127. averaged temporal noise (smoother)
  5128. @item p
  5129. mix random noise with a (semi)regular pattern
  5130. @item t
  5131. temporal noise (noise pattern changes between frames)
  5132. @item u
  5133. uniform noise (gaussian otherwise)
  5134. @end table
  5135. @end table
  5136. @subsection Examples
  5137. Add temporal and uniform noise to input video:
  5138. @example
  5139. noise=alls=20:allf=t+u
  5140. @end example
  5141. @section null
  5142. Pass the video source unchanged to the output.
  5143. @section ocv
  5144. Apply a video transform using libopencv.
  5145. To enable this filter, install the libopencv library and headers and
  5146. configure FFmpeg with @code{--enable-libopencv}.
  5147. It accepts the following parameters:
  5148. @table @option
  5149. @item filter_name
  5150. The name of the libopencv filter to apply.
  5151. @item filter_params
  5152. The parameters to pass to the libopencv filter. If not specified, the default
  5153. values are assumed.
  5154. @end table
  5155. Refer to the official libopencv documentation for more precise
  5156. information:
  5157. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5158. Several libopencv filters are supported; see the following subsections.
  5159. @anchor{dilate}
  5160. @subsection dilate
  5161. Dilate an image by using a specific structuring element.
  5162. It corresponds to the libopencv function @code{cvDilate}.
  5163. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5164. @var{struct_el} represents a structuring element, and has the syntax:
  5165. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5166. @var{cols} and @var{rows} represent the number of columns and rows of
  5167. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5168. point, and @var{shape} the shape for the structuring element. @var{shape}
  5169. must be "rect", "cross", "ellipse", or "custom".
  5170. If the value for @var{shape} is "custom", it must be followed by a
  5171. string of the form "=@var{filename}". The file with name
  5172. @var{filename} is assumed to represent a binary image, with each
  5173. printable character corresponding to a bright pixel. When a custom
  5174. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5175. or columns and rows of the read file are assumed instead.
  5176. The default value for @var{struct_el} is "3x3+0x0/rect".
  5177. @var{nb_iterations} specifies the number of times the transform is
  5178. applied to the image, and defaults to 1.
  5179. Some examples:
  5180. @example
  5181. # Use the default values
  5182. ocv=dilate
  5183. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5184. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5185. # Read the shape from the file diamond.shape, iterating two times.
  5186. # The file diamond.shape may contain a pattern of characters like this
  5187. # *
  5188. # ***
  5189. # *****
  5190. # ***
  5191. # *
  5192. # The specified columns and rows are ignored
  5193. # but the anchor point coordinates are not
  5194. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5195. @end example
  5196. @subsection erode
  5197. Erode an image by using a specific structuring element.
  5198. It corresponds to the libopencv function @code{cvErode}.
  5199. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5200. with the same syntax and semantics as the @ref{dilate} filter.
  5201. @subsection smooth
  5202. Smooth the input video.
  5203. The filter takes the following parameters:
  5204. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5205. @var{type} is the type of smooth filter to apply, and must be one of
  5206. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5207. or "bilateral". The default value is "gaussian".
  5208. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5209. depend on the smooth type. @var{param1} and
  5210. @var{param2} accept integer positive values or 0. @var{param3} and
  5211. @var{param4} accept floating point values.
  5212. The default value for @var{param1} is 3. The default value for the
  5213. other parameters is 0.
  5214. These parameters correspond to the parameters assigned to the
  5215. libopencv function @code{cvSmooth}.
  5216. @anchor{overlay}
  5217. @section overlay
  5218. Overlay one video on top of another.
  5219. It takes two inputs and has one output. The first input is the "main"
  5220. video on which the second input is overlaid.
  5221. It accepts the following parameters:
  5222. A description of the accepted options follows.
  5223. @table @option
  5224. @item x
  5225. @item y
  5226. Set the expression for the x and y coordinates of the overlaid video
  5227. on the main video. Default value is "0" for both expressions. In case
  5228. the expression is invalid, it is set to a huge value (meaning that the
  5229. overlay will not be displayed within the output visible area).
  5230. @item eof_action
  5231. The action to take when EOF is encountered on the secondary input; it accepts
  5232. one of the following values:
  5233. @table @option
  5234. @item repeat
  5235. Repeat the last frame (the default).
  5236. @item endall
  5237. End both streams.
  5238. @item pass
  5239. Pass the main input through.
  5240. @end table
  5241. @item eval
  5242. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5243. It accepts the following values:
  5244. @table @samp
  5245. @item init
  5246. only evaluate expressions once during the filter initialization or
  5247. when a command is processed
  5248. @item frame
  5249. evaluate expressions for each incoming frame
  5250. @end table
  5251. Default value is @samp{frame}.
  5252. @item shortest
  5253. If set to 1, force the output to terminate when the shortest input
  5254. terminates. Default value is 0.
  5255. @item format
  5256. Set the format for the output video.
  5257. It accepts the following values:
  5258. @table @samp
  5259. @item yuv420
  5260. force YUV420 output
  5261. @item yuv422
  5262. force YUV422 output
  5263. @item yuv444
  5264. force YUV444 output
  5265. @item rgb
  5266. force RGB output
  5267. @end table
  5268. Default value is @samp{yuv420}.
  5269. @item rgb @emph{(deprecated)}
  5270. If set to 1, force the filter to accept inputs in the RGB
  5271. color space. Default value is 0. This option is deprecated, use
  5272. @option{format} instead.
  5273. @item repeatlast
  5274. If set to 1, force the filter to draw the last overlay frame over the
  5275. main input until the end of the stream. A value of 0 disables this
  5276. behavior. Default value is 1.
  5277. @end table
  5278. The @option{x}, and @option{y} expressions can contain the following
  5279. parameters.
  5280. @table @option
  5281. @item main_w, W
  5282. @item main_h, H
  5283. The main input width and height.
  5284. @item overlay_w, w
  5285. @item overlay_h, h
  5286. The overlay input width and height.
  5287. @item x
  5288. @item y
  5289. The computed values for @var{x} and @var{y}. They are evaluated for
  5290. each new frame.
  5291. @item hsub
  5292. @item vsub
  5293. horizontal and vertical chroma subsample values of the output
  5294. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5295. @var{vsub} is 1.
  5296. @item n
  5297. the number of input frame, starting from 0
  5298. @item pos
  5299. the position in the file of the input frame, NAN if unknown
  5300. @item t
  5301. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5302. @end table
  5303. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5304. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5305. when @option{eval} is set to @samp{init}.
  5306. Be aware that frames are taken from each input video in timestamp
  5307. order, hence, if their initial timestamps differ, it is a good idea
  5308. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  5309. have them begin in the same zero timestamp, as the example for
  5310. the @var{movie} filter does.
  5311. You can chain together more overlays but you should test the
  5312. efficiency of such approach.
  5313. @subsection Commands
  5314. This filter supports the following commands:
  5315. @table @option
  5316. @item x
  5317. @item y
  5318. Modify the x and y of the overlay input.
  5319. The command accepts the same syntax of the corresponding option.
  5320. If the specified expression is not valid, it is kept at its current
  5321. value.
  5322. @end table
  5323. @subsection Examples
  5324. @itemize
  5325. @item
  5326. Draw the overlay at 10 pixels from the bottom right corner of the main
  5327. video:
  5328. @example
  5329. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  5330. @end example
  5331. Using named options the example above becomes:
  5332. @example
  5333. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  5334. @end example
  5335. @item
  5336. Insert a transparent PNG logo in the bottom left corner of the input,
  5337. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  5338. @example
  5339. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  5340. @end example
  5341. @item
  5342. Insert 2 different transparent PNG logos (second logo on bottom
  5343. right corner) using the @command{ffmpeg} tool:
  5344. @example
  5345. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
  5346. @end example
  5347. @item
  5348. Add a transparent color layer on top of the main video; @code{WxH}
  5349. must specify the size of the main input to the overlay filter:
  5350. @example
  5351. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  5352. @end example
  5353. @item
  5354. Play an original video and a filtered version (here with the deshake
  5355. filter) side by side using the @command{ffplay} tool:
  5356. @example
  5357. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  5358. @end example
  5359. The above command is the same as:
  5360. @example
  5361. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  5362. @end example
  5363. @item
  5364. Make a sliding overlay appearing from the left to the right top part of the
  5365. screen starting since time 2:
  5366. @example
  5367. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  5368. @end example
  5369. @item
  5370. Compose output by putting two input videos side to side:
  5371. @example
  5372. ffmpeg -i left.avi -i right.avi -filter_complex "
  5373. nullsrc=size=200x100 [background];
  5374. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  5375. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  5376. [background][left] overlay=shortest=1 [background+left];
  5377. [background+left][right] overlay=shortest=1:x=100 [left+right]
  5378. "
  5379. @end example
  5380. @item
  5381. Mask 10-20 seconds of a video by applying the delogo filter to a section
  5382. @example
  5383. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  5384. -vf '[in]split[split_main][split_delogo];[split_delogo]trim=start=360:end=371,delogo=0:0:640:480[delogoed];[split_main][delogoed]overlay=eof_action=pass[out]'
  5385. masked.avi
  5386. @end example
  5387. @item
  5388. Chain several overlays in cascade:
  5389. @example
  5390. nullsrc=s=200x200 [bg];
  5391. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  5392. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  5393. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  5394. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  5395. [in3] null, [mid2] overlay=100:100 [out0]
  5396. @end example
  5397. @end itemize
  5398. @section owdenoise
  5399. Apply Overcomplete Wavelet denoiser.
  5400. The filter accepts the following options:
  5401. @table @option
  5402. @item depth
  5403. Set depth.
  5404. Larger depth values will denoise lower frequency components more, but
  5405. slow down filtering.
  5406. Must be an int in the range 8-16, default is @code{8}.
  5407. @item luma_strength, ls
  5408. Set luma strength.
  5409. Must be a double value in the range 0-1000, default is @code{1.0}.
  5410. @item chroma_strength, cs
  5411. Set chroma strength.
  5412. Must be a double value in the range 0-1000, default is @code{1.0}.
  5413. @end table
  5414. @section pad
  5415. Add paddings to the input image, and place the original input at the
  5416. provided @var{x}, @var{y} coordinates.
  5417. It accepts the following parameters:
  5418. @table @option
  5419. @item width, w
  5420. @item height, h
  5421. Specify an expression for the size of the output image with the
  5422. paddings added. If the value for @var{width} or @var{height} is 0, the
  5423. corresponding input size is used for the output.
  5424. The @var{width} expression can reference the value set by the
  5425. @var{height} expression, and vice versa.
  5426. The default value of @var{width} and @var{height} is 0.
  5427. @item x
  5428. @item y
  5429. Specify the offsets to place the input image at within the padded area,
  5430. with respect to the top/left border of the output image.
  5431. The @var{x} expression can reference the value set by the @var{y}
  5432. expression, and vice versa.
  5433. The default value of @var{x} and @var{y} is 0.
  5434. @item color
  5435. Specify the color of the padded area. For the syntax of this option,
  5436. check the "Color" section in the ffmpeg-utils manual.
  5437. The default value of @var{color} is "black".
  5438. @end table
  5439. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  5440. options are expressions containing the following constants:
  5441. @table @option
  5442. @item in_w
  5443. @item in_h
  5444. The input video width and height.
  5445. @item iw
  5446. @item ih
  5447. These are the same as @var{in_w} and @var{in_h}.
  5448. @item out_w
  5449. @item out_h
  5450. The output width and height (the size of the padded area), as
  5451. specified by the @var{width} and @var{height} expressions.
  5452. @item ow
  5453. @item oh
  5454. These are the same as @var{out_w} and @var{out_h}.
  5455. @item x
  5456. @item y
  5457. The x and y offsets as specified by the @var{x} and @var{y}
  5458. expressions, or NAN if not yet specified.
  5459. @item a
  5460. same as @var{iw} / @var{ih}
  5461. @item sar
  5462. input sample aspect ratio
  5463. @item dar
  5464. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  5465. @item hsub
  5466. @item vsub
  5467. The horizontal and vertical chroma subsample values. For example for the
  5468. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5469. @end table
  5470. @subsection Examples
  5471. @itemize
  5472. @item
  5473. Add paddings with the color "violet" to the input video. The output video
  5474. size is 640x480, and the top-left corner of the input video is placed at
  5475. column 0, row 40
  5476. @example
  5477. pad=640:480:0:40:violet
  5478. @end example
  5479. The example above is equivalent to the following command:
  5480. @example
  5481. pad=width=640:height=480:x=0:y=40:color=violet
  5482. @end example
  5483. @item
  5484. Pad the input to get an output with dimensions increased by 3/2,
  5485. and put the input video at the center of the padded area:
  5486. @example
  5487. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  5488. @end example
  5489. @item
  5490. Pad the input to get a squared output with size equal to the maximum
  5491. value between the input width and height, and put the input video at
  5492. the center of the padded area:
  5493. @example
  5494. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  5495. @end example
  5496. @item
  5497. Pad the input to get a final w/h ratio of 16:9:
  5498. @example
  5499. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  5500. @end example
  5501. @item
  5502. In case of anamorphic video, in order to set the output display aspect
  5503. correctly, it is necessary to use @var{sar} in the expression,
  5504. according to the relation:
  5505. @example
  5506. (ih * X / ih) * sar = output_dar
  5507. X = output_dar / sar
  5508. @end example
  5509. Thus the previous example needs to be modified to:
  5510. @example
  5511. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  5512. @end example
  5513. @item
  5514. Double the output size and put the input video in the bottom-right
  5515. corner of the output padded area:
  5516. @example
  5517. pad="2*iw:2*ih:ow-iw:oh-ih"
  5518. @end example
  5519. @end itemize
  5520. @anchor{palettegen}
  5521. @section palettegen
  5522. Generate one palette for a whole video stream.
  5523. It accepts the following options:
  5524. @table @option
  5525. @item max_colors
  5526. Set the maximum number of colors to quantize in the palette.
  5527. Note: the palette will still contain 256 colors; the unused palette entries
  5528. will be black.
  5529. @item reserve_transparent
  5530. Create a palette of 255 colors maximum and reserve the last one for
  5531. transparency. Reserving the transparency color is useful for GIF optimization.
  5532. If not set, the maximum of colors in the palette will be 256. You probably want
  5533. to disable this option for a standalone image.
  5534. Set by default.
  5535. @item stats_mode
  5536. Set statistics mode.
  5537. It accepts the following values:
  5538. @table @samp
  5539. @item full
  5540. Compute full frame histograms.
  5541. @item diff
  5542. Compute histograms only for the part that differs from previous frame. This
  5543. might be relevant to give more importance to the moving part of your input if
  5544. the background is static.
  5545. @end table
  5546. Default value is @var{full}.
  5547. @end table
  5548. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  5549. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  5550. color quantization of the palette. This information is also visible at
  5551. @var{info} logging level.
  5552. @subsection Examples
  5553. @itemize
  5554. @item
  5555. Generate a representative palette of a given video using @command{ffmpeg}:
  5556. @example
  5557. ffmpeg -i input.mkv -vf palettegen palette.png
  5558. @end example
  5559. @end itemize
  5560. @section paletteuse
  5561. Use a palette to downsample an input video stream.
  5562. The filter takes two inputs: one video stream and a palette. The palette must
  5563. be a 256 pixels image.
  5564. It accepts the following options:
  5565. @table @option
  5566. @item dither
  5567. Select dithering mode. Available algorithms are:
  5568. @table @samp
  5569. @item bayer
  5570. Ordered 8x8 bayer dithering (deterministic)
  5571. @item heckbert
  5572. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  5573. Note: this dithering is sometimes considered "wrong" and is included as a
  5574. reference.
  5575. @item floyd_steinberg
  5576. Floyd and Steingberg dithering (error diffusion)
  5577. @item sierra2
  5578. Frankie Sierra dithering v2 (error diffusion)
  5579. @item sierra2_4a
  5580. Frankie Sierra dithering v2 "Lite" (error diffusion)
  5581. @end table
  5582. Default is @var{sierra2_4a}.
  5583. @item bayer_scale
  5584. When @var{bayer} dithering is selected, this option defines the scale of the
  5585. pattern (how much the crosshatch pattern is visible). A low value means more
  5586. visible pattern for less banding, and higher value means less visible pattern
  5587. at the cost of more banding.
  5588. The option must be an integer value in the range [0,5]. Default is @var{2}.
  5589. @item diff_mode
  5590. If set, define the zone to process
  5591. @table @samp
  5592. @item rectangle
  5593. Only the changing rectangle will be reprocessed. This is similar to GIF
  5594. cropping/offsetting compression mechanism. This option can be useful for speed
  5595. if only a part of the image is changing, and has use cases such as limiting the
  5596. scope of the error diffusal @option{dither} to the rectangle that bounds the
  5597. moving scene (it leads to more deterministic output if the scene doesn't change
  5598. much, and as a result less moving noise and better GIF compression).
  5599. @end table
  5600. Default is @var{none}.
  5601. @end table
  5602. @subsection Examples
  5603. @itemize
  5604. @item
  5605. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  5606. using @command{ffmpeg}:
  5607. @example
  5608. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  5609. @end example
  5610. @end itemize
  5611. @section perspective
  5612. Correct perspective of video not recorded perpendicular to the screen.
  5613. A description of the accepted parameters follows.
  5614. @table @option
  5615. @item x0
  5616. @item y0
  5617. @item x1
  5618. @item y1
  5619. @item x2
  5620. @item y2
  5621. @item x3
  5622. @item y3
  5623. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  5624. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  5625. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  5626. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  5627. then the corners of the source will be sent to the specified coordinates.
  5628. The expressions can use the following variables:
  5629. @table @option
  5630. @item W
  5631. @item H
  5632. the width and height of video frame.
  5633. @end table
  5634. @item interpolation
  5635. Set interpolation for perspective correction.
  5636. It accepts the following values:
  5637. @table @samp
  5638. @item linear
  5639. @item cubic
  5640. @end table
  5641. Default value is @samp{linear}.
  5642. @item sense
  5643. Set interpretation of coordinate options.
  5644. It accepts the following values:
  5645. @table @samp
  5646. @item 0, source
  5647. Send point in the source specified by the given coordinates to
  5648. the corners of the destination.
  5649. @item 1, destination
  5650. Send the corners of the source to the point in the destination specified
  5651. by the given coordinates.
  5652. Default value is @samp{source}.
  5653. @end table
  5654. @end table
  5655. @section phase
  5656. Delay interlaced video by one field time so that the field order changes.
  5657. The intended use is to fix PAL movies that have been captured with the
  5658. opposite field order to the film-to-video transfer.
  5659. A description of the accepted parameters follows.
  5660. @table @option
  5661. @item mode
  5662. Set phase mode.
  5663. It accepts the following values:
  5664. @table @samp
  5665. @item t
  5666. Capture field order top-first, transfer bottom-first.
  5667. Filter will delay the bottom field.
  5668. @item b
  5669. Capture field order bottom-first, transfer top-first.
  5670. Filter will delay the top field.
  5671. @item p
  5672. Capture and transfer with the same field order. This mode only exists
  5673. for the documentation of the other options to refer to, but if you
  5674. actually select it, the filter will faithfully do nothing.
  5675. @item a
  5676. Capture field order determined automatically by field flags, transfer
  5677. opposite.
  5678. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  5679. basis using field flags. If no field information is available,
  5680. then this works just like @samp{u}.
  5681. @item u
  5682. Capture unknown or varying, transfer opposite.
  5683. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  5684. analyzing the images and selecting the alternative that produces best
  5685. match between the fields.
  5686. @item T
  5687. Capture top-first, transfer unknown or varying.
  5688. Filter selects among @samp{t} and @samp{p} using image analysis.
  5689. @item B
  5690. Capture bottom-first, transfer unknown or varying.
  5691. Filter selects among @samp{b} and @samp{p} using image analysis.
  5692. @item A
  5693. Capture determined by field flags, transfer unknown or varying.
  5694. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  5695. image analysis. If no field information is available, then this works just
  5696. like @samp{U}. This is the default mode.
  5697. @item U
  5698. Both capture and transfer unknown or varying.
  5699. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  5700. @end table
  5701. @end table
  5702. @section pixdesctest
  5703. Pixel format descriptor test filter, mainly useful for internal
  5704. testing. The output video should be equal to the input video.
  5705. For example:
  5706. @example
  5707. format=monow, pixdesctest
  5708. @end example
  5709. can be used to test the monowhite pixel format descriptor definition.
  5710. @section pp
  5711. Enable the specified chain of postprocessing subfilters using libpostproc. This
  5712. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  5713. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  5714. Each subfilter and some options have a short and a long name that can be used
  5715. interchangeably, i.e. dr/dering are the same.
  5716. The filters accept the following options:
  5717. @table @option
  5718. @item subfilters
  5719. Set postprocessing subfilters string.
  5720. @end table
  5721. All subfilters share common options to determine their scope:
  5722. @table @option
  5723. @item a/autoq
  5724. Honor the quality commands for this subfilter.
  5725. @item c/chrom
  5726. Do chrominance filtering, too (default).
  5727. @item y/nochrom
  5728. Do luminance filtering only (no chrominance).
  5729. @item n/noluma
  5730. Do chrominance filtering only (no luminance).
  5731. @end table
  5732. These options can be appended after the subfilter name, separated by a '|'.
  5733. Available subfilters are:
  5734. @table @option
  5735. @item hb/hdeblock[|difference[|flatness]]
  5736. Horizontal deblocking filter
  5737. @table @option
  5738. @item difference
  5739. Difference factor where higher values mean more deblocking (default: @code{32}).
  5740. @item flatness
  5741. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5742. @end table
  5743. @item vb/vdeblock[|difference[|flatness]]
  5744. Vertical deblocking filter
  5745. @table @option
  5746. @item difference
  5747. Difference factor where higher values mean more deblocking (default: @code{32}).
  5748. @item flatness
  5749. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5750. @end table
  5751. @item ha/hadeblock[|difference[|flatness]]
  5752. Accurate horizontal deblocking filter
  5753. @table @option
  5754. @item difference
  5755. Difference factor where higher values mean more deblocking (default: @code{32}).
  5756. @item flatness
  5757. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5758. @end table
  5759. @item va/vadeblock[|difference[|flatness]]
  5760. Accurate vertical deblocking filter
  5761. @table @option
  5762. @item difference
  5763. Difference factor where higher values mean more deblocking (default: @code{32}).
  5764. @item flatness
  5765. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5766. @end table
  5767. @end table
  5768. The horizontal and vertical deblocking filters share the difference and
  5769. flatness values so you cannot set different horizontal and vertical
  5770. thresholds.
  5771. @table @option
  5772. @item h1/x1hdeblock
  5773. Experimental horizontal deblocking filter
  5774. @item v1/x1vdeblock
  5775. Experimental vertical deblocking filter
  5776. @item dr/dering
  5777. Deringing filter
  5778. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  5779. @table @option
  5780. @item threshold1
  5781. larger -> stronger filtering
  5782. @item threshold2
  5783. larger -> stronger filtering
  5784. @item threshold3
  5785. larger -> stronger filtering
  5786. @end table
  5787. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  5788. @table @option
  5789. @item f/fullyrange
  5790. Stretch luminance to @code{0-255}.
  5791. @end table
  5792. @item lb/linblenddeint
  5793. Linear blend deinterlacing filter that deinterlaces the given block by
  5794. filtering all lines with a @code{(1 2 1)} filter.
  5795. @item li/linipoldeint
  5796. Linear interpolating deinterlacing filter that deinterlaces the given block by
  5797. linearly interpolating every second line.
  5798. @item ci/cubicipoldeint
  5799. Cubic interpolating deinterlacing filter deinterlaces the given block by
  5800. cubically interpolating every second line.
  5801. @item md/mediandeint
  5802. Median deinterlacing filter that deinterlaces the given block by applying a
  5803. median filter to every second line.
  5804. @item fd/ffmpegdeint
  5805. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  5806. second line with a @code{(-1 4 2 4 -1)} filter.
  5807. @item l5/lowpass5
  5808. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  5809. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  5810. @item fq/forceQuant[|quantizer]
  5811. Overrides the quantizer table from the input with the constant quantizer you
  5812. specify.
  5813. @table @option
  5814. @item quantizer
  5815. Quantizer to use
  5816. @end table
  5817. @item de/default
  5818. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  5819. @item fa/fast
  5820. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  5821. @item ac
  5822. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  5823. @end table
  5824. @subsection Examples
  5825. @itemize
  5826. @item
  5827. Apply horizontal and vertical deblocking, deringing and automatic
  5828. brightness/contrast:
  5829. @example
  5830. pp=hb/vb/dr/al
  5831. @end example
  5832. @item
  5833. Apply default filters without brightness/contrast correction:
  5834. @example
  5835. pp=de/-al
  5836. @end example
  5837. @item
  5838. Apply default filters and temporal denoiser:
  5839. @example
  5840. pp=default/tmpnoise|1|2|3
  5841. @end example
  5842. @item
  5843. Apply deblocking on luminance only, and switch vertical deblocking on or off
  5844. automatically depending on available CPU time:
  5845. @example
  5846. pp=hb|y/vb|a
  5847. @end example
  5848. @end itemize
  5849. @section pp7
  5850. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  5851. similar to spp = 6 with 7 point DCT, where only the center sample is
  5852. used after IDCT.
  5853. The filter accepts the following options:
  5854. @table @option
  5855. @item qp
  5856. Force a constant quantization parameter. It accepts an integer in range
  5857. 0 to 63. If not set, the filter will use the QP from the video stream
  5858. (if available).
  5859. @item mode
  5860. Set thresholding mode. Available modes are:
  5861. @table @samp
  5862. @item hard
  5863. Set hard thresholding.
  5864. @item soft
  5865. Set soft thresholding (better de-ringing effect, but likely blurrier).
  5866. @item medium
  5867. Set medium thresholding (good results, default).
  5868. @end table
  5869. @end table
  5870. @section psnr
  5871. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  5872. Ratio) between two input videos.
  5873. This filter takes in input two input videos, the first input is
  5874. considered the "main" source and is passed unchanged to the
  5875. output. The second input is used as a "reference" video for computing
  5876. the PSNR.
  5877. Both video inputs must have the same resolution and pixel format for
  5878. this filter to work correctly. Also it assumes that both inputs
  5879. have the same number of frames, which are compared one by one.
  5880. The obtained average PSNR is printed through the logging system.
  5881. The filter stores the accumulated MSE (mean squared error) of each
  5882. frame, and at the end of the processing it is averaged across all frames
  5883. equally, and the following formula is applied to obtain the PSNR:
  5884. @example
  5885. PSNR = 10*log10(MAX^2/MSE)
  5886. @end example
  5887. Where MAX is the average of the maximum values of each component of the
  5888. image.
  5889. The description of the accepted parameters follows.
  5890. @table @option
  5891. @item stats_file, f
  5892. If specified the filter will use the named file to save the PSNR of
  5893. each individual frame.
  5894. @end table
  5895. The file printed if @var{stats_file} is selected, contains a sequence of
  5896. key/value pairs of the form @var{key}:@var{value} for each compared
  5897. couple of frames.
  5898. A description of each shown parameter follows:
  5899. @table @option
  5900. @item n
  5901. sequential number of the input frame, starting from 1
  5902. @item mse_avg
  5903. Mean Square Error pixel-by-pixel average difference of the compared
  5904. frames, averaged over all the image components.
  5905. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  5906. Mean Square Error pixel-by-pixel average difference of the compared
  5907. frames for the component specified by the suffix.
  5908. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  5909. Peak Signal to Noise ratio of the compared frames for the component
  5910. specified by the suffix.
  5911. @end table
  5912. For example:
  5913. @example
  5914. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  5915. [main][ref] psnr="stats_file=stats.log" [out]
  5916. @end example
  5917. On this example the input file being processed is compared with the
  5918. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  5919. is stored in @file{stats.log}.
  5920. @anchor{pullup}
  5921. @section pullup
  5922. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  5923. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  5924. content.
  5925. The pullup filter is designed to take advantage of future context in making
  5926. its decisions. This filter is stateless in the sense that it does not lock
  5927. onto a pattern to follow, but it instead looks forward to the following
  5928. fields in order to identify matches and rebuild progressive frames.
  5929. To produce content with an even framerate, insert the fps filter after
  5930. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  5931. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  5932. The filter accepts the following options:
  5933. @table @option
  5934. @item jl
  5935. @item jr
  5936. @item jt
  5937. @item jb
  5938. These options set the amount of "junk" to ignore at the left, right, top, and
  5939. bottom of the image, respectively. Left and right are in units of 8 pixels,
  5940. while top and bottom are in units of 2 lines.
  5941. The default is 8 pixels on each side.
  5942. @item sb
  5943. Set the strict breaks. Setting this option to 1 will reduce the chances of
  5944. filter generating an occasional mismatched frame, but it may also cause an
  5945. excessive number of frames to be dropped during high motion sequences.
  5946. Conversely, setting it to -1 will make filter match fields more easily.
  5947. This may help processing of video where there is slight blurring between
  5948. the fields, but may also cause there to be interlaced frames in the output.
  5949. Default value is @code{0}.
  5950. @item mp
  5951. Set the metric plane to use. It accepts the following values:
  5952. @table @samp
  5953. @item l
  5954. Use luma plane.
  5955. @item u
  5956. Use chroma blue plane.
  5957. @item v
  5958. Use chroma red plane.
  5959. @end table
  5960. This option may be set to use chroma plane instead of the default luma plane
  5961. for doing filter's computations. This may improve accuracy on very clean
  5962. source material, but more likely will decrease accuracy, especially if there
  5963. is chroma noise (rainbow effect) or any grayscale video.
  5964. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  5965. load and make pullup usable in realtime on slow machines.
  5966. @end table
  5967. For best results (without duplicated frames in the output file) it is
  5968. necessary to change the output frame rate. For example, to inverse
  5969. telecine NTSC input:
  5970. @example
  5971. ffmpeg -i input -vf pullup -r 24000/1001 ...
  5972. @end example
  5973. @section qp
  5974. Change video quantization parameters (QP).
  5975. The filter accepts the following option:
  5976. @table @option
  5977. @item qp
  5978. Set expression for quantization parameter.
  5979. @end table
  5980. The expression is evaluated through the eval API and can contain, among others,
  5981. the following constants:
  5982. @table @var
  5983. @item known
  5984. 1 if index is not 129, 0 otherwise.
  5985. @item qp
  5986. Sequentional index starting from -129 to 128.
  5987. @end table
  5988. @subsection Examples
  5989. @itemize
  5990. @item
  5991. Some equation like:
  5992. @example
  5993. qp=2+2*sin(PI*qp)
  5994. @end example
  5995. @end itemize
  5996. @section removelogo
  5997. Suppress a TV station logo, using an image file to determine which
  5998. pixels comprise the logo. It works by filling in the pixels that
  5999. comprise the logo with neighboring pixels.
  6000. The filter accepts the following options:
  6001. @table @option
  6002. @item filename, f
  6003. Set the filter bitmap file, which can be any image format supported by
  6004. libavformat. The width and height of the image file must match those of the
  6005. video stream being processed.
  6006. @end table
  6007. Pixels in the provided bitmap image with a value of zero are not
  6008. considered part of the logo, non-zero pixels are considered part of
  6009. the logo. If you use white (255) for the logo and black (0) for the
  6010. rest, you will be safe. For making the filter bitmap, it is
  6011. recommended to take a screen capture of a black frame with the logo
  6012. visible, and then using a threshold filter followed by the erode
  6013. filter once or twice.
  6014. If needed, little splotches can be fixed manually. Remember that if
  6015. logo pixels are not covered, the filter quality will be much
  6016. reduced. Marking too many pixels as part of the logo does not hurt as
  6017. much, but it will increase the amount of blurring needed to cover over
  6018. the image and will destroy more information than necessary, and extra
  6019. pixels will slow things down on a large logo.
  6020. @section repeatfields
  6021. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6022. fields based on its value.
  6023. @section rotate
  6024. Rotate video by an arbitrary angle expressed in radians.
  6025. The filter accepts the following options:
  6026. A description of the optional parameters follows.
  6027. @table @option
  6028. @item angle, a
  6029. Set an expression for the angle by which to rotate the input video
  6030. clockwise, expressed as a number of radians. A negative value will
  6031. result in a counter-clockwise rotation. By default it is set to "0".
  6032. This expression is evaluated for each frame.
  6033. @item out_w, ow
  6034. Set the output width expression, default value is "iw".
  6035. This expression is evaluated just once during configuration.
  6036. @item out_h, oh
  6037. Set the output height expression, default value is "ih".
  6038. This expression is evaluated just once during configuration.
  6039. @item bilinear
  6040. Enable bilinear interpolation if set to 1, a value of 0 disables
  6041. it. Default value is 1.
  6042. @item fillcolor, c
  6043. Set the color used to fill the output area not covered by the rotated
  6044. image. For the general syntax of this option, check the "Color" section in the
  6045. ffmpeg-utils manual. If the special value "none" is selected then no
  6046. background is printed (useful for example if the background is never shown).
  6047. Default value is "black".
  6048. @end table
  6049. The expressions for the angle and the output size can contain the
  6050. following constants and functions:
  6051. @table @option
  6052. @item n
  6053. sequential number of the input frame, starting from 0. It is always NAN
  6054. before the first frame is filtered.
  6055. @item t
  6056. time in seconds of the input frame, it is set to 0 when the filter is
  6057. configured. It is always NAN before the first frame is filtered.
  6058. @item hsub
  6059. @item vsub
  6060. horizontal and vertical chroma subsample values. For example for the
  6061. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6062. @item in_w, iw
  6063. @item in_h, ih
  6064. the input video width and height
  6065. @item out_w, ow
  6066. @item out_h, oh
  6067. the output width and height, that is the size of the padded area as
  6068. specified by the @var{width} and @var{height} expressions
  6069. @item rotw(a)
  6070. @item roth(a)
  6071. the minimal width/height required for completely containing the input
  6072. video rotated by @var{a} radians.
  6073. These are only available when computing the @option{out_w} and
  6074. @option{out_h} expressions.
  6075. @end table
  6076. @subsection Examples
  6077. @itemize
  6078. @item
  6079. Rotate the input by PI/6 radians clockwise:
  6080. @example
  6081. rotate=PI/6
  6082. @end example
  6083. @item
  6084. Rotate the input by PI/6 radians counter-clockwise:
  6085. @example
  6086. rotate=-PI/6
  6087. @end example
  6088. @item
  6089. Rotate the input by 45 degrees clockwise:
  6090. @example
  6091. rotate=45*PI/180
  6092. @end example
  6093. @item
  6094. Apply a constant rotation with period T, starting from an angle of PI/3:
  6095. @example
  6096. rotate=PI/3+2*PI*t/T
  6097. @end example
  6098. @item
  6099. Make the input video rotation oscillating with a period of T
  6100. seconds and an amplitude of A radians:
  6101. @example
  6102. rotate=A*sin(2*PI/T*t)
  6103. @end example
  6104. @item
  6105. Rotate the video, output size is chosen so that the whole rotating
  6106. input video is always completely contained in the output:
  6107. @example
  6108. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6109. @end example
  6110. @item
  6111. Rotate the video, reduce the output size so that no background is ever
  6112. shown:
  6113. @example
  6114. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6115. @end example
  6116. @end itemize
  6117. @subsection Commands
  6118. The filter supports the following commands:
  6119. @table @option
  6120. @item a, angle
  6121. Set the angle expression.
  6122. The command accepts the same syntax of the corresponding option.
  6123. If the specified expression is not valid, it is kept at its current
  6124. value.
  6125. @end table
  6126. @section sab
  6127. Apply Shape Adaptive Blur.
  6128. The filter accepts the following options:
  6129. @table @option
  6130. @item luma_radius, lr
  6131. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6132. value is 1.0. A greater value will result in a more blurred image, and
  6133. in slower processing.
  6134. @item luma_pre_filter_radius, lpfr
  6135. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6136. value is 1.0.
  6137. @item luma_strength, ls
  6138. Set luma maximum difference between pixels to still be considered, must
  6139. be a value in the 0.1-100.0 range, default value is 1.0.
  6140. @item chroma_radius, cr
  6141. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6142. greater value will result in a more blurred image, and in slower
  6143. processing.
  6144. @item chroma_pre_filter_radius, cpfr
  6145. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6146. @item chroma_strength, cs
  6147. Set chroma maximum difference between pixels to still be considered,
  6148. must be a value in the 0.1-100.0 range.
  6149. @end table
  6150. Each chroma option value, if not explicitly specified, is set to the
  6151. corresponding luma option value.
  6152. @anchor{scale}
  6153. @section scale
  6154. Scale (resize) the input video, using the libswscale library.
  6155. The scale filter forces the output display aspect ratio to be the same
  6156. of the input, by changing the output sample aspect ratio.
  6157. If the input image format is different from the format requested by
  6158. the next filter, the scale filter will convert the input to the
  6159. requested format.
  6160. @subsection Options
  6161. The filter accepts the following options, or any of the options
  6162. supported by the libswscale scaler.
  6163. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6164. the complete list of scaler options.
  6165. @table @option
  6166. @item width, w
  6167. @item height, h
  6168. Set the output video dimension expression. Default value is the input
  6169. dimension.
  6170. If the value is 0, the input width is used for the output.
  6171. If one of the values is -1, the scale filter will use a value that
  6172. maintains the aspect ratio of the input image, calculated from the
  6173. other specified dimension. If both of them are -1, the input size is
  6174. used
  6175. If one of the values is -n with n > 1, the scale filter will also use a value
  6176. that maintains the aspect ratio of the input image, calculated from the other
  6177. specified dimension. After that it will, however, make sure that the calculated
  6178. dimension is divisible by n and adjust the value if necessary.
  6179. See below for the list of accepted constants for use in the dimension
  6180. expression.
  6181. @item interl
  6182. Set the interlacing mode. It accepts the following values:
  6183. @table @samp
  6184. @item 1
  6185. Force interlaced aware scaling.
  6186. @item 0
  6187. Do not apply interlaced scaling.
  6188. @item -1
  6189. Select interlaced aware scaling depending on whether the source frames
  6190. are flagged as interlaced or not.
  6191. @end table
  6192. Default value is @samp{0}.
  6193. @item flags
  6194. Set libswscale scaling flags. See
  6195. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6196. complete list of values. If not explicitly specified the filter applies
  6197. the default flags.
  6198. @item size, s
  6199. Set the video size. For the syntax of this option, check the
  6200. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6201. @item in_color_matrix
  6202. @item out_color_matrix
  6203. Set in/output YCbCr color space type.
  6204. This allows the autodetected value to be overridden as well as allows forcing
  6205. a specific value used for the output and encoder.
  6206. If not specified, the color space type depends on the pixel format.
  6207. Possible values:
  6208. @table @samp
  6209. @item auto
  6210. Choose automatically.
  6211. @item bt709
  6212. Format conforming to International Telecommunication Union (ITU)
  6213. Recommendation BT.709.
  6214. @item fcc
  6215. Set color space conforming to the United States Federal Communications
  6216. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  6217. @item bt601
  6218. Set color space conforming to:
  6219. @itemize
  6220. @item
  6221. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  6222. @item
  6223. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  6224. @item
  6225. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  6226. @end itemize
  6227. @item smpte240m
  6228. Set color space conforming to SMPTE ST 240:1999.
  6229. @end table
  6230. @item in_range
  6231. @item out_range
  6232. Set in/output YCbCr sample range.
  6233. This allows the autodetected value to be overridden as well as allows forcing
  6234. a specific value used for the output and encoder. If not specified, the
  6235. range depends on the pixel format. Possible values:
  6236. @table @samp
  6237. @item auto
  6238. Choose automatically.
  6239. @item jpeg/full/pc
  6240. Set full range (0-255 in case of 8-bit luma).
  6241. @item mpeg/tv
  6242. Set "MPEG" range (16-235 in case of 8-bit luma).
  6243. @end table
  6244. @item force_original_aspect_ratio
  6245. Enable decreasing or increasing output video width or height if necessary to
  6246. keep the original aspect ratio. Possible values:
  6247. @table @samp
  6248. @item disable
  6249. Scale the video as specified and disable this feature.
  6250. @item decrease
  6251. The output video dimensions will automatically be decreased if needed.
  6252. @item increase
  6253. The output video dimensions will automatically be increased if needed.
  6254. @end table
  6255. One useful instance of this option is that when you know a specific device's
  6256. maximum allowed resolution, you can use this to limit the output video to
  6257. that, while retaining the aspect ratio. For example, device A allows
  6258. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  6259. decrease) and specifying 1280x720 to the command line makes the output
  6260. 1280x533.
  6261. Please note that this is a different thing than specifying -1 for @option{w}
  6262. or @option{h}, you still need to specify the output resolution for this option
  6263. to work.
  6264. @end table
  6265. The values of the @option{w} and @option{h} options are expressions
  6266. containing the following constants:
  6267. @table @var
  6268. @item in_w
  6269. @item in_h
  6270. The input width and height
  6271. @item iw
  6272. @item ih
  6273. These are the same as @var{in_w} and @var{in_h}.
  6274. @item out_w
  6275. @item out_h
  6276. The output (scaled) width and height
  6277. @item ow
  6278. @item oh
  6279. These are the same as @var{out_w} and @var{out_h}
  6280. @item a
  6281. The same as @var{iw} / @var{ih}
  6282. @item sar
  6283. input sample aspect ratio
  6284. @item dar
  6285. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  6286. @item hsub
  6287. @item vsub
  6288. horizontal and vertical input chroma subsample values. For example for the
  6289. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6290. @item ohsub
  6291. @item ovsub
  6292. horizontal and vertical output chroma subsample values. For example for the
  6293. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6294. @end table
  6295. @subsection Examples
  6296. @itemize
  6297. @item
  6298. Scale the input video to a size of 200x100
  6299. @example
  6300. scale=w=200:h=100
  6301. @end example
  6302. This is equivalent to:
  6303. @example
  6304. scale=200:100
  6305. @end example
  6306. or:
  6307. @example
  6308. scale=200x100
  6309. @end example
  6310. @item
  6311. Specify a size abbreviation for the output size:
  6312. @example
  6313. scale=qcif
  6314. @end example
  6315. which can also be written as:
  6316. @example
  6317. scale=size=qcif
  6318. @end example
  6319. @item
  6320. Scale the input to 2x:
  6321. @example
  6322. scale=w=2*iw:h=2*ih
  6323. @end example
  6324. @item
  6325. The above is the same as:
  6326. @example
  6327. scale=2*in_w:2*in_h
  6328. @end example
  6329. @item
  6330. Scale the input to 2x with forced interlaced scaling:
  6331. @example
  6332. scale=2*iw:2*ih:interl=1
  6333. @end example
  6334. @item
  6335. Scale the input to half size:
  6336. @example
  6337. scale=w=iw/2:h=ih/2
  6338. @end example
  6339. @item
  6340. Increase the width, and set the height to the same size:
  6341. @example
  6342. scale=3/2*iw:ow
  6343. @end example
  6344. @item
  6345. Seek Greek harmony:
  6346. @example
  6347. scale=iw:1/PHI*iw
  6348. scale=ih*PHI:ih
  6349. @end example
  6350. @item
  6351. Increase the height, and set the width to 3/2 of the height:
  6352. @example
  6353. scale=w=3/2*oh:h=3/5*ih
  6354. @end example
  6355. @item
  6356. Increase the size, making the size a multiple of the chroma
  6357. subsample values:
  6358. @example
  6359. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  6360. @end example
  6361. @item
  6362. Increase the width to a maximum of 500 pixels,
  6363. keeping the same aspect ratio as the input:
  6364. @example
  6365. scale=w='min(500\, iw*3/2):h=-1'
  6366. @end example
  6367. @end itemize
  6368. @section separatefields
  6369. The @code{separatefields} takes a frame-based video input and splits
  6370. each frame into its components fields, producing a new half height clip
  6371. with twice the frame rate and twice the frame count.
  6372. This filter use field-dominance information in frame to decide which
  6373. of each pair of fields to place first in the output.
  6374. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  6375. @section setdar, setsar
  6376. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  6377. output video.
  6378. This is done by changing the specified Sample (aka Pixel) Aspect
  6379. Ratio, according to the following equation:
  6380. @example
  6381. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  6382. @end example
  6383. Keep in mind that the @code{setdar} filter does not modify the pixel
  6384. dimensions of the video frame. Also, the display aspect ratio set by
  6385. this filter may be changed by later filters in the filterchain,
  6386. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  6387. applied.
  6388. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  6389. the filter output video.
  6390. Note that as a consequence of the application of this filter, the
  6391. output display aspect ratio will change according to the equation
  6392. above.
  6393. Keep in mind that the sample aspect ratio set by the @code{setsar}
  6394. filter may be changed by later filters in the filterchain, e.g. if
  6395. another "setsar" or a "setdar" filter is applied.
  6396. It accepts the following parameters:
  6397. @table @option
  6398. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  6399. Set the aspect ratio used by the filter.
  6400. The parameter can be a floating point number string, an expression, or
  6401. a string of the form @var{num}:@var{den}, where @var{num} and
  6402. @var{den} are the numerator and denominator of the aspect ratio. If
  6403. the parameter is not specified, it is assumed the value "0".
  6404. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  6405. should be escaped.
  6406. @item max
  6407. Set the maximum integer value to use for expressing numerator and
  6408. denominator when reducing the expressed aspect ratio to a rational.
  6409. Default value is @code{100}.
  6410. @end table
  6411. The parameter @var{sar} is an expression containing
  6412. the following constants:
  6413. @table @option
  6414. @item E, PI, PHI
  6415. These are approximated values for the mathematical constants e
  6416. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  6417. @item w, h
  6418. The input width and height.
  6419. @item a
  6420. These are the same as @var{w} / @var{h}.
  6421. @item sar
  6422. The input sample aspect ratio.
  6423. @item dar
  6424. The input display aspect ratio. It is the same as
  6425. (@var{w} / @var{h}) * @var{sar}.
  6426. @item hsub, vsub
  6427. Horizontal and vertical chroma subsample values. For example, for the
  6428. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6429. @end table
  6430. @subsection Examples
  6431. @itemize
  6432. @item
  6433. To change the display aspect ratio to 16:9, specify one of the following:
  6434. @example
  6435. setdar=dar=1.77777
  6436. setdar=dar=16/9
  6437. setdar=dar=1.77777
  6438. @end example
  6439. @item
  6440. To change the sample aspect ratio to 10:11, specify:
  6441. @example
  6442. setsar=sar=10/11
  6443. @end example
  6444. @item
  6445. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  6446. 1000 in the aspect ratio reduction, use the command:
  6447. @example
  6448. setdar=ratio=16/9:max=1000
  6449. @end example
  6450. @end itemize
  6451. @anchor{setfield}
  6452. @section setfield
  6453. Force field for the output video frame.
  6454. The @code{setfield} filter marks the interlace type field for the
  6455. output frames. It does not change the input frame, but only sets the
  6456. corresponding property, which affects how the frame is treated by
  6457. following filters (e.g. @code{fieldorder} or @code{yadif}).
  6458. The filter accepts the following options:
  6459. @table @option
  6460. @item mode
  6461. Available values are:
  6462. @table @samp
  6463. @item auto
  6464. Keep the same field property.
  6465. @item bff
  6466. Mark the frame as bottom-field-first.
  6467. @item tff
  6468. Mark the frame as top-field-first.
  6469. @item prog
  6470. Mark the frame as progressive.
  6471. @end table
  6472. @end table
  6473. @section showinfo
  6474. Show a line containing various information for each input video frame.
  6475. The input video is not modified.
  6476. The shown line contains a sequence of key/value pairs of the form
  6477. @var{key}:@var{value}.
  6478. The following values are shown in the output:
  6479. @table @option
  6480. @item n
  6481. The (sequential) number of the input frame, starting from 0.
  6482. @item pts
  6483. The Presentation TimeStamp of the input frame, expressed as a number of
  6484. time base units. The time base unit depends on the filter input pad.
  6485. @item pts_time
  6486. The Presentation TimeStamp of the input frame, expressed as a number of
  6487. seconds.
  6488. @item pos
  6489. The position of the frame in the input stream, or -1 if this information is
  6490. unavailable and/or meaningless (for example in case of synthetic video).
  6491. @item fmt
  6492. The pixel format name.
  6493. @item sar
  6494. The sample aspect ratio of the input frame, expressed in the form
  6495. @var{num}/@var{den}.
  6496. @item s
  6497. The size of the input frame. For the syntax of this option, check the
  6498. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6499. @item i
  6500. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  6501. for bottom field first).
  6502. @item iskey
  6503. This is 1 if the frame is a key frame, 0 otherwise.
  6504. @item type
  6505. The picture type of the input frame ("I" for an I-frame, "P" for a
  6506. P-frame, "B" for a B-frame, or "?" for an unknown type).
  6507. Also refer to the documentation of the @code{AVPictureType} enum and of
  6508. the @code{av_get_picture_type_char} function defined in
  6509. @file{libavutil/avutil.h}.
  6510. @item checksum
  6511. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  6512. @item plane_checksum
  6513. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  6514. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  6515. @end table
  6516. @section showpalette
  6517. Displays the 256 colors palette of each frame. This filter is only relevant for
  6518. @var{pal8} pixel format frames.
  6519. It accepts the following option:
  6520. @table @option
  6521. @item s
  6522. Set the size of the box used to represent one palette color entry. Default is
  6523. @code{30} (for a @code{30x30} pixel box).
  6524. @end table
  6525. @section shuffleplanes
  6526. Reorder and/or duplicate video planes.
  6527. It accepts the following parameters:
  6528. @table @option
  6529. @item map0
  6530. The index of the input plane to be used as the first output plane.
  6531. @item map1
  6532. The index of the input plane to be used as the second output plane.
  6533. @item map2
  6534. The index of the input plane to be used as the third output plane.
  6535. @item map3
  6536. The index of the input plane to be used as the fourth output plane.
  6537. @end table
  6538. The first plane has the index 0. The default is to keep the input unchanged.
  6539. Swap the second and third planes of the input:
  6540. @example
  6541. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  6542. @end example
  6543. @section signalstats
  6544. Evaluate various visual metrics that assist in determining issues associated
  6545. with the digitization of analog video media.
  6546. By default the filter will log these metadata values:
  6547. @table @option
  6548. @item YMIN
  6549. Display the minimal Y value contained within the input frame. Expressed in
  6550. range of [0-255].
  6551. @item YLOW
  6552. Display the Y value at the 10% percentile within the input frame. Expressed in
  6553. range of [0-255].
  6554. @item YAVG
  6555. Display the average Y value within the input frame. Expressed in range of
  6556. [0-255].
  6557. @item YHIGH
  6558. Display the Y value at the 90% percentile within the input frame. Expressed in
  6559. range of [0-255].
  6560. @item YMAX
  6561. Display the maximum Y value contained within the input frame. Expressed in
  6562. range of [0-255].
  6563. @item UMIN
  6564. Display the minimal U value contained within the input frame. Expressed in
  6565. range of [0-255].
  6566. @item ULOW
  6567. Display the U value at the 10% percentile within the input frame. Expressed in
  6568. range of [0-255].
  6569. @item UAVG
  6570. Display the average U value within the input frame. Expressed in range of
  6571. [0-255].
  6572. @item UHIGH
  6573. Display the U value at the 90% percentile within the input frame. Expressed in
  6574. range of [0-255].
  6575. @item UMAX
  6576. Display the maximum U value contained within the input frame. Expressed in
  6577. range of [0-255].
  6578. @item VMIN
  6579. Display the minimal V value contained within the input frame. Expressed in
  6580. range of [0-255].
  6581. @item VLOW
  6582. Display the V value at the 10% percentile within the input frame. Expressed in
  6583. range of [0-255].
  6584. @item VAVG
  6585. Display the average V value within the input frame. Expressed in range of
  6586. [0-255].
  6587. @item VHIGH
  6588. Display the V value at the 90% percentile within the input frame. Expressed in
  6589. range of [0-255].
  6590. @item VMAX
  6591. Display the maximum V value contained within the input frame. Expressed in
  6592. range of [0-255].
  6593. @item SATMIN
  6594. Display the minimal saturation value contained within the input frame.
  6595. Expressed in range of [0-~181.02].
  6596. @item SATLOW
  6597. Display the saturation value at the 10% percentile within the input frame.
  6598. Expressed in range of [0-~181.02].
  6599. @item SATAVG
  6600. Display the average saturation value within the input frame. Expressed in range
  6601. of [0-~181.02].
  6602. @item SATHIGH
  6603. Display the saturation value at the 90% percentile within the input frame.
  6604. Expressed in range of [0-~181.02].
  6605. @item SATMAX
  6606. Display the maximum saturation value contained within the input frame.
  6607. Expressed in range of [0-~181.02].
  6608. @item HUEMED
  6609. Display the median value for hue within the input frame. Expressed in range of
  6610. [0-360].
  6611. @item HUEAVG
  6612. Display the average value for hue within the input frame. Expressed in range of
  6613. [0-360].
  6614. @item YDIF
  6615. Display the average of sample value difference between all values of the Y
  6616. plane in the current frame and corresponding values of the previous input frame.
  6617. Expressed in range of [0-255].
  6618. @item UDIF
  6619. Display the average of sample value difference between all values of the U
  6620. plane in the current frame and corresponding values of the previous input frame.
  6621. Expressed in range of [0-255].
  6622. @item VDIF
  6623. Display the average of sample value difference between all values of the V
  6624. plane in the current frame and corresponding values of the previous input frame.
  6625. Expressed in range of [0-255].
  6626. @end table
  6627. The filter accepts the following options:
  6628. @table @option
  6629. @item stat
  6630. @item out
  6631. @option{stat} specify an additional form of image analysis.
  6632. @option{out} output video with the specified type of pixel highlighted.
  6633. Both options accept the following values:
  6634. @table @samp
  6635. @item tout
  6636. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  6637. unlike the neighboring pixels of the same field. Examples of temporal outliers
  6638. include the results of video dropouts, head clogs, or tape tracking issues.
  6639. @item vrep
  6640. Identify @var{vertical line repetition}. Vertical line repetition includes
  6641. similar rows of pixels within a frame. In born-digital video vertical line
  6642. repetition is common, but this pattern is uncommon in video digitized from an
  6643. analog source. When it occurs in video that results from the digitization of an
  6644. analog source it can indicate concealment from a dropout compensator.
  6645. @item brng
  6646. Identify pixels that fall outside of legal broadcast range.
  6647. @end table
  6648. @item color, c
  6649. Set the highlight color for the @option{out} option. The default color is
  6650. yellow.
  6651. @end table
  6652. @subsection Examples
  6653. @itemize
  6654. @item
  6655. Output data of various video metrics:
  6656. @example
  6657. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  6658. @end example
  6659. @item
  6660. Output specific data about the minimum and maximum values of the Y plane per frame:
  6661. @example
  6662. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  6663. @end example
  6664. @item
  6665. Playback video while highlighting pixels that are outside of broadcast range in red.
  6666. @example
  6667. ffplay example.mov -vf signalstats="out=brng:color=red"
  6668. @end example
  6669. @item
  6670. Playback video with signalstats metadata drawn over the frame.
  6671. @example
  6672. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  6673. @end example
  6674. The contents of signalstat_drawtext.txt used in the command are:
  6675. @example
  6676. time %@{pts:hms@}
  6677. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  6678. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  6679. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  6680. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  6681. @end example
  6682. @end itemize
  6683. @anchor{smartblur}
  6684. @section smartblur
  6685. Blur the input video without impacting the outlines.
  6686. It accepts the following options:
  6687. @table @option
  6688. @item luma_radius, lr
  6689. Set the luma radius. The option value must be a float number in
  6690. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6691. used to blur the image (slower if larger). Default value is 1.0.
  6692. @item luma_strength, ls
  6693. Set the luma strength. The option value must be a float number
  6694. in the range [-1.0,1.0] that configures the blurring. A value included
  6695. in [0.0,1.0] will blur the image whereas a value included in
  6696. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6697. @item luma_threshold, lt
  6698. Set the luma threshold used as a coefficient to determine
  6699. whether a pixel should be blurred or not. The option value must be an
  6700. integer in the range [-30,30]. A value of 0 will filter all the image,
  6701. a value included in [0,30] will filter flat areas and a value included
  6702. in [-30,0] will filter edges. Default value is 0.
  6703. @item chroma_radius, cr
  6704. Set the chroma radius. The option value must be a float number in
  6705. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6706. used to blur the image (slower if larger). Default value is 1.0.
  6707. @item chroma_strength, cs
  6708. Set the chroma strength. The option value must be a float number
  6709. in the range [-1.0,1.0] that configures the blurring. A value included
  6710. in [0.0,1.0] will blur the image whereas a value included in
  6711. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6712. @item chroma_threshold, ct
  6713. Set the chroma threshold used as a coefficient to determine
  6714. whether a pixel should be blurred or not. The option value must be an
  6715. integer in the range [-30,30]. A value of 0 will filter all the image,
  6716. a value included in [0,30] will filter flat areas and a value included
  6717. in [-30,0] will filter edges. Default value is 0.
  6718. @end table
  6719. If a chroma option is not explicitly set, the corresponding luma value
  6720. is set.
  6721. @section stereo3d
  6722. Convert between different stereoscopic image formats.
  6723. The filters accept the following options:
  6724. @table @option
  6725. @item in
  6726. Set stereoscopic image format of input.
  6727. Available values for input image formats are:
  6728. @table @samp
  6729. @item sbsl
  6730. side by side parallel (left eye left, right eye right)
  6731. @item sbsr
  6732. side by side crosseye (right eye left, left eye right)
  6733. @item sbs2l
  6734. side by side parallel with half width resolution
  6735. (left eye left, right eye right)
  6736. @item sbs2r
  6737. side by side crosseye with half width resolution
  6738. (right eye left, left eye right)
  6739. @item abl
  6740. above-below (left eye above, right eye below)
  6741. @item abr
  6742. above-below (right eye above, left eye below)
  6743. @item ab2l
  6744. above-below with half height resolution
  6745. (left eye above, right eye below)
  6746. @item ab2r
  6747. above-below with half height resolution
  6748. (right eye above, left eye below)
  6749. @item al
  6750. alternating frames (left eye first, right eye second)
  6751. @item ar
  6752. alternating frames (right eye first, left eye second)
  6753. Default value is @samp{sbsl}.
  6754. @end table
  6755. @item out
  6756. Set stereoscopic image format of output.
  6757. Available values for output image formats are all the input formats as well as:
  6758. @table @samp
  6759. @item arbg
  6760. anaglyph red/blue gray
  6761. (red filter on left eye, blue filter on right eye)
  6762. @item argg
  6763. anaglyph red/green gray
  6764. (red filter on left eye, green filter on right eye)
  6765. @item arcg
  6766. anaglyph red/cyan gray
  6767. (red filter on left eye, cyan filter on right eye)
  6768. @item arch
  6769. anaglyph red/cyan half colored
  6770. (red filter on left eye, cyan filter on right eye)
  6771. @item arcc
  6772. anaglyph red/cyan color
  6773. (red filter on left eye, cyan filter on right eye)
  6774. @item arcd
  6775. anaglyph red/cyan color optimized with the least squares projection of dubois
  6776. (red filter on left eye, cyan filter on right eye)
  6777. @item agmg
  6778. anaglyph green/magenta gray
  6779. (green filter on left eye, magenta filter on right eye)
  6780. @item agmh
  6781. anaglyph green/magenta half colored
  6782. (green filter on left eye, magenta filter on right eye)
  6783. @item agmc
  6784. anaglyph green/magenta colored
  6785. (green filter on left eye, magenta filter on right eye)
  6786. @item agmd
  6787. anaglyph green/magenta color optimized with the least squares projection of dubois
  6788. (green filter on left eye, magenta filter on right eye)
  6789. @item aybg
  6790. anaglyph yellow/blue gray
  6791. (yellow filter on left eye, blue filter on right eye)
  6792. @item aybh
  6793. anaglyph yellow/blue half colored
  6794. (yellow filter on left eye, blue filter on right eye)
  6795. @item aybc
  6796. anaglyph yellow/blue colored
  6797. (yellow filter on left eye, blue filter on right eye)
  6798. @item aybd
  6799. anaglyph yellow/blue color optimized with the least squares projection of dubois
  6800. (yellow filter on left eye, blue filter on right eye)
  6801. @item irl
  6802. interleaved rows (left eye has top row, right eye starts on next row)
  6803. @item irr
  6804. interleaved rows (right eye has top row, left eye starts on next row)
  6805. @item ml
  6806. mono output (left eye only)
  6807. @item mr
  6808. mono output (right eye only)
  6809. @end table
  6810. Default value is @samp{arcd}.
  6811. @end table
  6812. @subsection Examples
  6813. @itemize
  6814. @item
  6815. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  6816. @example
  6817. stereo3d=sbsl:aybd
  6818. @end example
  6819. @item
  6820. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  6821. @example
  6822. stereo3d=abl:sbsr
  6823. @end example
  6824. @end itemize
  6825. @anchor{spp}
  6826. @section spp
  6827. Apply a simple postprocessing filter that compresses and decompresses the image
  6828. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  6829. and average the results.
  6830. The filter accepts the following options:
  6831. @table @option
  6832. @item quality
  6833. Set quality. This option defines the number of levels for averaging. It accepts
  6834. an integer in the range 0-6. If set to @code{0}, the filter will have no
  6835. effect. A value of @code{6} means the higher quality. For each increment of
  6836. that value the speed drops by a factor of approximately 2. Default value is
  6837. @code{3}.
  6838. @item qp
  6839. Force a constant quantization parameter. If not set, the filter will use the QP
  6840. from the video stream (if available).
  6841. @item mode
  6842. Set thresholding mode. Available modes are:
  6843. @table @samp
  6844. @item hard
  6845. Set hard thresholding (default).
  6846. @item soft
  6847. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6848. @end table
  6849. @item use_bframe_qp
  6850. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  6851. option may cause flicker since the B-Frames have often larger QP. Default is
  6852. @code{0} (not enabled).
  6853. @end table
  6854. @anchor{subtitles}
  6855. @section subtitles
  6856. Draw subtitles on top of input video using the libass library.
  6857. To enable compilation of this filter you need to configure FFmpeg with
  6858. @code{--enable-libass}. This filter also requires a build with libavcodec and
  6859. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  6860. Alpha) subtitles format.
  6861. The filter accepts the following options:
  6862. @table @option
  6863. @item filename, f
  6864. Set the filename of the subtitle file to read. It must be specified.
  6865. @item original_size
  6866. Specify the size of the original video, the video for which the ASS file
  6867. was composed. For the syntax of this option, check the
  6868. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6869. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  6870. correctly scale the fonts if the aspect ratio has been changed.
  6871. @item charenc
  6872. Set subtitles input character encoding. @code{subtitles} filter only. Only
  6873. useful if not UTF-8.
  6874. @item stream_index, si
  6875. Set subtitles stream index. @code{subtitles} filter only.
  6876. @item force_style
  6877. Override default style or script info parameters of the subtitles. It accepts a
  6878. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  6879. @end table
  6880. If the first key is not specified, it is assumed that the first value
  6881. specifies the @option{filename}.
  6882. For example, to render the file @file{sub.srt} on top of the input
  6883. video, use the command:
  6884. @example
  6885. subtitles=sub.srt
  6886. @end example
  6887. which is equivalent to:
  6888. @example
  6889. subtitles=filename=sub.srt
  6890. @end example
  6891. To render the default subtitles stream from file @file{video.mkv}, use:
  6892. @example
  6893. subtitles=video.mkv
  6894. @end example
  6895. To render the second subtitles stream from that file, use:
  6896. @example
  6897. subtitles=video.mkv:si=1
  6898. @end example
  6899. To make the subtitles stream from @file{sub.srt} appear in transparent green
  6900. @code{DejaVu Serif}, use:
  6901. @example
  6902. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  6903. @end example
  6904. @section super2xsai
  6905. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  6906. Interpolate) pixel art scaling algorithm.
  6907. Useful for enlarging pixel art images without reducing sharpness.
  6908. @section swapuv
  6909. Swap U & V plane.
  6910. @section telecine
  6911. Apply telecine process to the video.
  6912. This filter accepts the following options:
  6913. @table @option
  6914. @item first_field
  6915. @table @samp
  6916. @item top, t
  6917. top field first
  6918. @item bottom, b
  6919. bottom field first
  6920. The default value is @code{top}.
  6921. @end table
  6922. @item pattern
  6923. A string of numbers representing the pulldown pattern you wish to apply.
  6924. The default value is @code{23}.
  6925. @end table
  6926. @example
  6927. Some typical patterns:
  6928. NTSC output (30i):
  6929. 27.5p: 32222
  6930. 24p: 23 (classic)
  6931. 24p: 2332 (preferred)
  6932. 20p: 33
  6933. 18p: 334
  6934. 16p: 3444
  6935. PAL output (25i):
  6936. 27.5p: 12222
  6937. 24p: 222222222223 ("Euro pulldown")
  6938. 16.67p: 33
  6939. 16p: 33333334
  6940. @end example
  6941. @section thumbnail
  6942. Select the most representative frame in a given sequence of consecutive frames.
  6943. The filter accepts the following options:
  6944. @table @option
  6945. @item n
  6946. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  6947. will pick one of them, and then handle the next batch of @var{n} frames until
  6948. the end. Default is @code{100}.
  6949. @end table
  6950. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  6951. value will result in a higher memory usage, so a high value is not recommended.
  6952. @subsection Examples
  6953. @itemize
  6954. @item
  6955. Extract one picture each 50 frames:
  6956. @example
  6957. thumbnail=50
  6958. @end example
  6959. @item
  6960. Complete example of a thumbnail creation with @command{ffmpeg}:
  6961. @example
  6962. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  6963. @end example
  6964. @end itemize
  6965. @section tile
  6966. Tile several successive frames together.
  6967. The filter accepts the following options:
  6968. @table @option
  6969. @item layout
  6970. Set the grid size (i.e. the number of lines and columns). For the syntax of
  6971. this option, check the
  6972. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6973. @item nb_frames
  6974. Set the maximum number of frames to render in the given area. It must be less
  6975. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  6976. the area will be used.
  6977. @item margin
  6978. Set the outer border margin in pixels.
  6979. @item padding
  6980. Set the inner border thickness (i.e. the number of pixels between frames). For
  6981. more advanced padding options (such as having different values for the edges),
  6982. refer to the pad video filter.
  6983. @item color
  6984. Specify the color of the unused area. For the syntax of this option, check the
  6985. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  6986. is "black".
  6987. @end table
  6988. @subsection Examples
  6989. @itemize
  6990. @item
  6991. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  6992. @example
  6993. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  6994. @end example
  6995. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  6996. duplicating each output frame to accommodate the originally detected frame
  6997. rate.
  6998. @item
  6999. Display @code{5} pictures in an area of @code{3x2} frames,
  7000. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7001. mixed flat and named options:
  7002. @example
  7003. tile=3x2:nb_frames=5:padding=7:margin=2
  7004. @end example
  7005. @end itemize
  7006. @section tinterlace
  7007. Perform various types of temporal field interlacing.
  7008. Frames are counted starting from 1, so the first input frame is
  7009. considered odd.
  7010. The filter accepts the following options:
  7011. @table @option
  7012. @item mode
  7013. Specify the mode of the interlacing. This option can also be specified
  7014. as a value alone. See below for a list of values for this option.
  7015. Available values are:
  7016. @table @samp
  7017. @item merge, 0
  7018. Move odd frames into the upper field, even into the lower field,
  7019. generating a double height frame at half frame rate.
  7020. @example
  7021. ------> time
  7022. Input:
  7023. Frame 1 Frame 2 Frame 3 Frame 4
  7024. 11111 22222 33333 44444
  7025. 11111 22222 33333 44444
  7026. 11111 22222 33333 44444
  7027. 11111 22222 33333 44444
  7028. Output:
  7029. 11111 33333
  7030. 22222 44444
  7031. 11111 33333
  7032. 22222 44444
  7033. 11111 33333
  7034. 22222 44444
  7035. 11111 33333
  7036. 22222 44444
  7037. @end example
  7038. @item drop_odd, 1
  7039. Only output even frames, odd frames are dropped, generating a frame with
  7040. unchanged height at half frame rate.
  7041. @example
  7042. ------> time
  7043. Input:
  7044. Frame 1 Frame 2 Frame 3 Frame 4
  7045. 11111 22222 33333 44444
  7046. 11111 22222 33333 44444
  7047. 11111 22222 33333 44444
  7048. 11111 22222 33333 44444
  7049. Output:
  7050. 22222 44444
  7051. 22222 44444
  7052. 22222 44444
  7053. 22222 44444
  7054. @end example
  7055. @item drop_even, 2
  7056. Only output odd frames, even frames are dropped, generating a frame with
  7057. unchanged height at half frame rate.
  7058. @example
  7059. ------> time
  7060. Input:
  7061. Frame 1 Frame 2 Frame 3 Frame 4
  7062. 11111 22222 33333 44444
  7063. 11111 22222 33333 44444
  7064. 11111 22222 33333 44444
  7065. 11111 22222 33333 44444
  7066. Output:
  7067. 11111 33333
  7068. 11111 33333
  7069. 11111 33333
  7070. 11111 33333
  7071. @end example
  7072. @item pad, 3
  7073. Expand each frame to full height, but pad alternate lines with black,
  7074. generating a frame with double height at the same input frame rate.
  7075. @example
  7076. ------> time
  7077. Input:
  7078. Frame 1 Frame 2 Frame 3 Frame 4
  7079. 11111 22222 33333 44444
  7080. 11111 22222 33333 44444
  7081. 11111 22222 33333 44444
  7082. 11111 22222 33333 44444
  7083. Output:
  7084. 11111 ..... 33333 .....
  7085. ..... 22222 ..... 44444
  7086. 11111 ..... 33333 .....
  7087. ..... 22222 ..... 44444
  7088. 11111 ..... 33333 .....
  7089. ..... 22222 ..... 44444
  7090. 11111 ..... 33333 .....
  7091. ..... 22222 ..... 44444
  7092. @end example
  7093. @item interleave_top, 4
  7094. Interleave the upper field from odd frames with the lower field from
  7095. even frames, generating a frame with unchanged height at half frame rate.
  7096. @example
  7097. ------> time
  7098. Input:
  7099. Frame 1 Frame 2 Frame 3 Frame 4
  7100. 11111<- 22222 33333<- 44444
  7101. 11111 22222<- 33333 44444<-
  7102. 11111<- 22222 33333<- 44444
  7103. 11111 22222<- 33333 44444<-
  7104. Output:
  7105. 11111 33333
  7106. 22222 44444
  7107. 11111 33333
  7108. 22222 44444
  7109. @end example
  7110. @item interleave_bottom, 5
  7111. Interleave the lower field from odd frames with the upper field from
  7112. even frames, generating a frame with unchanged height at half frame rate.
  7113. @example
  7114. ------> time
  7115. Input:
  7116. Frame 1 Frame 2 Frame 3 Frame 4
  7117. 11111 22222<- 33333 44444<-
  7118. 11111<- 22222 33333<- 44444
  7119. 11111 22222<- 33333 44444<-
  7120. 11111<- 22222 33333<- 44444
  7121. Output:
  7122. 22222 44444
  7123. 11111 33333
  7124. 22222 44444
  7125. 11111 33333
  7126. @end example
  7127. @item interlacex2, 6
  7128. Double frame rate with unchanged height. Frames are inserted each
  7129. containing the second temporal field from the previous input frame and
  7130. the first temporal field from the next input frame. This mode relies on
  7131. the top_field_first flag. Useful for interlaced video displays with no
  7132. field synchronisation.
  7133. @example
  7134. ------> time
  7135. Input:
  7136. Frame 1 Frame 2 Frame 3 Frame 4
  7137. 11111 22222 33333 44444
  7138. 11111 22222 33333 44444
  7139. 11111 22222 33333 44444
  7140. 11111 22222 33333 44444
  7141. Output:
  7142. 11111 22222 22222 33333 33333 44444 44444
  7143. 11111 11111 22222 22222 33333 33333 44444
  7144. 11111 22222 22222 33333 33333 44444 44444
  7145. 11111 11111 22222 22222 33333 33333 44444
  7146. @end example
  7147. @end table
  7148. Numeric values are deprecated but are accepted for backward
  7149. compatibility reasons.
  7150. Default mode is @code{merge}.
  7151. @item flags
  7152. Specify flags influencing the filter process.
  7153. Available value for @var{flags} is:
  7154. @table @option
  7155. @item low_pass_filter, vlfp
  7156. Enable vertical low-pass filtering in the filter.
  7157. Vertical low-pass filtering is required when creating an interlaced
  7158. destination from a progressive source which contains high-frequency
  7159. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  7160. patterning.
  7161. Vertical low-pass filtering can only be enabled for @option{mode}
  7162. @var{interleave_top} and @var{interleave_bottom}.
  7163. @end table
  7164. @end table
  7165. @section transpose
  7166. Transpose rows with columns in the input video and optionally flip it.
  7167. It accepts the following parameters:
  7168. @table @option
  7169. @item dir
  7170. Specify the transposition direction.
  7171. Can assume the following values:
  7172. @table @samp
  7173. @item 0, 4, cclock_flip
  7174. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  7175. @example
  7176. L.R L.l
  7177. . . -> . .
  7178. l.r R.r
  7179. @end example
  7180. @item 1, 5, clock
  7181. Rotate by 90 degrees clockwise, that is:
  7182. @example
  7183. L.R l.L
  7184. . . -> . .
  7185. l.r r.R
  7186. @end example
  7187. @item 2, 6, cclock
  7188. Rotate by 90 degrees counterclockwise, that is:
  7189. @example
  7190. L.R R.r
  7191. . . -> . .
  7192. l.r L.l
  7193. @end example
  7194. @item 3, 7, clock_flip
  7195. Rotate by 90 degrees clockwise and vertically flip, that is:
  7196. @example
  7197. L.R r.R
  7198. . . -> . .
  7199. l.r l.L
  7200. @end example
  7201. @end table
  7202. For values between 4-7, the transposition is only done if the input
  7203. video geometry is portrait and not landscape. These values are
  7204. deprecated, the @code{passthrough} option should be used instead.
  7205. Numerical values are deprecated, and should be dropped in favor of
  7206. symbolic constants.
  7207. @item passthrough
  7208. Do not apply the transposition if the input geometry matches the one
  7209. specified by the specified value. It accepts the following values:
  7210. @table @samp
  7211. @item none
  7212. Always apply transposition.
  7213. @item portrait
  7214. Preserve portrait geometry (when @var{height} >= @var{width}).
  7215. @item landscape
  7216. Preserve landscape geometry (when @var{width} >= @var{height}).
  7217. @end table
  7218. Default value is @code{none}.
  7219. @end table
  7220. For example to rotate by 90 degrees clockwise and preserve portrait
  7221. layout:
  7222. @example
  7223. transpose=dir=1:passthrough=portrait
  7224. @end example
  7225. The command above can also be specified as:
  7226. @example
  7227. transpose=1:portrait
  7228. @end example
  7229. @section trim
  7230. Trim the input so that the output contains one continuous subpart of the input.
  7231. It accepts the following parameters:
  7232. @table @option
  7233. @item start
  7234. Specify the time of the start of the kept section, i.e. the frame with the
  7235. timestamp @var{start} will be the first frame in the output.
  7236. @item end
  7237. Specify the time of the first frame that will be dropped, i.e. the frame
  7238. immediately preceding the one with the timestamp @var{end} will be the last
  7239. frame in the output.
  7240. @item start_pts
  7241. This is the same as @var{start}, except this option sets the start timestamp
  7242. in timebase units instead of seconds.
  7243. @item end_pts
  7244. This is the same as @var{end}, except this option sets the end timestamp
  7245. in timebase units instead of seconds.
  7246. @item duration
  7247. The maximum duration of the output in seconds.
  7248. @item start_frame
  7249. The number of the first frame that should be passed to the output.
  7250. @item end_frame
  7251. The number of the first frame that should be dropped.
  7252. @end table
  7253. @option{start}, @option{end}, and @option{duration} are expressed as time
  7254. duration specifications; see
  7255. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  7256. for the accepted syntax.
  7257. Note that the first two sets of the start/end options and the @option{duration}
  7258. option look at the frame timestamp, while the _frame variants simply count the
  7259. frames that pass through the filter. Also note that this filter does not modify
  7260. the timestamps. If you wish for the output timestamps to start at zero, insert a
  7261. setpts filter after the trim filter.
  7262. If multiple start or end options are set, this filter tries to be greedy and
  7263. keep all the frames that match at least one of the specified constraints. To keep
  7264. only the part that matches all the constraints at once, chain multiple trim
  7265. filters.
  7266. The defaults are such that all the input is kept. So it is possible to set e.g.
  7267. just the end values to keep everything before the specified time.
  7268. Examples:
  7269. @itemize
  7270. @item
  7271. Drop everything except the second minute of input:
  7272. @example
  7273. ffmpeg -i INPUT -vf trim=60:120
  7274. @end example
  7275. @item
  7276. Keep only the first second:
  7277. @example
  7278. ffmpeg -i INPUT -vf trim=duration=1
  7279. @end example
  7280. @end itemize
  7281. @anchor{unsharp}
  7282. @section unsharp
  7283. Sharpen or blur the input video.
  7284. It accepts the following parameters:
  7285. @table @option
  7286. @item luma_msize_x, lx
  7287. Set the luma matrix horizontal size. It must be an odd integer between
  7288. 3 and 63. The default value is 5.
  7289. @item luma_msize_y, ly
  7290. Set the luma matrix vertical size. It must be an odd integer between 3
  7291. and 63. The default value is 5.
  7292. @item luma_amount, la
  7293. Set the luma effect strength. It must be a floating point number, reasonable
  7294. values lay between -1.5 and 1.5.
  7295. Negative values will blur the input video, while positive values will
  7296. sharpen it, a value of zero will disable the effect.
  7297. Default value is 1.0.
  7298. @item chroma_msize_x, cx
  7299. Set the chroma matrix horizontal size. It must be an odd integer
  7300. between 3 and 63. The default value is 5.
  7301. @item chroma_msize_y, cy
  7302. Set the chroma matrix vertical size. It must be an odd integer
  7303. between 3 and 63. The default value is 5.
  7304. @item chroma_amount, ca
  7305. Set the chroma effect strength. It must be a floating point number, reasonable
  7306. values lay between -1.5 and 1.5.
  7307. Negative values will blur the input video, while positive values will
  7308. sharpen it, a value of zero will disable the effect.
  7309. Default value is 0.0.
  7310. @item opencl
  7311. If set to 1, specify using OpenCL capabilities, only available if
  7312. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  7313. @end table
  7314. All parameters are optional and default to the equivalent of the
  7315. string '5:5:1.0:5:5:0.0'.
  7316. @subsection Examples
  7317. @itemize
  7318. @item
  7319. Apply strong luma sharpen effect:
  7320. @example
  7321. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  7322. @end example
  7323. @item
  7324. Apply a strong blur of both luma and chroma parameters:
  7325. @example
  7326. unsharp=7:7:-2:7:7:-2
  7327. @end example
  7328. @end itemize
  7329. @section uspp
  7330. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  7331. the image at several (or - in the case of @option{quality} level @code{8} - all)
  7332. shifts and average the results.
  7333. The way this differs from the behavior of spp is that uspp actually encodes &
  7334. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  7335. DCT similar to MJPEG.
  7336. The filter accepts the following options:
  7337. @table @option
  7338. @item quality
  7339. Set quality. This option defines the number of levels for averaging. It accepts
  7340. an integer in the range 0-8. If set to @code{0}, the filter will have no
  7341. effect. A value of @code{8} means the higher quality. For each increment of
  7342. that value the speed drops by a factor of approximately 2. Default value is
  7343. @code{3}.
  7344. @item qp
  7345. Force a constant quantization parameter. If not set, the filter will use the QP
  7346. from the video stream (if available).
  7347. @end table
  7348. @anchor{vidstabdetect}
  7349. @section vidstabdetect
  7350. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  7351. @ref{vidstabtransform} for pass 2.
  7352. This filter generates a file with relative translation and rotation
  7353. transform information about subsequent frames, which is then used by
  7354. the @ref{vidstabtransform} filter.
  7355. To enable compilation of this filter you need to configure FFmpeg with
  7356. @code{--enable-libvidstab}.
  7357. This filter accepts the following options:
  7358. @table @option
  7359. @item result
  7360. Set the path to the file used to write the transforms information.
  7361. Default value is @file{transforms.trf}.
  7362. @item shakiness
  7363. Set how shaky the video is and how quick the camera is. It accepts an
  7364. integer in the range 1-10, a value of 1 means little shakiness, a
  7365. value of 10 means strong shakiness. Default value is 5.
  7366. @item accuracy
  7367. Set the accuracy of the detection process. It must be a value in the
  7368. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  7369. accuracy. Default value is 15.
  7370. @item stepsize
  7371. Set stepsize of the search process. The region around minimum is
  7372. scanned with 1 pixel resolution. Default value is 6.
  7373. @item mincontrast
  7374. Set minimum contrast. Below this value a local measurement field is
  7375. discarded. Must be a floating point value in the range 0-1. Default
  7376. value is 0.3.
  7377. @item tripod
  7378. Set reference frame number for tripod mode.
  7379. If enabled, the motion of the frames is compared to a reference frame
  7380. in the filtered stream, identified by the specified number. The idea
  7381. is to compensate all movements in a more-or-less static scene and keep
  7382. the camera view absolutely still.
  7383. If set to 0, it is disabled. The frames are counted starting from 1.
  7384. @item show
  7385. Show fields and transforms in the resulting frames. It accepts an
  7386. integer in the range 0-2. Default value is 0, which disables any
  7387. visualization.
  7388. @end table
  7389. @subsection Examples
  7390. @itemize
  7391. @item
  7392. Use default values:
  7393. @example
  7394. vidstabdetect
  7395. @end example
  7396. @item
  7397. Analyze strongly shaky movie and put the results in file
  7398. @file{mytransforms.trf}:
  7399. @example
  7400. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  7401. @end example
  7402. @item
  7403. Visualize the result of internal transformations in the resulting
  7404. video:
  7405. @example
  7406. vidstabdetect=show=1
  7407. @end example
  7408. @item
  7409. Analyze a video with medium shakiness using @command{ffmpeg}:
  7410. @example
  7411. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  7412. @end example
  7413. @end itemize
  7414. @anchor{vidstabtransform}
  7415. @section vidstabtransform
  7416. Video stabilization/deshaking: pass 2 of 2,
  7417. see @ref{vidstabdetect} for pass 1.
  7418. Read a file with transform information for each frame and
  7419. apply/compensate them. Together with the @ref{vidstabdetect}
  7420. filter this can be used to deshake videos. See also
  7421. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  7422. the @ref{unsharp} filter, see below.
  7423. To enable compilation of this filter you need to configure FFmpeg with
  7424. @code{--enable-libvidstab}.
  7425. @subsection Options
  7426. @table @option
  7427. @item input
  7428. Set path to the file used to read the transforms. Default value is
  7429. @file{transforms.trf}.
  7430. @item smoothing
  7431. Set the number of frames (value*2 + 1) used for lowpass filtering the
  7432. camera movements. Default value is 10.
  7433. For example a number of 10 means that 21 frames are used (10 in the
  7434. past and 10 in the future) to smoothen the motion in the video. A
  7435. larger value leads to a smoother video, but limits the acceleration of
  7436. the camera (pan/tilt movements). 0 is a special case where a static
  7437. camera is simulated.
  7438. @item optalgo
  7439. Set the camera path optimization algorithm.
  7440. Accepted values are:
  7441. @table @samp
  7442. @item gauss
  7443. gaussian kernel low-pass filter on camera motion (default)
  7444. @item avg
  7445. averaging on transformations
  7446. @end table
  7447. @item maxshift
  7448. Set maximal number of pixels to translate frames. Default value is -1,
  7449. meaning no limit.
  7450. @item maxangle
  7451. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  7452. value is -1, meaning no limit.
  7453. @item crop
  7454. Specify how to deal with borders that may be visible due to movement
  7455. compensation.
  7456. Available values are:
  7457. @table @samp
  7458. @item keep
  7459. keep image information from previous frame (default)
  7460. @item black
  7461. fill the border black
  7462. @end table
  7463. @item invert
  7464. Invert transforms if set to 1. Default value is 0.
  7465. @item relative
  7466. Consider transforms as relative to previous frame if set to 1,
  7467. absolute if set to 0. Default value is 0.
  7468. @item zoom
  7469. Set percentage to zoom. A positive value will result in a zoom-in
  7470. effect, a negative value in a zoom-out effect. Default value is 0 (no
  7471. zoom).
  7472. @item optzoom
  7473. Set optimal zooming to avoid borders.
  7474. Accepted values are:
  7475. @table @samp
  7476. @item 0
  7477. disabled
  7478. @item 1
  7479. optimal static zoom value is determined (only very strong movements
  7480. will lead to visible borders) (default)
  7481. @item 2
  7482. optimal adaptive zoom value is determined (no borders will be
  7483. visible), see @option{zoomspeed}
  7484. @end table
  7485. Note that the value given at zoom is added to the one calculated here.
  7486. @item zoomspeed
  7487. Set percent to zoom maximally each frame (enabled when
  7488. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  7489. 0.25.
  7490. @item interpol
  7491. Specify type of interpolation.
  7492. Available values are:
  7493. @table @samp
  7494. @item no
  7495. no interpolation
  7496. @item linear
  7497. linear only horizontal
  7498. @item bilinear
  7499. linear in both directions (default)
  7500. @item bicubic
  7501. cubic in both directions (slow)
  7502. @end table
  7503. @item tripod
  7504. Enable virtual tripod mode if set to 1, which is equivalent to
  7505. @code{relative=0:smoothing=0}. Default value is 0.
  7506. Use also @code{tripod} option of @ref{vidstabdetect}.
  7507. @item debug
  7508. Increase log verbosity if set to 1. Also the detected global motions
  7509. are written to the temporary file @file{global_motions.trf}. Default
  7510. value is 0.
  7511. @end table
  7512. @subsection Examples
  7513. @itemize
  7514. @item
  7515. Use @command{ffmpeg} for a typical stabilization with default values:
  7516. @example
  7517. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  7518. @end example
  7519. Note the use of the @ref{unsharp} filter which is always recommended.
  7520. @item
  7521. Zoom in a bit more and load transform data from a given file:
  7522. @example
  7523. vidstabtransform=zoom=5:input="mytransforms.trf"
  7524. @end example
  7525. @item
  7526. Smoothen the video even more:
  7527. @example
  7528. vidstabtransform=smoothing=30
  7529. @end example
  7530. @end itemize
  7531. @section vflip
  7532. Flip the input video vertically.
  7533. For example, to vertically flip a video with @command{ffmpeg}:
  7534. @example
  7535. ffmpeg -i in.avi -vf "vflip" out.avi
  7536. @end example
  7537. @anchor{vignette}
  7538. @section vignette
  7539. Make or reverse a natural vignetting effect.
  7540. The filter accepts the following options:
  7541. @table @option
  7542. @item angle, a
  7543. Set lens angle expression as a number of radians.
  7544. The value is clipped in the @code{[0,PI/2]} range.
  7545. Default value: @code{"PI/5"}
  7546. @item x0
  7547. @item y0
  7548. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  7549. by default.
  7550. @item mode
  7551. Set forward/backward mode.
  7552. Available modes are:
  7553. @table @samp
  7554. @item forward
  7555. The larger the distance from the central point, the darker the image becomes.
  7556. @item backward
  7557. The larger the distance from the central point, the brighter the image becomes.
  7558. This can be used to reverse a vignette effect, though there is no automatic
  7559. detection to extract the lens @option{angle} and other settings (yet). It can
  7560. also be used to create a burning effect.
  7561. @end table
  7562. Default value is @samp{forward}.
  7563. @item eval
  7564. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  7565. It accepts the following values:
  7566. @table @samp
  7567. @item init
  7568. Evaluate expressions only once during the filter initialization.
  7569. @item frame
  7570. Evaluate expressions for each incoming frame. This is way slower than the
  7571. @samp{init} mode since it requires all the scalers to be re-computed, but it
  7572. allows advanced dynamic expressions.
  7573. @end table
  7574. Default value is @samp{init}.
  7575. @item dither
  7576. Set dithering to reduce the circular banding effects. Default is @code{1}
  7577. (enabled).
  7578. @item aspect
  7579. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  7580. Setting this value to the SAR of the input will make a rectangular vignetting
  7581. following the dimensions of the video.
  7582. Default is @code{1/1}.
  7583. @end table
  7584. @subsection Expressions
  7585. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  7586. following parameters.
  7587. @table @option
  7588. @item w
  7589. @item h
  7590. input width and height
  7591. @item n
  7592. the number of input frame, starting from 0
  7593. @item pts
  7594. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  7595. @var{TB} units, NAN if undefined
  7596. @item r
  7597. frame rate of the input video, NAN if the input frame rate is unknown
  7598. @item t
  7599. the PTS (Presentation TimeStamp) of the filtered video frame,
  7600. expressed in seconds, NAN if undefined
  7601. @item tb
  7602. time base of the input video
  7603. @end table
  7604. @subsection Examples
  7605. @itemize
  7606. @item
  7607. Apply simple strong vignetting effect:
  7608. @example
  7609. vignette=PI/4
  7610. @end example
  7611. @item
  7612. Make a flickering vignetting:
  7613. @example
  7614. vignette='PI/4+random(1)*PI/50':eval=frame
  7615. @end example
  7616. @end itemize
  7617. @section w3fdif
  7618. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  7619. Deinterlacing Filter").
  7620. Based on the process described by Martin Weston for BBC R&D, and
  7621. implemented based on the de-interlace algorithm written by Jim
  7622. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  7623. uses filter coefficients calculated by BBC R&D.
  7624. There are two sets of filter coefficients, so called "simple":
  7625. and "complex". Which set of filter coefficients is used can
  7626. be set by passing an optional parameter:
  7627. @table @option
  7628. @item filter
  7629. Set the interlacing filter coefficients. Accepts one of the following values:
  7630. @table @samp
  7631. @item simple
  7632. Simple filter coefficient set.
  7633. @item complex
  7634. More-complex filter coefficient set.
  7635. @end table
  7636. Default value is @samp{complex}.
  7637. @item deint
  7638. Specify which frames to deinterlace. Accept one of the following values:
  7639. @table @samp
  7640. @item all
  7641. Deinterlace all frames,
  7642. @item interlaced
  7643. Only deinterlace frames marked as interlaced.
  7644. @end table
  7645. Default value is @samp{all}.
  7646. @end table
  7647. @section xbr
  7648. Apply the xBR high-quality magnification filter which is designed for pixel
  7649. art. It follows a set of edge-detection rules, see
  7650. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  7651. It accepts the following option:
  7652. @table @option
  7653. @item n
  7654. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  7655. @code{3xBR} and @code{4} for @code{4xBR}.
  7656. Default is @code{3}.
  7657. @end table
  7658. @anchor{yadif}
  7659. @section yadif
  7660. Deinterlace the input video ("yadif" means "yet another deinterlacing
  7661. filter").
  7662. It accepts the following parameters:
  7663. @table @option
  7664. @item mode
  7665. The interlacing mode to adopt. It accepts one of the following values:
  7666. @table @option
  7667. @item 0, send_frame
  7668. Output one frame for each frame.
  7669. @item 1, send_field
  7670. Output one frame for each field.
  7671. @item 2, send_frame_nospatial
  7672. Like @code{send_frame}, but it skips the spatial interlacing check.
  7673. @item 3, send_field_nospatial
  7674. Like @code{send_field}, but it skips the spatial interlacing check.
  7675. @end table
  7676. The default value is @code{send_frame}.
  7677. @item parity
  7678. The picture field parity assumed for the input interlaced video. It accepts one
  7679. of the following values:
  7680. @table @option
  7681. @item 0, tff
  7682. Assume the top field is first.
  7683. @item 1, bff
  7684. Assume the bottom field is first.
  7685. @item -1, auto
  7686. Enable automatic detection of field parity.
  7687. @end table
  7688. The default value is @code{auto}.
  7689. If the interlacing is unknown or the decoder does not export this information,
  7690. top field first will be assumed.
  7691. @item deint
  7692. Specify which frames to deinterlace. Accept one of the following
  7693. values:
  7694. @table @option
  7695. @item 0, all
  7696. Deinterlace all frames.
  7697. @item 1, interlaced
  7698. Only deinterlace frames marked as interlaced.
  7699. @end table
  7700. The default value is @code{all}.
  7701. @end table
  7702. @section zoompan
  7703. Apply Zoom & Pan effect.
  7704. This filter accepts the following options:
  7705. @table @option
  7706. @item zoom, z
  7707. Set the zoom expression. Default is 1.
  7708. @item x
  7709. @item y
  7710. Set the x and y expression. Default is 0.
  7711. @item d
  7712. Set the duration expression in number of frames.
  7713. This sets for how many number of frames effect will last for
  7714. single input image.
  7715. @item s
  7716. Set the output image size, default is 'hd720'.
  7717. @end table
  7718. Each expression can contain the following constants:
  7719. @table @option
  7720. @item in_w, iw
  7721. Input width.
  7722. @item in_h, ih
  7723. Input height.
  7724. @item out_w, ow
  7725. Output width.
  7726. @item out_h, oh
  7727. Output height.
  7728. @item in
  7729. Input frame count.
  7730. @item on
  7731. Output frame count.
  7732. @item x
  7733. @item y
  7734. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  7735. for current input frame.
  7736. @item px
  7737. @item py
  7738. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  7739. not yet such frame (first input frame).
  7740. @item zoom
  7741. Last calculated zoom from 'z' expression for current input frame.
  7742. @item pzoom
  7743. Last calculated zoom of last output frame of previous input frame.
  7744. @item duration
  7745. Number of output frames for current input frame. Calculated from 'd' expression
  7746. for each input frame.
  7747. @item pduration
  7748. number of output frames created for previous input frame
  7749. @item a
  7750. Rational number: input width / input height
  7751. @item sar
  7752. sample aspect ratio
  7753. @item dar
  7754. display aspect ratio
  7755. @end table
  7756. @subsection Examples
  7757. @itemize
  7758. @item
  7759. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  7760. @example
  7761. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360
  7762. @end example
  7763. @end itemize
  7764. @c man end VIDEO FILTERS
  7765. @chapter Video Sources
  7766. @c man begin VIDEO SOURCES
  7767. Below is a description of the currently available video sources.
  7768. @section buffer
  7769. Buffer video frames, and make them available to the filter chain.
  7770. This source is mainly intended for a programmatic use, in particular
  7771. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  7772. It accepts the following parameters:
  7773. @table @option
  7774. @item video_size
  7775. Specify the size (width and height) of the buffered video frames. For the
  7776. syntax of this option, check the
  7777. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7778. @item width
  7779. The input video width.
  7780. @item height
  7781. The input video height.
  7782. @item pix_fmt
  7783. A string representing the pixel format of the buffered video frames.
  7784. It may be a number corresponding to a pixel format, or a pixel format
  7785. name.
  7786. @item time_base
  7787. Specify the timebase assumed by the timestamps of the buffered frames.
  7788. @item frame_rate
  7789. Specify the frame rate expected for the video stream.
  7790. @item pixel_aspect, sar
  7791. The sample (pixel) aspect ratio of the input video.
  7792. @item sws_param
  7793. Specify the optional parameters to be used for the scale filter which
  7794. is automatically inserted when an input change is detected in the
  7795. input size or format.
  7796. @end table
  7797. For example:
  7798. @example
  7799. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  7800. @end example
  7801. will instruct the source to accept video frames with size 320x240 and
  7802. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  7803. square pixels (1:1 sample aspect ratio).
  7804. Since the pixel format with name "yuv410p" corresponds to the number 6
  7805. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  7806. this example corresponds to:
  7807. @example
  7808. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  7809. @end example
  7810. Alternatively, the options can be specified as a flat string, but this
  7811. syntax is deprecated:
  7812. @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}]
  7813. @section cellauto
  7814. Create a pattern generated by an elementary cellular automaton.
  7815. The initial state of the cellular automaton can be defined through the
  7816. @option{filename}, and @option{pattern} options. If such options are
  7817. not specified an initial state is created randomly.
  7818. At each new frame a new row in the video is filled with the result of
  7819. the cellular automaton next generation. The behavior when the whole
  7820. frame is filled is defined by the @option{scroll} option.
  7821. This source accepts the following options:
  7822. @table @option
  7823. @item filename, f
  7824. Read the initial cellular automaton state, i.e. the starting row, from
  7825. the specified file.
  7826. In the file, each non-whitespace character is considered an alive
  7827. cell, a newline will terminate the row, and further characters in the
  7828. file will be ignored.
  7829. @item pattern, p
  7830. Read the initial cellular automaton state, i.e. the starting row, from
  7831. the specified string.
  7832. Each non-whitespace character in the string is considered an alive
  7833. cell, a newline will terminate the row, and further characters in the
  7834. string will be ignored.
  7835. @item rate, r
  7836. Set the video rate, that is the number of frames generated per second.
  7837. Default is 25.
  7838. @item random_fill_ratio, ratio
  7839. Set the random fill ratio for the initial cellular automaton row. It
  7840. is a floating point number value ranging from 0 to 1, defaults to
  7841. 1/PHI.
  7842. This option is ignored when a file or a pattern is specified.
  7843. @item random_seed, seed
  7844. Set the seed for filling randomly the initial row, must be an integer
  7845. included between 0 and UINT32_MAX. If not specified, or if explicitly
  7846. set to -1, the filter will try to use a good random seed on a best
  7847. effort basis.
  7848. @item rule
  7849. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  7850. Default value is 110.
  7851. @item size, s
  7852. Set the size of the output video. For the syntax of this option, check the
  7853. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7854. If @option{filename} or @option{pattern} is specified, the size is set
  7855. by default to the width of the specified initial state row, and the
  7856. height is set to @var{width} * PHI.
  7857. If @option{size} is set, it must contain the width of the specified
  7858. pattern string, and the specified pattern will be centered in the
  7859. larger row.
  7860. If a filename or a pattern string is not specified, the size value
  7861. defaults to "320x518" (used for a randomly generated initial state).
  7862. @item scroll
  7863. If set to 1, scroll the output upward when all the rows in the output
  7864. have been already filled. If set to 0, the new generated row will be
  7865. written over the top row just after the bottom row is filled.
  7866. Defaults to 1.
  7867. @item start_full, full
  7868. If set to 1, completely fill the output with generated rows before
  7869. outputting the first frame.
  7870. This is the default behavior, for disabling set the value to 0.
  7871. @item stitch
  7872. If set to 1, stitch the left and right row edges together.
  7873. This is the default behavior, for disabling set the value to 0.
  7874. @end table
  7875. @subsection Examples
  7876. @itemize
  7877. @item
  7878. Read the initial state from @file{pattern}, and specify an output of
  7879. size 200x400.
  7880. @example
  7881. cellauto=f=pattern:s=200x400
  7882. @end example
  7883. @item
  7884. Generate a random initial row with a width of 200 cells, with a fill
  7885. ratio of 2/3:
  7886. @example
  7887. cellauto=ratio=2/3:s=200x200
  7888. @end example
  7889. @item
  7890. Create a pattern generated by rule 18 starting by a single alive cell
  7891. centered on an initial row with width 100:
  7892. @example
  7893. cellauto=p=@@:s=100x400:full=0:rule=18
  7894. @end example
  7895. @item
  7896. Specify a more elaborated initial pattern:
  7897. @example
  7898. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  7899. @end example
  7900. @end itemize
  7901. @section mandelbrot
  7902. Generate a Mandelbrot set fractal, and progressively zoom towards the
  7903. point specified with @var{start_x} and @var{start_y}.
  7904. This source accepts the following options:
  7905. @table @option
  7906. @item end_pts
  7907. Set the terminal pts value. Default value is 400.
  7908. @item end_scale
  7909. Set the terminal scale value.
  7910. Must be a floating point value. Default value is 0.3.
  7911. @item inner
  7912. Set the inner coloring mode, that is the algorithm used to draw the
  7913. Mandelbrot fractal internal region.
  7914. It shall assume one of the following values:
  7915. @table @option
  7916. @item black
  7917. Set black mode.
  7918. @item convergence
  7919. Show time until convergence.
  7920. @item mincol
  7921. Set color based on point closest to the origin of the iterations.
  7922. @item period
  7923. Set period mode.
  7924. @end table
  7925. Default value is @var{mincol}.
  7926. @item bailout
  7927. Set the bailout value. Default value is 10.0.
  7928. @item maxiter
  7929. Set the maximum of iterations performed by the rendering
  7930. algorithm. Default value is 7189.
  7931. @item outer
  7932. Set outer coloring mode.
  7933. It shall assume one of following values:
  7934. @table @option
  7935. @item iteration_count
  7936. Set iteration cound mode.
  7937. @item normalized_iteration_count
  7938. set normalized iteration count mode.
  7939. @end table
  7940. Default value is @var{normalized_iteration_count}.
  7941. @item rate, r
  7942. Set frame rate, expressed as number of frames per second. Default
  7943. value is "25".
  7944. @item size, s
  7945. Set frame size. For the syntax of this option, check the "Video
  7946. size" section in the ffmpeg-utils manual. Default value is "640x480".
  7947. @item start_scale
  7948. Set the initial scale value. Default value is 3.0.
  7949. @item start_x
  7950. Set the initial x position. Must be a floating point value between
  7951. -100 and 100. Default value is -0.743643887037158704752191506114774.
  7952. @item start_y
  7953. Set the initial y position. Must be a floating point value between
  7954. -100 and 100. Default value is -0.131825904205311970493132056385139.
  7955. @end table
  7956. @section mptestsrc
  7957. Generate various test patterns, as generated by the MPlayer test filter.
  7958. The size of the generated video is fixed, and is 256x256.
  7959. This source is useful in particular for testing encoding features.
  7960. This source accepts the following options:
  7961. @table @option
  7962. @item rate, r
  7963. Specify the frame rate of the sourced video, as the number of frames
  7964. generated per second. It has to be a string in the format
  7965. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  7966. number or a valid video frame rate abbreviation. The default value is
  7967. "25".
  7968. @item duration, d
  7969. Set the duration of the sourced video. See
  7970. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  7971. for the accepted syntax.
  7972. If not specified, or the expressed duration is negative, the video is
  7973. supposed to be generated forever.
  7974. @item test, t
  7975. Set the number or the name of the test to perform. Supported tests are:
  7976. @table @option
  7977. @item dc_luma
  7978. @item dc_chroma
  7979. @item freq_luma
  7980. @item freq_chroma
  7981. @item amp_luma
  7982. @item amp_chroma
  7983. @item cbp
  7984. @item mv
  7985. @item ring1
  7986. @item ring2
  7987. @item all
  7988. @end table
  7989. Default value is "all", which will cycle through the list of all tests.
  7990. @end table
  7991. Some examples:
  7992. @example
  7993. mptestsrc=t=dc_luma
  7994. @end example
  7995. will generate a "dc_luma" test pattern.
  7996. @section frei0r_src
  7997. Provide a frei0r source.
  7998. To enable compilation of this filter you need to install the frei0r
  7999. header and configure FFmpeg with @code{--enable-frei0r}.
  8000. This source accepts the following parameters:
  8001. @table @option
  8002. @item size
  8003. The size of the video to generate. For the syntax of this option, check the
  8004. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8005. @item framerate
  8006. The framerate of the generated video. It may be a string of the form
  8007. @var{num}/@var{den} or a frame rate abbreviation.
  8008. @item filter_name
  8009. The name to the frei0r source to load. For more information regarding frei0r and
  8010. how to set the parameters, read the @ref{frei0r} section in the video filters
  8011. documentation.
  8012. @item filter_params
  8013. A '|'-separated list of parameters to pass to the frei0r source.
  8014. @end table
  8015. For example, to generate a frei0r partik0l source with size 200x200
  8016. and frame rate 10 which is overlaid on the overlay filter main input:
  8017. @example
  8018. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  8019. @end example
  8020. @section life
  8021. Generate a life pattern.
  8022. This source is based on a generalization of John Conway's life game.
  8023. The sourced input represents a life grid, each pixel represents a cell
  8024. which can be in one of two possible states, alive or dead. Every cell
  8025. interacts with its eight neighbours, which are the cells that are
  8026. horizontally, vertically, or diagonally adjacent.
  8027. At each interaction the grid evolves according to the adopted rule,
  8028. which specifies the number of neighbor alive cells which will make a
  8029. cell stay alive or born. The @option{rule} option allows one to specify
  8030. the rule to adopt.
  8031. This source accepts the following options:
  8032. @table @option
  8033. @item filename, f
  8034. Set the file from which to read the initial grid state. In the file,
  8035. each non-whitespace character is considered an alive cell, and newline
  8036. is used to delimit the end of each row.
  8037. If this option is not specified, the initial grid is generated
  8038. randomly.
  8039. @item rate, r
  8040. Set the video rate, that is the number of frames generated per second.
  8041. Default is 25.
  8042. @item random_fill_ratio, ratio
  8043. Set the random fill ratio for the initial random grid. It is a
  8044. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  8045. It is ignored when a file is specified.
  8046. @item random_seed, seed
  8047. Set the seed for filling the initial random grid, must be an integer
  8048. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8049. set to -1, the filter will try to use a good random seed on a best
  8050. effort basis.
  8051. @item rule
  8052. Set the life rule.
  8053. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  8054. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  8055. @var{NS} specifies the number of alive neighbor cells which make a
  8056. live cell stay alive, and @var{NB} the number of alive neighbor cells
  8057. which make a dead cell to become alive (i.e. to "born").
  8058. "s" and "b" can be used in place of "S" and "B", respectively.
  8059. Alternatively a rule can be specified by an 18-bits integer. The 9
  8060. high order bits are used to encode the next cell state if it is alive
  8061. for each number of neighbor alive cells, the low order bits specify
  8062. the rule for "borning" new cells. Higher order bits encode for an
  8063. higher number of neighbor cells.
  8064. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  8065. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  8066. Default value is "S23/B3", which is the original Conway's game of life
  8067. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  8068. cells, and will born a new cell if there are three alive cells around
  8069. a dead cell.
  8070. @item size, s
  8071. Set the size of the output video. For the syntax of this option, check the
  8072. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8073. If @option{filename} is specified, the size is set by default to the
  8074. same size of the input file. If @option{size} is set, it must contain
  8075. the size specified in the input file, and the initial grid defined in
  8076. that file is centered in the larger resulting area.
  8077. If a filename is not specified, the size value defaults to "320x240"
  8078. (used for a randomly generated initial grid).
  8079. @item stitch
  8080. If set to 1, stitch the left and right grid edges together, and the
  8081. top and bottom edges also. Defaults to 1.
  8082. @item mold
  8083. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  8084. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  8085. value from 0 to 255.
  8086. @item life_color
  8087. Set the color of living (or new born) cells.
  8088. @item death_color
  8089. Set the color of dead cells. If @option{mold} is set, this is the first color
  8090. used to represent a dead cell.
  8091. @item mold_color
  8092. Set mold color, for definitely dead and moldy cells.
  8093. For the syntax of these 3 color options, check the "Color" section in the
  8094. ffmpeg-utils manual.
  8095. @end table
  8096. @subsection Examples
  8097. @itemize
  8098. @item
  8099. Read a grid from @file{pattern}, and center it on a grid of size
  8100. 300x300 pixels:
  8101. @example
  8102. life=f=pattern:s=300x300
  8103. @end example
  8104. @item
  8105. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  8106. @example
  8107. life=ratio=2/3:s=200x200
  8108. @end example
  8109. @item
  8110. Specify a custom rule for evolving a randomly generated grid:
  8111. @example
  8112. life=rule=S14/B34
  8113. @end example
  8114. @item
  8115. Full example with slow death effect (mold) using @command{ffplay}:
  8116. @example
  8117. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  8118. @end example
  8119. @end itemize
  8120. @anchor{color}
  8121. @anchor{haldclutsrc}
  8122. @anchor{nullsrc}
  8123. @anchor{rgbtestsrc}
  8124. @anchor{smptebars}
  8125. @anchor{smptehdbars}
  8126. @anchor{testsrc}
  8127. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  8128. The @code{color} source provides an uniformly colored input.
  8129. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  8130. @ref{haldclut} filter.
  8131. The @code{nullsrc} source returns unprocessed video frames. It is
  8132. mainly useful to be employed in analysis / debugging tools, or as the
  8133. source for filters which ignore the input data.
  8134. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  8135. detecting RGB vs BGR issues. You should see a red, green and blue
  8136. stripe from top to bottom.
  8137. The @code{smptebars} source generates a color bars pattern, based on
  8138. the SMPTE Engineering Guideline EG 1-1990.
  8139. The @code{smptehdbars} source generates a color bars pattern, based on
  8140. the SMPTE RP 219-2002.
  8141. The @code{testsrc} source generates a test video pattern, showing a
  8142. color pattern, a scrolling gradient and a timestamp. This is mainly
  8143. intended for testing purposes.
  8144. The sources accept the following parameters:
  8145. @table @option
  8146. @item color, c
  8147. Specify the color of the source, only available in the @code{color}
  8148. source. For the syntax of this option, check the "Color" section in the
  8149. ffmpeg-utils manual.
  8150. @item level
  8151. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  8152. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  8153. pixels to be used as identity matrix for 3D lookup tables. Each component is
  8154. coded on a @code{1/(N*N)} scale.
  8155. @item size, s
  8156. Specify the size of the sourced video. For the syntax of this option, check the
  8157. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8158. The default value is @code{320x240}.
  8159. This option is not available with the @code{haldclutsrc} filter.
  8160. @item rate, r
  8161. Specify the frame rate of the sourced video, as the number of frames
  8162. generated per second. It has to be a string in the format
  8163. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8164. number or a valid video frame rate abbreviation. The default value is
  8165. "25".
  8166. @item sar
  8167. Set the sample aspect ratio of the sourced video.
  8168. @item duration, d
  8169. Set the duration of the sourced video. See
  8170. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8171. for the accepted syntax.
  8172. If not specified, or the expressed duration is negative, the video is
  8173. supposed to be generated forever.
  8174. @item decimals, n
  8175. Set the number of decimals to show in the timestamp, only available in the
  8176. @code{testsrc} source.
  8177. The displayed timestamp value will correspond to the original
  8178. timestamp value multiplied by the power of 10 of the specified
  8179. value. Default value is 0.
  8180. @end table
  8181. For example the following:
  8182. @example
  8183. testsrc=duration=5.3:size=qcif:rate=10
  8184. @end example
  8185. will generate a video with a duration of 5.3 seconds, with size
  8186. 176x144 and a frame rate of 10 frames per second.
  8187. The following graph description will generate a red source
  8188. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  8189. frames per second.
  8190. @example
  8191. color=c=red@@0.2:s=qcif:r=10
  8192. @end example
  8193. If the input content is to be ignored, @code{nullsrc} can be used. The
  8194. following command generates noise in the luminance plane by employing
  8195. the @code{geq} filter:
  8196. @example
  8197. nullsrc=s=256x256, geq=random(1)*255:128:128
  8198. @end example
  8199. @subsection Commands
  8200. The @code{color} source supports the following commands:
  8201. @table @option
  8202. @item c, color
  8203. Set the color of the created image. Accepts the same syntax of the
  8204. corresponding @option{color} option.
  8205. @end table
  8206. @c man end VIDEO SOURCES
  8207. @chapter Video Sinks
  8208. @c man begin VIDEO SINKS
  8209. Below is a description of the currently available video sinks.
  8210. @section buffersink
  8211. Buffer video frames, and make them available to the end of the filter
  8212. graph.
  8213. This sink is mainly intended for programmatic use, in particular
  8214. through the interface defined in @file{libavfilter/buffersink.h}
  8215. or the options system.
  8216. It accepts a pointer to an AVBufferSinkContext structure, which
  8217. defines the incoming buffers' formats, to be passed as the opaque
  8218. parameter to @code{avfilter_init_filter} for initialization.
  8219. @section nullsink
  8220. Null video sink: do absolutely nothing with the input video. It is
  8221. mainly useful as a template and for use in analysis / debugging
  8222. tools.
  8223. @c man end VIDEO SINKS
  8224. @chapter Multimedia Filters
  8225. @c man begin MULTIMEDIA FILTERS
  8226. Below is a description of the currently available multimedia filters.
  8227. @section avectorscope
  8228. Convert input audio to a video output, representing the audio vector
  8229. scope.
  8230. The filter is used to measure the difference between channels of stereo
  8231. audio stream. A monoaural signal, consisting of identical left and right
  8232. signal, results in straight vertical line. Any stereo separation is visible
  8233. as a deviation from this line, creating a Lissajous figure.
  8234. If the straight (or deviation from it) but horizontal line appears this
  8235. indicates that the left and right channels are out of phase.
  8236. The filter accepts the following options:
  8237. @table @option
  8238. @item mode, m
  8239. Set the vectorscope mode.
  8240. Available values are:
  8241. @table @samp
  8242. @item lissajous
  8243. Lissajous rotated by 45 degrees.
  8244. @item lissajous_xy
  8245. Same as above but not rotated.
  8246. @end table
  8247. Default value is @samp{lissajous}.
  8248. @item size, s
  8249. Set the video size for the output. For the syntax of this option, check the
  8250. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8251. Default value is @code{400x400}.
  8252. @item rate, r
  8253. Set the output frame rate. Default value is @code{25}.
  8254. @item rc
  8255. @item gc
  8256. @item bc
  8257. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  8258. Allowed range is @code{[0, 255]}.
  8259. @item rf
  8260. @item gf
  8261. @item bf
  8262. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  8263. Allowed range is @code{[0, 255]}.
  8264. @item zoom
  8265. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  8266. @end table
  8267. @subsection Examples
  8268. @itemize
  8269. @item
  8270. Complete example using @command{ffplay}:
  8271. @example
  8272. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  8273. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  8274. @end example
  8275. @end itemize
  8276. @section concat
  8277. Concatenate audio and video streams, joining them together one after the
  8278. other.
  8279. The filter works on segments of synchronized video and audio streams. All
  8280. segments must have the same number of streams of each type, and that will
  8281. also be the number of streams at output.
  8282. The filter accepts the following options:
  8283. @table @option
  8284. @item n
  8285. Set the number of segments. Default is 2.
  8286. @item v
  8287. Set the number of output video streams, that is also the number of video
  8288. streams in each segment. Default is 1.
  8289. @item a
  8290. Set the number of output audio streams, that is also the number of audio
  8291. streams in each segment. Default is 0.
  8292. @item unsafe
  8293. Activate unsafe mode: do not fail if segments have a different format.
  8294. @end table
  8295. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  8296. @var{a} audio outputs.
  8297. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  8298. segment, in the same order as the outputs, then the inputs for the second
  8299. segment, etc.
  8300. Related streams do not always have exactly the same duration, for various
  8301. reasons including codec frame size or sloppy authoring. For that reason,
  8302. related synchronized streams (e.g. a video and its audio track) should be
  8303. concatenated at once. The concat filter will use the duration of the longest
  8304. stream in each segment (except the last one), and if necessary pad shorter
  8305. audio streams with silence.
  8306. For this filter to work correctly, all segments must start at timestamp 0.
  8307. All corresponding streams must have the same parameters in all segments; the
  8308. filtering system will automatically select a common pixel format for video
  8309. streams, and a common sample format, sample rate and channel layout for
  8310. audio streams, but other settings, such as resolution, must be converted
  8311. explicitly by the user.
  8312. Different frame rates are acceptable but will result in variable frame rate
  8313. at output; be sure to configure the output file to handle it.
  8314. @subsection Examples
  8315. @itemize
  8316. @item
  8317. Concatenate an opening, an episode and an ending, all in bilingual version
  8318. (video in stream 0, audio in streams 1 and 2):
  8319. @example
  8320. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  8321. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  8322. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  8323. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  8324. @end example
  8325. @item
  8326. Concatenate two parts, handling audio and video separately, using the
  8327. (a)movie sources, and adjusting the resolution:
  8328. @example
  8329. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  8330. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  8331. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  8332. @end example
  8333. Note that a desync will happen at the stitch if the audio and video streams
  8334. do not have exactly the same duration in the first file.
  8335. @end itemize
  8336. @section ebur128
  8337. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  8338. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  8339. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  8340. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  8341. The filter also has a video output (see the @var{video} option) with a real
  8342. time graph to observe the loudness evolution. The graphic contains the logged
  8343. message mentioned above, so it is not printed anymore when this option is set,
  8344. unless the verbose logging is set. The main graphing area contains the
  8345. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  8346. the momentary loudness (400 milliseconds).
  8347. More information about the Loudness Recommendation EBU R128 on
  8348. @url{http://tech.ebu.ch/loudness}.
  8349. The filter accepts the following options:
  8350. @table @option
  8351. @item video
  8352. Activate the video output. The audio stream is passed unchanged whether this
  8353. option is set or no. The video stream will be the first output stream if
  8354. activated. Default is @code{0}.
  8355. @item size
  8356. Set the video size. This option is for video only. For the syntax of this
  8357. option, check the
  8358. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8359. Default and minimum resolution is @code{640x480}.
  8360. @item meter
  8361. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  8362. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  8363. other integer value between this range is allowed.
  8364. @item metadata
  8365. Set metadata injection. If set to @code{1}, the audio input will be segmented
  8366. into 100ms output frames, each of them containing various loudness information
  8367. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  8368. Default is @code{0}.
  8369. @item framelog
  8370. Force the frame logging level.
  8371. Available values are:
  8372. @table @samp
  8373. @item info
  8374. information logging level
  8375. @item verbose
  8376. verbose logging level
  8377. @end table
  8378. By default, the logging level is set to @var{info}. If the @option{video} or
  8379. the @option{metadata} options are set, it switches to @var{verbose}.
  8380. @item peak
  8381. Set peak mode(s).
  8382. Available modes can be cumulated (the option is a @code{flag} type). Possible
  8383. values are:
  8384. @table @samp
  8385. @item none
  8386. Disable any peak mode (default).
  8387. @item sample
  8388. Enable sample-peak mode.
  8389. Simple peak mode looking for the higher sample value. It logs a message
  8390. for sample-peak (identified by @code{SPK}).
  8391. @item true
  8392. Enable true-peak mode.
  8393. If enabled, the peak lookup is done on an over-sampled version of the input
  8394. stream for better peak accuracy. It logs a message for true-peak.
  8395. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  8396. This mode requires a build with @code{libswresample}.
  8397. @end table
  8398. @end table
  8399. @subsection Examples
  8400. @itemize
  8401. @item
  8402. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  8403. @example
  8404. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  8405. @end example
  8406. @item
  8407. Run an analysis with @command{ffmpeg}:
  8408. @example
  8409. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  8410. @end example
  8411. @end itemize
  8412. @section interleave, ainterleave
  8413. Temporally interleave frames from several inputs.
  8414. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  8415. These filters read frames from several inputs and send the oldest
  8416. queued frame to the output.
  8417. Input streams must have a well defined, monotonically increasing frame
  8418. timestamp values.
  8419. In order to submit one frame to output, these filters need to enqueue
  8420. at least one frame for each input, so they cannot work in case one
  8421. input is not yet terminated and will not receive incoming frames.
  8422. For example consider the case when one input is a @code{select} filter
  8423. which always drop input frames. The @code{interleave} filter will keep
  8424. reading from that input, but it will never be able to send new frames
  8425. to output until the input will send an end-of-stream signal.
  8426. Also, depending on inputs synchronization, the filters will drop
  8427. frames in case one input receives more frames than the other ones, and
  8428. the queue is already filled.
  8429. These filters accept the following options:
  8430. @table @option
  8431. @item nb_inputs, n
  8432. Set the number of different inputs, it is 2 by default.
  8433. @end table
  8434. @subsection Examples
  8435. @itemize
  8436. @item
  8437. Interleave frames belonging to different streams using @command{ffmpeg}:
  8438. @example
  8439. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  8440. @end example
  8441. @item
  8442. Add flickering blur effect:
  8443. @example
  8444. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  8445. @end example
  8446. @end itemize
  8447. @section perms, aperms
  8448. Set read/write permissions for the output frames.
  8449. These filters are mainly aimed at developers to test direct path in the
  8450. following filter in the filtergraph.
  8451. The filters accept the following options:
  8452. @table @option
  8453. @item mode
  8454. Select the permissions mode.
  8455. It accepts the following values:
  8456. @table @samp
  8457. @item none
  8458. Do nothing. This is the default.
  8459. @item ro
  8460. Set all the output frames read-only.
  8461. @item rw
  8462. Set all the output frames directly writable.
  8463. @item toggle
  8464. Make the frame read-only if writable, and writable if read-only.
  8465. @item random
  8466. Set each output frame read-only or writable randomly.
  8467. @end table
  8468. @item seed
  8469. Set the seed for the @var{random} mode, must be an integer included between
  8470. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  8471. @code{-1}, the filter will try to use a good random seed on a best effort
  8472. basis.
  8473. @end table
  8474. Note: in case of auto-inserted filter between the permission filter and the
  8475. following one, the permission might not be received as expected in that
  8476. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  8477. perms/aperms filter can avoid this problem.
  8478. @section select, aselect
  8479. Select frames to pass in output.
  8480. This filter accepts the following options:
  8481. @table @option
  8482. @item expr, e
  8483. Set expression, which is evaluated for each input frame.
  8484. If the expression is evaluated to zero, the frame is discarded.
  8485. If the evaluation result is negative or NaN, the frame is sent to the
  8486. first output; otherwise it is sent to the output with index
  8487. @code{ceil(val)-1}, assuming that the input index starts from 0.
  8488. For example a value of @code{1.2} corresponds to the output with index
  8489. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  8490. @item outputs, n
  8491. Set the number of outputs. The output to which to send the selected
  8492. frame is based on the result of the evaluation. Default value is 1.
  8493. @end table
  8494. The expression can contain the following constants:
  8495. @table @option
  8496. @item n
  8497. The (sequential) number of the filtered frame, starting from 0.
  8498. @item selected_n
  8499. The (sequential) number of the selected frame, starting from 0.
  8500. @item prev_selected_n
  8501. The sequential number of the last selected frame. It's NAN if undefined.
  8502. @item TB
  8503. The timebase of the input timestamps.
  8504. @item pts
  8505. The PTS (Presentation TimeStamp) of the filtered video frame,
  8506. expressed in @var{TB} units. It's NAN if undefined.
  8507. @item t
  8508. The PTS of the filtered video frame,
  8509. expressed in seconds. It's NAN if undefined.
  8510. @item prev_pts
  8511. The PTS of the previously filtered video frame. It's NAN if undefined.
  8512. @item prev_selected_pts
  8513. The PTS of the last previously filtered video frame. It's NAN if undefined.
  8514. @item prev_selected_t
  8515. The PTS of the last previously selected video frame. It's NAN if undefined.
  8516. @item start_pts
  8517. The PTS of the first video frame in the video. It's NAN if undefined.
  8518. @item start_t
  8519. The time of the first video frame in the video. It's NAN if undefined.
  8520. @item pict_type @emph{(video only)}
  8521. The type of the filtered frame. It can assume one of the following
  8522. values:
  8523. @table @option
  8524. @item I
  8525. @item P
  8526. @item B
  8527. @item S
  8528. @item SI
  8529. @item SP
  8530. @item BI
  8531. @end table
  8532. @item interlace_type @emph{(video only)}
  8533. The frame interlace type. It can assume one of the following values:
  8534. @table @option
  8535. @item PROGRESSIVE
  8536. The frame is progressive (not interlaced).
  8537. @item TOPFIRST
  8538. The frame is top-field-first.
  8539. @item BOTTOMFIRST
  8540. The frame is bottom-field-first.
  8541. @end table
  8542. @item consumed_sample_n @emph{(audio only)}
  8543. the number of selected samples before the current frame
  8544. @item samples_n @emph{(audio only)}
  8545. the number of samples in the current frame
  8546. @item sample_rate @emph{(audio only)}
  8547. the input sample rate
  8548. @item key
  8549. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  8550. @item pos
  8551. the position in the file of the filtered frame, -1 if the information
  8552. is not available (e.g. for synthetic video)
  8553. @item scene @emph{(video only)}
  8554. value between 0 and 1 to indicate a new scene; a low value reflects a low
  8555. probability for the current frame to introduce a new scene, while a higher
  8556. value means the current frame is more likely to be one (see the example below)
  8557. @end table
  8558. The default value of the select expression is "1".
  8559. @subsection Examples
  8560. @itemize
  8561. @item
  8562. Select all frames in input:
  8563. @example
  8564. select
  8565. @end example
  8566. The example above is the same as:
  8567. @example
  8568. select=1
  8569. @end example
  8570. @item
  8571. Skip all frames:
  8572. @example
  8573. select=0
  8574. @end example
  8575. @item
  8576. Select only I-frames:
  8577. @example
  8578. select='eq(pict_type\,I)'
  8579. @end example
  8580. @item
  8581. Select one frame every 100:
  8582. @example
  8583. select='not(mod(n\,100))'
  8584. @end example
  8585. @item
  8586. Select only frames contained in the 10-20 time interval:
  8587. @example
  8588. select=between(t\,10\,20)
  8589. @end example
  8590. @item
  8591. Select only I frames contained in the 10-20 time interval:
  8592. @example
  8593. select=between(t\,10\,20)*eq(pict_type\,I)
  8594. @end example
  8595. @item
  8596. Select frames with a minimum distance of 10 seconds:
  8597. @example
  8598. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  8599. @end example
  8600. @item
  8601. Use aselect to select only audio frames with samples number > 100:
  8602. @example
  8603. aselect='gt(samples_n\,100)'
  8604. @end example
  8605. @item
  8606. Create a mosaic of the first scenes:
  8607. @example
  8608. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  8609. @end example
  8610. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  8611. choice.
  8612. @item
  8613. Send even and odd frames to separate outputs, and compose them:
  8614. @example
  8615. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  8616. @end example
  8617. @end itemize
  8618. @section sendcmd, asendcmd
  8619. Send commands to filters in the filtergraph.
  8620. These filters read commands to be sent to other filters in the
  8621. filtergraph.
  8622. @code{sendcmd} must be inserted between two video filters,
  8623. @code{asendcmd} must be inserted between two audio filters, but apart
  8624. from that they act the same way.
  8625. The specification of commands can be provided in the filter arguments
  8626. with the @var{commands} option, or in a file specified by the
  8627. @var{filename} option.
  8628. These filters accept the following options:
  8629. @table @option
  8630. @item commands, c
  8631. Set the commands to be read and sent to the other filters.
  8632. @item filename, f
  8633. Set the filename of the commands to be read and sent to the other
  8634. filters.
  8635. @end table
  8636. @subsection Commands syntax
  8637. A commands description consists of a sequence of interval
  8638. specifications, comprising a list of commands to be executed when a
  8639. particular event related to that interval occurs. The occurring event
  8640. is typically the current frame time entering or leaving a given time
  8641. interval.
  8642. An interval is specified by the following syntax:
  8643. @example
  8644. @var{START}[-@var{END}] @var{COMMANDS};
  8645. @end example
  8646. The time interval is specified by the @var{START} and @var{END} times.
  8647. @var{END} is optional and defaults to the maximum time.
  8648. The current frame time is considered within the specified interval if
  8649. it is included in the interval [@var{START}, @var{END}), that is when
  8650. the time is greater or equal to @var{START} and is lesser than
  8651. @var{END}.
  8652. @var{COMMANDS} consists of a sequence of one or more command
  8653. specifications, separated by ",", relating to that interval. The
  8654. syntax of a command specification is given by:
  8655. @example
  8656. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  8657. @end example
  8658. @var{FLAGS} is optional and specifies the type of events relating to
  8659. the time interval which enable sending the specified command, and must
  8660. be a non-null sequence of identifier flags separated by "+" or "|" and
  8661. enclosed between "[" and "]".
  8662. The following flags are recognized:
  8663. @table @option
  8664. @item enter
  8665. The command is sent when the current frame timestamp enters the
  8666. specified interval. In other words, the command is sent when the
  8667. previous frame timestamp was not in the given interval, and the
  8668. current is.
  8669. @item leave
  8670. The command is sent when the current frame timestamp leaves the
  8671. specified interval. In other words, the command is sent when the
  8672. previous frame timestamp was in the given interval, and the
  8673. current is not.
  8674. @end table
  8675. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  8676. assumed.
  8677. @var{TARGET} specifies the target of the command, usually the name of
  8678. the filter class or a specific filter instance name.
  8679. @var{COMMAND} specifies the name of the command for the target filter.
  8680. @var{ARG} is optional and specifies the optional list of argument for
  8681. the given @var{COMMAND}.
  8682. Between one interval specification and another, whitespaces, or
  8683. sequences of characters starting with @code{#} until the end of line,
  8684. are ignored and can be used to annotate comments.
  8685. A simplified BNF description of the commands specification syntax
  8686. follows:
  8687. @example
  8688. @var{COMMAND_FLAG} ::= "enter" | "leave"
  8689. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  8690. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  8691. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  8692. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  8693. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  8694. @end example
  8695. @subsection Examples
  8696. @itemize
  8697. @item
  8698. Specify audio tempo change at second 4:
  8699. @example
  8700. asendcmd=c='4.0 atempo tempo 1.5',atempo
  8701. @end example
  8702. @item
  8703. Specify a list of drawtext and hue commands in a file.
  8704. @example
  8705. # show text in the interval 5-10
  8706. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  8707. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  8708. # desaturate the image in the interval 15-20
  8709. 15.0-20.0 [enter] hue s 0,
  8710. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  8711. [leave] hue s 1,
  8712. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  8713. # apply an exponential saturation fade-out effect, starting from time 25
  8714. 25 [enter] hue s exp(25-t)
  8715. @end example
  8716. A filtergraph allowing to read and process the above command list
  8717. stored in a file @file{test.cmd}, can be specified with:
  8718. @example
  8719. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  8720. @end example
  8721. @end itemize
  8722. @anchor{setpts}
  8723. @section setpts, asetpts
  8724. Change the PTS (presentation timestamp) of the input frames.
  8725. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  8726. This filter accepts the following options:
  8727. @table @option
  8728. @item expr
  8729. The expression which is evaluated for each frame to construct its timestamp.
  8730. @end table
  8731. The expression is evaluated through the eval API and can contain the following
  8732. constants:
  8733. @table @option
  8734. @item FRAME_RATE
  8735. frame rate, only defined for constant frame-rate video
  8736. @item PTS
  8737. The presentation timestamp in input
  8738. @item N
  8739. The count of the input frame for video or the number of consumed samples,
  8740. not including the current frame for audio, starting from 0.
  8741. @item NB_CONSUMED_SAMPLES
  8742. The number of consumed samples, not including the current frame (only
  8743. audio)
  8744. @item NB_SAMPLES, S
  8745. The number of samples in the current frame (only audio)
  8746. @item SAMPLE_RATE, SR
  8747. The audio sample rate.
  8748. @item STARTPTS
  8749. The PTS of the first frame.
  8750. @item STARTT
  8751. the time in seconds of the first frame
  8752. @item INTERLACED
  8753. State whether the current frame is interlaced.
  8754. @item T
  8755. the time in seconds of the current frame
  8756. @item POS
  8757. original position in the file of the frame, or undefined if undefined
  8758. for the current frame
  8759. @item PREV_INPTS
  8760. The previous input PTS.
  8761. @item PREV_INT
  8762. previous input time in seconds
  8763. @item PREV_OUTPTS
  8764. The previous output PTS.
  8765. @item PREV_OUTT
  8766. previous output time in seconds
  8767. @item RTCTIME
  8768. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  8769. instead.
  8770. @item RTCSTART
  8771. The wallclock (RTC) time at the start of the movie in microseconds.
  8772. @item TB
  8773. The timebase of the input timestamps.
  8774. @end table
  8775. @subsection Examples
  8776. @itemize
  8777. @item
  8778. Start counting PTS from zero
  8779. @example
  8780. setpts=PTS-STARTPTS
  8781. @end example
  8782. @item
  8783. Apply fast motion effect:
  8784. @example
  8785. setpts=0.5*PTS
  8786. @end example
  8787. @item
  8788. Apply slow motion effect:
  8789. @example
  8790. setpts=2.0*PTS
  8791. @end example
  8792. @item
  8793. Set fixed rate of 25 frames per second:
  8794. @example
  8795. setpts=N/(25*TB)
  8796. @end example
  8797. @item
  8798. Set fixed rate 25 fps with some jitter:
  8799. @example
  8800. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  8801. @end example
  8802. @item
  8803. Apply an offset of 10 seconds to the input PTS:
  8804. @example
  8805. setpts=PTS+10/TB
  8806. @end example
  8807. @item
  8808. Generate timestamps from a "live source" and rebase onto the current timebase:
  8809. @example
  8810. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  8811. @end example
  8812. @item
  8813. Generate timestamps by counting samples:
  8814. @example
  8815. asetpts=N/SR/TB
  8816. @end example
  8817. @end itemize
  8818. @section settb, asettb
  8819. Set the timebase to use for the output frames timestamps.
  8820. It is mainly useful for testing timebase configuration.
  8821. It accepts the following parameters:
  8822. @table @option
  8823. @item expr, tb
  8824. The expression which is evaluated into the output timebase.
  8825. @end table
  8826. The value for @option{tb} is an arithmetic expression representing a
  8827. rational. The expression can contain the constants "AVTB" (the default
  8828. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  8829. audio only). Default value is "intb".
  8830. @subsection Examples
  8831. @itemize
  8832. @item
  8833. Set the timebase to 1/25:
  8834. @example
  8835. settb=expr=1/25
  8836. @end example
  8837. @item
  8838. Set the timebase to 1/10:
  8839. @example
  8840. settb=expr=0.1
  8841. @end example
  8842. @item
  8843. Set the timebase to 1001/1000:
  8844. @example
  8845. settb=1+0.001
  8846. @end example
  8847. @item
  8848. Set the timebase to 2*intb:
  8849. @example
  8850. settb=2*intb
  8851. @end example
  8852. @item
  8853. Set the default timebase value:
  8854. @example
  8855. settb=AVTB
  8856. @end example
  8857. @end itemize
  8858. @section showcqt
  8859. Convert input audio to a video output representing
  8860. frequency spectrum logarithmically (using constant Q transform with
  8861. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  8862. The filter accepts the following options:
  8863. @table @option
  8864. @item volume
  8865. Specify transform volume (multiplier) expression. The expression can contain
  8866. variables:
  8867. @table @option
  8868. @item frequency, freq, f
  8869. the frequency where transform is evaluated
  8870. @item timeclamp, tc
  8871. value of timeclamp option
  8872. @end table
  8873. and functions:
  8874. @table @option
  8875. @item a_weighting(f)
  8876. A-weighting of equal loudness
  8877. @item b_weighting(f)
  8878. B-weighting of equal loudness
  8879. @item c_weighting(f)
  8880. C-weighting of equal loudness
  8881. @end table
  8882. Default value is @code{16}.
  8883. @item tlength
  8884. Specify transform length expression. The expression can contain variables:
  8885. @table @option
  8886. @item frequency, freq, f
  8887. the frequency where transform is evaluated
  8888. @item timeclamp, tc
  8889. value of timeclamp option
  8890. @end table
  8891. Default value is @code{384/f*tc/(384/f+tc)}.
  8892. @item timeclamp
  8893. Specify the transform timeclamp. At low frequency, there is trade-off between
  8894. accuracy in time domain and frequency domain. If timeclamp is lower,
  8895. event in time domain is represented more accurately (such as fast bass drum),
  8896. otherwise event in frequency domain is represented more accurately
  8897. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  8898. @item coeffclamp
  8899. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  8900. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  8901. Default value is @code{1.0}.
  8902. @item gamma
  8903. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  8904. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  8905. Default value is @code{3.0}.
  8906. @item gamma2
  8907. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  8908. Default value is @code{1.0}.
  8909. @item fontfile
  8910. Specify font file for use with freetype. If not specified, use embedded font.
  8911. @item fontcolor
  8912. Specify font color expression. This is arithmetic expression that should return
  8913. integer value 0xRRGGBB. The expression can contain variables:
  8914. @table @option
  8915. @item frequency, freq, f
  8916. the frequency where transform is evaluated
  8917. @item timeclamp, tc
  8918. value of timeclamp option
  8919. @end table
  8920. and functions:
  8921. @table @option
  8922. @item midi(f)
  8923. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  8924. @item r(x), g(x), b(x)
  8925. red, green, and blue value of intensity x
  8926. @end table
  8927. Default value is @code{st(0, (midi(f)-59.5)/12);
  8928. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  8929. r(1-ld(1)) + b(ld(1))}
  8930. @item fullhd
  8931. If set to 1 (the default), the video size is 1920x1080 (full HD),
  8932. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  8933. @item fps
  8934. Specify video fps. Default value is @code{25}.
  8935. @item count
  8936. Specify number of transform per frame, so there are fps*count transforms
  8937. per second. Note that audio data rate must be divisible by fps*count.
  8938. Default value is @code{6}.
  8939. @end table
  8940. @subsection Examples
  8941. @itemize
  8942. @item
  8943. Playing audio while showing the spectrum:
  8944. @example
  8945. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  8946. @end example
  8947. @item
  8948. Same as above, but with frame rate 30 fps:
  8949. @example
  8950. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  8951. @end example
  8952. @item
  8953. Playing at 960x540 and lower CPU usage:
  8954. @example
  8955. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  8956. @end example
  8957. @item
  8958. A1 and its harmonics: A1, A2, (near)E3, A3:
  8959. @example
  8960. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  8961. asplit[a][out1]; [a] showcqt [out0]'
  8962. @end example
  8963. @item
  8964. Same as above, but with more accuracy in frequency domain (and slower):
  8965. @example
  8966. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  8967. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  8968. @end example
  8969. @item
  8970. B-weighting of equal loudness
  8971. @example
  8972. volume=16*b_weighting(f)
  8973. @end example
  8974. @item
  8975. Lower Q factor
  8976. @example
  8977. tlength=100/f*tc/(100/f+tc)
  8978. @end example
  8979. @item
  8980. Custom fontcolor, C-note is colored green, others are colored blue
  8981. @example
  8982. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  8983. @end example
  8984. @item
  8985. Custom gamma, now spectrum is linear to the amplitude.
  8986. @example
  8987. gamma=2:gamma2=2
  8988. @end example
  8989. @end itemize
  8990. @section showspectrum
  8991. Convert input audio to a video output, representing the audio frequency
  8992. spectrum.
  8993. The filter accepts the following options:
  8994. @table @option
  8995. @item size, s
  8996. Specify the video size for the output. For the syntax of this option, check the
  8997. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8998. Default value is @code{640x512}.
  8999. @item slide
  9000. Specify how the spectrum should slide along the window.
  9001. It accepts the following values:
  9002. @table @samp
  9003. @item replace
  9004. the samples start again on the left when they reach the right
  9005. @item scroll
  9006. the samples scroll from right to left
  9007. @item fullframe
  9008. frames are only produced when the samples reach the right
  9009. @end table
  9010. Default value is @code{replace}.
  9011. @item mode
  9012. Specify display mode.
  9013. It accepts the following values:
  9014. @table @samp
  9015. @item combined
  9016. all channels are displayed in the same row
  9017. @item separate
  9018. all channels are displayed in separate rows
  9019. @end table
  9020. Default value is @samp{combined}.
  9021. @item color
  9022. Specify display color mode.
  9023. It accepts the following values:
  9024. @table @samp
  9025. @item channel
  9026. each channel is displayed in a separate color
  9027. @item intensity
  9028. each channel is is displayed using the same color scheme
  9029. @end table
  9030. Default value is @samp{channel}.
  9031. @item scale
  9032. Specify scale used for calculating intensity color values.
  9033. It accepts the following values:
  9034. @table @samp
  9035. @item lin
  9036. linear
  9037. @item sqrt
  9038. square root, default
  9039. @item cbrt
  9040. cubic root
  9041. @item log
  9042. logarithmic
  9043. @end table
  9044. Default value is @samp{sqrt}.
  9045. @item saturation
  9046. Set saturation modifier for displayed colors. Negative values provide
  9047. alternative color scheme. @code{0} is no saturation at all.
  9048. Saturation must be in [-10.0, 10.0] range.
  9049. Default value is @code{1}.
  9050. @item win_func
  9051. Set window function.
  9052. It accepts the following values:
  9053. @table @samp
  9054. @item none
  9055. No samples pre-processing (do not expect this to be faster)
  9056. @item hann
  9057. Hann window
  9058. @item hamming
  9059. Hamming window
  9060. @item blackman
  9061. Blackman window
  9062. @end table
  9063. Default value is @code{hann}.
  9064. @end table
  9065. The usage is very similar to the showwaves filter; see the examples in that
  9066. section.
  9067. @subsection Examples
  9068. @itemize
  9069. @item
  9070. Large window with logarithmic color scaling:
  9071. @example
  9072. showspectrum=s=1280x480:scale=log
  9073. @end example
  9074. @item
  9075. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  9076. @example
  9077. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9078. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  9079. @end example
  9080. @end itemize
  9081. @section showwaves
  9082. Convert input audio to a video output, representing the samples waves.
  9083. The filter accepts the following options:
  9084. @table @option
  9085. @item size, s
  9086. Specify the video size for the output. For the syntax of this option, check the
  9087. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9088. Default value is @code{600x240}.
  9089. @item mode
  9090. Set display mode.
  9091. Available values are:
  9092. @table @samp
  9093. @item point
  9094. Draw a point for each sample.
  9095. @item line
  9096. Draw a vertical line for each sample.
  9097. @item p2p
  9098. Draw a point for each sample and a line between them.
  9099. @item cline
  9100. Draw a centered vertical line for each sample.
  9101. @end table
  9102. Default value is @code{point}.
  9103. @item n
  9104. Set the number of samples which are printed on the same column. A
  9105. larger value will decrease the frame rate. Must be a positive
  9106. integer. This option can be set only if the value for @var{rate}
  9107. is not explicitly specified.
  9108. @item rate, r
  9109. Set the (approximate) output frame rate. This is done by setting the
  9110. option @var{n}. Default value is "25".
  9111. @item split_channels
  9112. Set if channels should be drawn separately or overlap. Default value is 0.
  9113. @end table
  9114. @subsection Examples
  9115. @itemize
  9116. @item
  9117. Output the input file audio and the corresponding video representation
  9118. at the same time:
  9119. @example
  9120. amovie=a.mp3,asplit[out0],showwaves[out1]
  9121. @end example
  9122. @item
  9123. Create a synthetic signal and show it with showwaves, forcing a
  9124. frame rate of 30 frames per second:
  9125. @example
  9126. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  9127. @end example
  9128. @end itemize
  9129. @section showwavespic
  9130. Convert input audio to a single video frame, representing the samples waves.
  9131. The filter accepts the following options:
  9132. @table @option
  9133. @item size, s
  9134. Specify the video size for the output. For the syntax of this option, check the
  9135. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9136. Default value is @code{600x240}.
  9137. @item split_channels
  9138. Set if channels should be drawn separately or overlap. Default value is 0.
  9139. @end table
  9140. @subsection Examples
  9141. @itemize
  9142. @item
  9143. Extract a channel split representation of the wave form of a whole audio track
  9144. in a 1024x800 picture using @command{ffmpeg}:
  9145. @example
  9146. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  9147. @end example
  9148. @end itemize
  9149. @section split, asplit
  9150. Split input into several identical outputs.
  9151. @code{asplit} works with audio input, @code{split} with video.
  9152. The filter accepts a single parameter which specifies the number of outputs. If
  9153. unspecified, it defaults to 2.
  9154. @subsection Examples
  9155. @itemize
  9156. @item
  9157. Create two separate outputs from the same input:
  9158. @example
  9159. [in] split [out0][out1]
  9160. @end example
  9161. @item
  9162. To create 3 or more outputs, you need to specify the number of
  9163. outputs, like in:
  9164. @example
  9165. [in] asplit=3 [out0][out1][out2]
  9166. @end example
  9167. @item
  9168. Create two separate outputs from the same input, one cropped and
  9169. one padded:
  9170. @example
  9171. [in] split [splitout1][splitout2];
  9172. [splitout1] crop=100:100:0:0 [cropout];
  9173. [splitout2] pad=200:200:100:100 [padout];
  9174. @end example
  9175. @item
  9176. Create 5 copies of the input audio with @command{ffmpeg}:
  9177. @example
  9178. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  9179. @end example
  9180. @end itemize
  9181. @section zmq, azmq
  9182. Receive commands sent through a libzmq client, and forward them to
  9183. filters in the filtergraph.
  9184. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  9185. must be inserted between two video filters, @code{azmq} between two
  9186. audio filters.
  9187. To enable these filters you need to install the libzmq library and
  9188. headers and configure FFmpeg with @code{--enable-libzmq}.
  9189. For more information about libzmq see:
  9190. @url{http://www.zeromq.org/}
  9191. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  9192. receives messages sent through a network interface defined by the
  9193. @option{bind_address} option.
  9194. The received message must be in the form:
  9195. @example
  9196. @var{TARGET} @var{COMMAND} [@var{ARG}]
  9197. @end example
  9198. @var{TARGET} specifies the target of the command, usually the name of
  9199. the filter class or a specific filter instance name.
  9200. @var{COMMAND} specifies the name of the command for the target filter.
  9201. @var{ARG} is optional and specifies the optional argument list for the
  9202. given @var{COMMAND}.
  9203. Upon reception, the message is processed and the corresponding command
  9204. is injected into the filtergraph. Depending on the result, the filter
  9205. will send a reply to the client, adopting the format:
  9206. @example
  9207. @var{ERROR_CODE} @var{ERROR_REASON}
  9208. @var{MESSAGE}
  9209. @end example
  9210. @var{MESSAGE} is optional.
  9211. @subsection Examples
  9212. Look at @file{tools/zmqsend} for an example of a zmq client which can
  9213. be used to send commands processed by these filters.
  9214. Consider the following filtergraph generated by @command{ffplay}
  9215. @example
  9216. ffplay -dumpgraph 1 -f lavfi "
  9217. color=s=100x100:c=red [l];
  9218. color=s=100x100:c=blue [r];
  9219. nullsrc=s=200x100, zmq [bg];
  9220. [bg][l] overlay [bg+l];
  9221. [bg+l][r] overlay=x=100 "
  9222. @end example
  9223. To change the color of the left side of the video, the following
  9224. command can be used:
  9225. @example
  9226. echo Parsed_color_0 c yellow | tools/zmqsend
  9227. @end example
  9228. To change the right side:
  9229. @example
  9230. echo Parsed_color_1 c pink | tools/zmqsend
  9231. @end example
  9232. @c man end MULTIMEDIA FILTERS
  9233. @chapter Multimedia Sources
  9234. @c man begin MULTIMEDIA SOURCES
  9235. Below is a description of the currently available multimedia sources.
  9236. @section amovie
  9237. This is the same as @ref{movie} source, except it selects an audio
  9238. stream by default.
  9239. @anchor{movie}
  9240. @section movie
  9241. Read audio and/or video stream(s) from a movie container.
  9242. It accepts the following parameters:
  9243. @table @option
  9244. @item filename
  9245. The name of the resource to read (not necessarily a file; it can also be a
  9246. device or a stream accessed through some protocol).
  9247. @item format_name, f
  9248. Specifies the format assumed for the movie to read, and can be either
  9249. the name of a container or an input device. If not specified, the
  9250. format is guessed from @var{movie_name} or by probing.
  9251. @item seek_point, sp
  9252. Specifies the seek point in seconds. The frames will be output
  9253. starting from this seek point. The parameter is evaluated with
  9254. @code{av_strtod}, so the numerical value may be suffixed by an IS
  9255. postfix. The default value is "0".
  9256. @item streams, s
  9257. Specifies the streams to read. Several streams can be specified,
  9258. separated by "+". The source will then have as many outputs, in the
  9259. same order. The syntax is explained in the ``Stream specifiers''
  9260. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  9261. respectively the default (best suited) video and audio stream. Default
  9262. is "dv", or "da" if the filter is called as "amovie".
  9263. @item stream_index, si
  9264. Specifies the index of the video stream to read. If the value is -1,
  9265. the most suitable video stream will be automatically selected. The default
  9266. value is "-1". Deprecated. If the filter is called "amovie", it will select
  9267. audio instead of video.
  9268. @item loop
  9269. Specifies how many times to read the stream in sequence.
  9270. If the value is less than 1, the stream will be read again and again.
  9271. Default value is "1".
  9272. Note that when the movie is looped the source timestamps are not
  9273. changed, so it will generate non monotonically increasing timestamps.
  9274. @end table
  9275. It allows overlaying a second video on top of the main input of
  9276. a filtergraph, as shown in this graph:
  9277. @example
  9278. input -----------> deltapts0 --> overlay --> output
  9279. ^
  9280. |
  9281. movie --> scale--> deltapts1 -------+
  9282. @end example
  9283. @subsection Examples
  9284. @itemize
  9285. @item
  9286. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  9287. on top of the input labelled "in":
  9288. @example
  9289. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  9290. [in] setpts=PTS-STARTPTS [main];
  9291. [main][over] overlay=16:16 [out]
  9292. @end example
  9293. @item
  9294. Read from a video4linux2 device, and overlay it on top of the input
  9295. labelled "in":
  9296. @example
  9297. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  9298. [in] setpts=PTS-STARTPTS [main];
  9299. [main][over] overlay=16:16 [out]
  9300. @end example
  9301. @item
  9302. Read the first video stream and the audio stream with id 0x81 from
  9303. dvd.vob; the video is connected to the pad named "video" and the audio is
  9304. connected to the pad named "audio":
  9305. @example
  9306. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  9307. @end example
  9308. @end itemize
  9309. @c man end MULTIMEDIA SOURCES