ffmpeg-resampler.html 13 KB

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