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

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