FFMPEG-RESAMPLER(1)

🌸 FFMPEG-RESAMPLER(1) β€” the resampler page, but make it make sense 🌸

okay bestie, welcome to the ffmpeg-resampler(1) manual page 🫢 this is the one that covers the FFmpeg Resampler, and trust me, it's lowkey iconic once you know what everything does.


✨ DESCRIPTION ✨

So. The FFmpeg resampler is basically a high-level glow-up wrapper around the audio resampling utilities in libswresample. It's giving "let me handle the messy parts for you" πŸ’…

Specifically, it lets you:

  • do audio resampling
  • do audio channel layout rematrixing
  • convert audio format and packing layout

That's the whole vibe. Three things. Slay.


πŸŽ€ RESAMPLER OPTIONS πŸŽ€

The audio resampler supports these named options. Not a subset, not "the important ones" β€” all of them. Periodt.

Quick note on how you set them (this part matters, ngl): you can set options by specifying -option value in the FFmpeg tools, or option=value for the aresample filter, or by setting the value explicitly in the SwrContext options, or by using the libavutil/opt.h API if you're doing it programmatically. Four whole ways. Choose your fighter πŸ¦‹


  • uchl, used_chlayout β€” sets the used input channel layout. Default is unset. Heads up: this one is only used for special remapping, so don't come for it if it does nothing in your normal everyday situation πŸ™ˆ
  • isr, in_sample_rate β€” sets the input sample rate. Default value is 0.
  • osr, out_sample_rate β€” sets the output sample rate. Default value is 0.
  • isf, in_sample_fmt β€” specifies the input sample format. It's set by default to none.
  • osf, out_sample_fmt β€” specifies the output sample format. It's set by default to none.
  • tsf, internal_sample_fmt β€” sets the internal sample format. Default value is none. The cute part: this gets automatically chosen when it's not explicitly set ✨
  • ichl, in_chlayout and ochl, out_chlayout β€” set the input/output channel layout. For the required syntax, see the Channel Layout section in the ffmpeg-utils(1) manual. iykyk, go read that one too πŸ“–
  • clev, center_mix_level β€” sets the center mix level. It's a value expressed in deciBel, and it must be in the interval [-32,32].
  • slev, surround_mix_level β€” sets the surround mix level. Also expressed in deciBel, also must be in the interval [-32,32].
  • lfe_mix_level β€” sets the LFE mix into non-LFE level. It's used when there's an LFE input but no LFE output. Expressed in deciBel, must be in the interval [-32,32]. (Yes, same interval. No, that's not a typo. Three for three πŸ’€)
  • rmvol, rematrix_volume β€” sets the rematrix volume. Default value is 1.0.
  • rematrix_maxval β€” sets the maximum output value for rematrixing. This is the classic tradeoff: use it to prevent clipping vs. prevent volume reduction. A value of 1.0 prevents clipping.
  • flags, swr_flags β€” sets the flags used by the converter. Default value is 0. It supports this individual flag:
    • res β€” force resampling. This flag forces resampling to be used even when the input and output sample rates match. Iconic stubbornness, honestly.
  • dither_scale β€” sets the dither scale. Default value is 1.
  • dither_method β€” sets the dither method. Default value is 0. Supported values are:
    • rectangular β€” select rectangular dither
    • triangular β€” select triangular dither
    • triangular_hp β€” select triangular dither with high pass
    • lipshitz β€” select Lipshitz noise shaping dither.
    • shibata β€” select Shibata noise shaping dither.
    • low_shibata β€” select low Shibata noise shaping dither.
    • high_shibata β€” select high Shibata noise shaping dither.
    • f_weighted β€” select f-weighted noise shaping dither
    • modified_e_weighted β€” select modified-e-weighted noise shaping dither
    • improved_e_weighted β€” select improved-e-weighted noise shaping dither
  • resampler β€” sets the resampling engine. Default value is swr. Supported values:
    • swr β€” select the native SW Resampler. In this case, the filter options precision and cheby are not applicable.
    • soxr β€” select the SoX Resampler (where available). In this case, compensation, and the filter options filter_size, phase_shift, exact_rational, filter_type & kaiser_beta, are not applicable.
  • filter_size β€” for swr only. Sets the resampling filter size. Default value is 32.
  • phase_shift β€” for swr only. Sets the resampling phase shift. Default value is 10, and it must be in the interval [0,30].
  • linear_interp β€” uses linear interpolation when enabled (and it is enabled by default). Disable it if you want to preserve speed instead of quality when exact_rational fails. Pick your priorities bestie πŸ”₯
  • exact_rational β€” for swr only. When enabled, it tries to use exact phase_count based on input and output sample rate. However β€” and this is the important bit β€” if that ends up larger than 1 << phase_shift, the phase_count will be 1 << phase_shift as a fallback. Default is enabled.
  • cutoff β€” sets the cutoff frequency ratio (swr: 6dB point; soxr: 0dB point). Must be a float value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr (which, with a sample-rate of 44100, preserves the entire audio band to 20kHz). Very demure, very mindful πŸŽ€
  • precision β€” for soxr only. The precision in bits to which the resampled signal will be calculated. The default value of 20 (which, with suitable dithering, is appropriate for a destination bit-depth of 16) gives SoX's 'High Quality'; a value of 28 gives SoX's 'Very High Quality'.
  • cheby β€” for soxr only. Selects passband rolloff none (Chebyshev) & higher-precision approximation for 'irrational' ratios. Default value is 0.
  • async β€” for swr only. Simple 1 parameter audio sync to timestamps using stretching, squeezing, filling and trimming. Setting this to 1 will enable filling and trimming; larger values represent the maximum amount in samples that the data may be stretched or squeezed for each second. Default value is 0, so no compensation is applied to make the samples match the audio timestamps.
  • first_pts β€” for swr only. Assume the first pts should be this value. The time unit is 1 / sample rate. This allows for padding/trimming at the start of the stream. By default, no assumption is made about the first frame's expected pts, so no padding or trimming is done. Example time: this could be set to 0 to pad the beginning with silence if an audio stream starts after the video stream, or to trim any samples with a negative pts due to encoder delay. Both valid, both useful 🫢
  • min_comp β€” for swr only. Sets the minimum difference between timestamps and audio data (in seconds) to trigger stretching/squeezing/filling or trimming of the data to make it match the timestamps. The default is that stretching/squeezing/filling and trimming is disabled (min_comp = FLT_MAX).
  • min_hard_comp β€” for swr only. Sets the minimum difference between timestamps and audio data (in seconds) to trigger adding/dropping samples to make it match the timestamps. This option is effectively a threshold to select between hard (trim/fill) and soft (squeeze/stretch) compensation. Note that all compensation is by default disabled through min_comp. The default here is 0.1.
  • comp_duration β€” for swr only. Sets the duration (in seconds) over which data is stretched/squeezed to make it match the timestamps. Must be a non-negative double float value, default value is 1.0.
  • max_soft_comp β€” for swr only. Sets the maximum factor by which data is stretched/squeezed to make it match the timestamps. Must be a non-negative double float value, default value is 0.
  • matrix_encoding β€” selects matrixed stereo encoding. It accepts the following values:
    • none β€” select none
    • dolby β€” select Dolby
    • dplii β€” select Dolby Pro Logic II

Default value is none.

  • filter_type β€” for swr only. Selects the resampling filter type. This only affects resampling operations. It accepts the following values:
    • cubic β€” select cubic
    • blackman_nuttall β€” select Blackman Nuttall windowed sinc
    • kaiser β€” select Kaiser windowed sinc
  • kaiser_beta β€” for swr only. Sets the Kaiser window beta value. Must be a double float value in the interval [2,16], default value is 9.
  • output_sample_bits β€” for swr only. Sets the number of used output sample bits for dithering. Must be an integer in the interval [0,64], default value is 0, which means it's not used.
fr fr, the swr-only and soxr-only labels are not decoration β€” they tell you which engine actually reads that option. Don't set precision on swr and then wonder why nothing happened πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

Go read them, bestie, they're all connected. It's a whole ecosystem πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

The FFmpeg developers.

For details about the authorship, see the Git history of the project (https://git.ffmpeg.org/ffmpeg), e.g. by typing the command git log in the FFmpeg source directory, or browsing the online repository at https://git.ffmpeg.org/ffmpeg.

Maintainers for the specific components are listed in the file MAINTAINERS in the source code tree.


and that's the whole page, bestie ✨ we started with the header FFMPEG-RESAMPLER(1) and we're ending right back on it β€” that's the footer, same name, no cap. main character energy from top to bottom πŸ’…πŸŽ€