ffmpeg-resampler
Resample audio to a different format
SYNOPSIS
ffmpeg-resampler [global options] -i input [audio options] output
PARAMETERS
-i input
Specify input file or '-' for stdin
-ar[:stream_specifier] rate (Hz)
Set output sample rate (e.g., 44100, 48000)
-ac[:stream_specifier] channels
Set output channels (e.g., 1 for mono, 2 for stereo)
-acodec[:stream_specifier] codec
Set output audio codec (e.g., pcm_s16le, flac)
-sample_fmt[:stream_specifier] fmt
Set output sample format (e.g., s16, fltp)
-f[:stream_specifier] fmt
Set output container format (e.g., wav, raw)
-filter:a[:stream_specifier] filtergraph
Set audio filtergraph (e.g., aresample=48000)
-y
Overwrite output files without asking
-n
Do not overwrite output files
-loglevel[:stream_specifier] level
Set logging level (quiet, error, info, verbose, debug)
-h, --help
Show help and exit
DESCRIPTION
The ffmpeg-resampler is a lightweight command-line tool from the FFmpeg project designed specifically for high-quality audio resampling. It changes the sample rate, channel layout, or sample format of audio streams using the efficient libswresample library, which supports advanced algorithms like soxr for minimal aliasing and distortion.
It reads audio from an input file or stdin (via -i), decodes it if necessary using libavcodec, resamples, and encodes/writes to an output file or stdout. Ideal for batch processing or scripts needing precise audio rate conversion without the full ffmpeg overhead.
Supports common formats like WAV, FLAC, MP3, and raw PCM. It handles single audio streams, automatic channel mapping, and dithering options. Output quality rivals professional tools, with configurable filters for sinc-based interpolation. Use it to upsample low-rate audio for modern hardware or downsample for compatibility.
Limited to audio-only processing, no video or complex muxing. Perfect for audio engineers, podcast producers, or developers integrating resampling in pipelines.
CAVEATS
Handles only single audio streams; no video or multi-stream support. Requires FFmpeg 4.4+. May need codec libraries for compressed input/output. Default resampler is soxr; quality settings via -swresample_flags.
EXAMPLE USAGE
Resample to 48kHz stereo WAV:
ffmpeg-resampler -i input.flac -ar 48000 -ac 2 output.wav
Raw PCM stdin to stdout:
cat input.raw | ffmpeg-resampler -f s16le -ar 44100 -ac 1 -f s16le - > output.raw
RESAMPLER OPTIONS
Advanced tuning via -af aresample=resampler=soxr:precision=28:dither_scale=0 or -swresample_flags sowxr for high-precision sinc interpolation.
HISTORY
Introduced in FFmpeg 4.4 'Shaman' (April 2021) to provide a minimal, focused tool for resampling using libswresample. Developed for efficiency in scripts and CI/CD pipelines, reducing dependencies on full FFmpeg for simple tasks.


