ffmpeg-resampler.html 13 KB

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