ffmpeg-resampler.html 14 KB

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