星火直播PC
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.

ffmpeg-resampler.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <title>FFmpeg documentation</title>
  7. <link rel="stylesheet" href="bootstrap.min.css" />
  8. <link rel="stylesheet" href="style.min.css" />
  9. <meta name="description" content="FFmpeg Resampler Documentation: ">
  10. <meta name="keywords" content="FFmpeg documentation : FFmpeg Resampler ">
  11. <meta name="Generator" content="texi2html 5.0">
  12. <!-- Created on March 9, 2020 by texi2html 5.0 -->
  13. <!--
  14. texi2html was written by:
  15. Lionel Cons <Lionel.Cons@cern.ch> (original author)
  16. Karl Berry <karl@freefriends.org>
  17. Olaf Bachmann <obachman@mathematik.uni-kl.de>
  18. and many others.
  19. Maintained by: Many creative people.
  20. Send bugs and suggestions to <texi2html-bug@nongnu.org>
  21. -->
  22. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  23. </head>
  24. <body>
  25. <div class="container">
  26. <h1 class="titlefont">FFmpeg Resampler Documentation</h1>
  27. <hr>
  28. <a name="SEC_Top"></a>
  29. <a name="SEC_Contents"></a>
  30. <h1>Table of Contents</h1>
  31. <div class="contents">
  32. <ul class="no-bullet">
  33. <li><a name="toc-Description" href="#Description">1 Description</a></li>
  34. <li><a name="toc-Resampler-Options" href="#Resampler-Options">2 Resampler Options</a></li>
  35. <li><a name="toc-See-Also" href="#See-Also">3 See Also</a></li>
  36. <li><a name="toc-Authors" href="#Authors">4 Authors</a></li>
  37. </ul>
  38. </div>
  39. <hr size="6">
  40. <a name="Description"></a>
  41. <h1 class="chapter"><a href="ffmpeg-resampler.html#toc-Description">1 Description</a></h1>
  42. <p>The FFmpeg resampler provides a high-level interface to the
  43. libswresample library audio resampling utilities. In particular it
  44. allows one to perform audio resampling, audio channel layout rematrixing,
  45. and convert audio format and packing layout.
  46. </p>
  47. <a name="Resampler-Options"></a>
  48. <h1 class="chapter"><a href="ffmpeg-resampler.html#toc-Resampler-Options">2 Resampler Options</a></h1>
  49. <p>The audio resampler supports the following named options.
  50. </p>
  51. <p>Options may be set by specifying -<var>option</var> <var>value</var> in the
  52. FFmpeg tools, <var>option</var>=<var>value</var> for the aresample filter,
  53. by setting the value explicitly in the
  54. <code>SwrContext</code> options or using the &lsquo;<tt>libavutil/opt.h</tt>&rsquo; API for
  55. programmatic use.
  56. </p>
  57. <dl compact="compact">
  58. <dt>&lsquo;<samp>ich, in_channel_count</samp>&rsquo;</dt>
  59. <dd><p>Set the number of input channels. Default value is 0. Setting this
  60. value is not mandatory if the corresponding channel layout
  61. &lsquo;<samp>in_channel_layout</samp>&rsquo; is set.
  62. </p>
  63. </dd>
  64. <dt>&lsquo;<samp>och, out_channel_count</samp>&rsquo;</dt>
  65. <dd><p>Set the number of output channels. Default value is 0. Setting this
  66. value is not mandatory if the corresponding channel layout
  67. &lsquo;<samp>out_channel_layout</samp>&rsquo; is set.
  68. </p>
  69. </dd>
  70. <dt>&lsquo;<samp>uch, used_channel_count</samp>&rsquo;</dt>
  71. <dd><p>Set the number of used input channels. Default value is 0. This option is
  72. only used for special remapping.
  73. </p>
  74. </dd>
  75. <dt>&lsquo;<samp>isr, in_sample_rate</samp>&rsquo;</dt>
  76. <dd><p>Set the input sample rate. Default value is 0.
  77. </p>
  78. </dd>
  79. <dt>&lsquo;<samp>osr, out_sample_rate</samp>&rsquo;</dt>
  80. <dd><p>Set the output sample rate. Default value is 0.
  81. </p>
  82. </dd>
  83. <dt>&lsquo;<samp>isf, in_sample_fmt</samp>&rsquo;</dt>
  84. <dd><p>Specify the input sample format. It is set by default to <code>none</code>.
  85. </p>
  86. </dd>
  87. <dt>&lsquo;<samp>osf, out_sample_fmt</samp>&rsquo;</dt>
  88. <dd><p>Specify the output sample format. It is set by default to <code>none</code>.
  89. </p>
  90. </dd>
  91. <dt>&lsquo;<samp>tsf, internal_sample_fmt</samp>&rsquo;</dt>
  92. <dd><p>Set the internal sample format. Default value is <code>none</code>.
  93. This will automatically be chosen when it is not explicitly set.
  94. </p>
  95. </dd>
  96. <dt>&lsquo;<samp>icl, in_channel_layout</samp>&rsquo;</dt>
  97. <dt>&lsquo;<samp>ocl, out_channel_layout</samp>&rsquo;</dt>
  98. <dd><p>Set the input/output channel layout.
  99. </p>
  100. <p>See <a href="ffmpeg-utils.html#channel-layout-syntax">(ffmpeg-utils)the Channel Layout section in the ffmpeg-utils(1) manual</a>
  101. for the required syntax.
  102. </p>
  103. </dd>
  104. <dt>&lsquo;<samp>clev, center_mix_level</samp>&rsquo;</dt>
  105. <dd><p>Set the center mix level. It is a value expressed in deciBel, and must be
  106. in the interval [-32,32].
  107. </p>
  108. </dd>
  109. <dt>&lsquo;<samp>slev, surround_mix_level</samp>&rsquo;</dt>
  110. <dd><p>Set the surround mix level. It is a value expressed in deciBel, and must
  111. be in the interval [-32,32].
  112. </p>
  113. </dd>
  114. <dt>&lsquo;<samp>lfe_mix_level</samp>&rsquo;</dt>
  115. <dd><p>Set LFE mix into non LFE level. It is used when there is a LFE input but no
  116. LFE output. It is a value expressed in deciBel, and must
  117. be in the interval [-32,32].
  118. </p>
  119. </dd>
  120. <dt>&lsquo;<samp>rmvol, rematrix_volume</samp>&rsquo;</dt>
  121. <dd><p>Set rematrix volume. Default value is 1.0.
  122. </p>
  123. </dd>
  124. <dt>&lsquo;<samp>rematrix_maxval</samp>&rsquo;</dt>
  125. <dd><p>Set maximum output value for rematrixing.
  126. This can be used to prevent clipping vs. preventing volume reduction.
  127. A value of 1.0 prevents clipping.
  128. </p>
  129. </dd>
  130. <dt>&lsquo;<samp>flags, swr_flags</samp>&rsquo;</dt>
  131. <dd><p>Set flags used by the converter. Default value is 0.
  132. </p>
  133. <p>It supports the following individual flags:
  134. </p><dl compact="compact">
  135. <dt>&lsquo;<samp>res</samp>&rsquo;</dt>
  136. <dd><p>force resampling, this flag forces resampling to be used even when the
  137. input and output sample rates match.
  138. </p></dd>
  139. </dl>
  140. </dd>
  141. <dt>&lsquo;<samp>dither_scale</samp>&rsquo;</dt>
  142. <dd><p>Set the dither scale. Default value is 1.
  143. </p>
  144. </dd>
  145. <dt>&lsquo;<samp>dither_method</samp>&rsquo;</dt>
  146. <dd><p>Set dither method. Default value is 0.
  147. </p>
  148. <p>Supported values:
  149. </p><dl compact="compact">
  150. <dt>&lsquo;<samp>rectangular</samp>&rsquo;</dt>
  151. <dd><p>select rectangular dither
  152. </p></dd>
  153. <dt>&lsquo;<samp>triangular</samp>&rsquo;</dt>
  154. <dd><p>select triangular dither
  155. </p></dd>
  156. <dt>&lsquo;<samp>triangular_hp</samp>&rsquo;</dt>
  157. <dd><p>select triangular dither with high pass
  158. </p></dd>
  159. <dt>&lsquo;<samp>lipshitz</samp>&rsquo;</dt>
  160. <dd><p>select Lipshitz noise shaping dither.
  161. </p></dd>
  162. <dt>&lsquo;<samp>shibata</samp>&rsquo;</dt>
  163. <dd><p>select Shibata noise shaping dither.
  164. </p></dd>
  165. <dt>&lsquo;<samp>low_shibata</samp>&rsquo;</dt>
  166. <dd><p>select low Shibata noise shaping dither.
  167. </p></dd>
  168. <dt>&lsquo;<samp>high_shibata</samp>&rsquo;</dt>
  169. <dd><p>select high Shibata noise shaping dither.
  170. </p></dd>
  171. <dt>&lsquo;<samp>f_weighted</samp>&rsquo;</dt>
  172. <dd><p>select f-weighted noise shaping dither
  173. </p></dd>
  174. <dt>&lsquo;<samp>modified_e_weighted</samp>&rsquo;</dt>
  175. <dd><p>select modified-e-weighted noise shaping dither
  176. </p></dd>
  177. <dt>&lsquo;<samp>improved_e_weighted</samp>&rsquo;</dt>
  178. <dd><p>select improved-e-weighted noise shaping dither
  179. </p>
  180. </dd>
  181. </dl>
  182. </dd>
  183. <dt>&lsquo;<samp>resampler</samp>&rsquo;</dt>
  184. <dd><p>Set resampling engine. Default value is swr.
  185. </p>
  186. <p>Supported values:
  187. </p><dl compact="compact">
  188. <dt>&lsquo;<samp>swr</samp>&rsquo;</dt>
  189. <dd><p>select the native SW Resampler; filter options precision and cheby are not
  190. applicable in this case.
  191. </p></dd>
  192. <dt>&lsquo;<samp>soxr</samp>&rsquo;</dt>
  193. <dd><p>select the SoX Resampler (where available); compensation, and filter options
  194. filter_size, phase_shift, exact_rational, filter_type &amp; kaiser_beta, are not
  195. applicable in this case.
  196. </p></dd>
  197. </dl>
  198. </dd>
  199. <dt>&lsquo;<samp>filter_size</samp>&rsquo;</dt>
  200. <dd><p>For swr only, set resampling filter size, default value is 32.
  201. </p>
  202. </dd>
  203. <dt>&lsquo;<samp>phase_shift</samp>&rsquo;</dt>
  204. <dd><p>For swr only, set resampling phase shift, default value is 10, and must be in
  205. the interval [0,30].
  206. </p>
  207. </dd>
  208. <dt>&lsquo;<samp>linear_interp</samp>&rsquo;</dt>
  209. <dd><p>Use linear interpolation when enabled (the default). Disable it if you want
  210. to preserve speed instead of quality when exact_rational fails.
  211. </p>
  212. </dd>
  213. <dt>&lsquo;<samp>exact_rational</samp>&rsquo;</dt>
  214. <dd><p>For swr only, when enabled, try to use exact phase_count based on input and
  215. output sample rate. However, if it is larger than <code>1 &lt;&lt; phase_shift</code>,
  216. the phase_count will be <code>1 &lt;&lt; phase_shift</code> as fallback. Default is enabled.
  217. </p>
  218. </dd>
  219. <dt>&lsquo;<samp>cutoff</samp>&rsquo;</dt>
  220. <dd><p>Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float
  221. value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr
  222. (which, with a sample-rate of 44100, preserves the entire audio band to 20kHz).
  223. </p>
  224. </dd>
  225. <dt>&lsquo;<samp>precision</samp>&rsquo;</dt>
  226. <dd><p>For soxr only, the precision in bits to which the resampled signal will be
  227. calculated. The default value of 20 (which, with suitable dithering, is
  228. appropriate for a destination bit-depth of 16) gives SoX&rsquo;s &rsquo;High Quality&rsquo;; a
  229. value of 28 gives SoX&rsquo;s &rsquo;Very High Quality&rsquo;.
  230. </p>
  231. </dd>
  232. <dt>&lsquo;<samp>cheby</samp>&rsquo;</dt>
  233. <dd><p>For soxr only, selects passband rolloff none (Chebyshev) &amp; higher-precision
  234. approximation for &rsquo;irrational&rsquo; ratios. Default value is 0.
  235. </p>
  236. </dd>
  237. <dt>&lsquo;<samp>async</samp>&rsquo;</dt>
  238. <dd><p>For swr only, simple 1 parameter audio sync to timestamps using stretching,
  239. squeezing, filling and trimming. Setting this to 1 will enable filling and
  240. trimming, larger values represent the maximum amount in samples that the data
  241. may be stretched or squeezed for each second.
  242. Default value is 0, thus no compensation is applied to make the samples match
  243. the audio timestamps.
  244. </p>
  245. </dd>
  246. <dt>&lsquo;<samp>first_pts</samp>&rsquo;</dt>
  247. <dd><p>For swr only, assume the first pts should be this value. The time unit is 1 / sample rate.
  248. This allows for padding/trimming at the start of stream. By default, no
  249. assumption is made about the first frame&rsquo;s expected pts, so no padding or
  250. trimming is done. For example, this could be set to 0 to pad the beginning with
  251. silence if an audio stream starts after the video stream or to trim any samples
  252. with a negative pts due to encoder delay.
  253. </p>
  254. </dd>
  255. <dt>&lsquo;<samp>min_comp</samp>&rsquo;</dt>
  256. <dd><p>For swr only, set the minimum difference between timestamps and audio data (in
  257. seconds) to trigger stretching/squeezing/filling or trimming of the
  258. data to make it match the timestamps. The default is that
  259. stretching/squeezing/filling and trimming is disabled
  260. (&lsquo;<samp>min_comp</samp>&rsquo; = <code>FLT_MAX</code>).
  261. </p>
  262. </dd>
  263. <dt>&lsquo;<samp>min_hard_comp</samp>&rsquo;</dt>
  264. <dd><p>For swr only, set the minimum difference between timestamps and audio data (in
  265. seconds) to trigger adding/dropping samples to make it match the
  266. timestamps. This option effectively is a threshold to select between
  267. hard (trim/fill) and soft (squeeze/stretch) compensation. Note that
  268. all compensation is by default disabled through &lsquo;<samp>min_comp</samp>&rsquo;.
  269. The default is 0.1.
  270. </p>
  271. </dd>
  272. <dt>&lsquo;<samp>comp_duration</samp>&rsquo;</dt>
  273. <dd><p>For swr only, set duration (in seconds) over which data is stretched/squeezed
  274. to make it match the timestamps. Must be a non-negative double float value,
  275. default value is 1.0.
  276. </p>
  277. </dd>
  278. <dt>&lsquo;<samp>max_soft_comp</samp>&rsquo;</dt>
  279. <dd><p>For swr only, set maximum factor by which data is stretched/squeezed to make it
  280. match the timestamps. Must be a non-negative double float value, default value
  281. is 0.
  282. </p>
  283. </dd>
  284. <dt>&lsquo;<samp>matrix_encoding</samp>&rsquo;</dt>
  285. <dd><p>Select matrixed stereo encoding.
  286. </p>
  287. <p>It accepts the following values:
  288. </p><dl compact="compact">
  289. <dt>&lsquo;<samp>none</samp>&rsquo;</dt>
  290. <dd><p>select none
  291. </p></dd>
  292. <dt>&lsquo;<samp>dolby</samp>&rsquo;</dt>
  293. <dd><p>select Dolby
  294. </p></dd>
  295. <dt>&lsquo;<samp>dplii</samp>&rsquo;</dt>
  296. <dd><p>select Dolby Pro Logic II
  297. </p></dd>
  298. </dl>
  299. <p>Default value is <code>none</code>.
  300. </p>
  301. </dd>
  302. <dt>&lsquo;<samp>filter_type</samp>&rsquo;</dt>
  303. <dd><p>For swr only, select resampling filter type. This only affects resampling
  304. operations.
  305. </p>
  306. <p>It accepts the following values:
  307. </p><dl compact="compact">
  308. <dt>&lsquo;<samp>cubic</samp>&rsquo;</dt>
  309. <dd><p>select cubic
  310. </p></dd>
  311. <dt>&lsquo;<samp>blackman_nuttall</samp>&rsquo;</dt>
  312. <dd><p>select Blackman Nuttall windowed sinc
  313. </p></dd>
  314. <dt>&lsquo;<samp>kaiser</samp>&rsquo;</dt>
  315. <dd><p>select Kaiser windowed sinc
  316. </p></dd>
  317. </dl>
  318. </dd>
  319. <dt>&lsquo;<samp>kaiser_beta</samp>&rsquo;</dt>
  320. <dd><p>For swr only, set Kaiser window beta value. Must be a double float value in the
  321. interval [2,16], default value is 9.
  322. </p>
  323. </dd>
  324. <dt>&lsquo;<samp>output_sample_bits</samp>&rsquo;</dt>
  325. <dd><p>For swr only, set number of used output sample bits for dithering. Must be an integer in the
  326. interval [0,64], default value is 0, which means it&rsquo;s not used.
  327. </p>
  328. </dd>
  329. </dl>
  330. <a name="See-Also"></a>
  331. <h1 class="chapter"><a href="ffmpeg-resampler.html#toc-See-Also">3 See Also</a></h1>
  332. <p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>,
  333. <a href="libswresample.html">libswresample</a>
  334. </p>
  335. <a name="Authors"></a>
  336. <h1 class="chapter"><a href="ffmpeg-resampler.html#toc-Authors">4 Authors</a></h1>
  337. <p>The FFmpeg developers.
  338. </p>
  339. <p>For details about the authorship, see the Git history of the project
  340. (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
  341. <code>git log</code> in the FFmpeg source directory, or browsing the
  342. online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
  343. </p>
  344. <p>Maintainers for the specific components are listed in the file
  345. &lsquo;<tt>MAINTAINERS</tt>&rsquo; in the source code tree.
  346. </p>
  347. </div>
  348. </body>
  349. </html>