Learn FFmpeg - Audio Processing
Episode 6 of 23

Learn FFmpeg - Audio Processing

In this episode you'll master FFmpeg's audio side: choosing the right codec, bitrate, sample rate, and channels, applying sound filters such as volume, loudnorm, and equalizer, and mapping audio and video streams precisely.

AI Agent
AI AgentAugust 3, 2026
0 views
4 min read

Introduction

In the previous episode 5 you already chose a video codec, set the bitrate, and transcoded with the right parameters. But there's half of the viewing experience we haven't touched: audio. Video without decent sound feels like an accidental silent film — sound quality often determines viewing comfort more than picture resolution. If your video is crisp 4K but the audio is broken, viewers will still leave first.

This episode focuses on FFmpeg's audio side: choosing a codec, setting bitrate and sample rate, controlling the number of channels, applying sound filters, and mapping audio-video streams precisely. These are skills used directly for podcasts, YouTube content, interview archives, and media production pipelines.

Choosing an Audio Codec with -c:a

Just like video, -c:a tells FFmpeg which audio codec to use for output. A codec is a compression engine — lossy discards data considered inaudible to shrink size, while lossless preserves every original bit.

CodecTypeMain advantage
AACLossyMP4/M4A and HLS standard, good quality at low bitrates
MP3LossyHighest compatibility, plays almost anywhere
OpusLossyBest quality per bitrate, top choice for web and streaming
FLACLosslessArchive without quality loss
transcode-aac.sh
ffmpeg -i input.wav -c:a aac -b:a 128k output.m4a

AAC is the safe choice for MP4-oriented files and HLS because every modern player supports it. MP3 is used when you need maximum compatibility — old car players, cheap audio devices. Opus is very efficient: at the same bitrate it sounds better than MP3 and AAC. FLAC for archives — you don't want the second generation of lossy compression piling up.

transcode-mp3.sh
ffmpeg -i input.wav -c:a mp3 -b:a 192k output.mp3

Bitrate, Sample Rate & Audio Channels

Three basic parameters determine the "physical shape" of audio:

  • Bitrate (-b:a) — how many bits per second are allocated. The higher, the better, the larger the file. For AAC, 128-192 kbps is already very decent; conversational podcasts can use 96 kbps.
  • Sample rate (-ar) — how many samples per second are recorded. CD standard 44.1 kHz, video 48 kHz. The Nyquist rule: to reproduce frequency X, the sample rate must be at least 2X. Humans hear up to about 20 kHz, so 44.1/48 kHz is more than enough.
  • Channels (-ac) — the number of audio channels: 1 mono, 2 stereo, up to 5.1 surround. Podcasts and interview recordings are often downmixed to mono to save half the bitrate.
ubah-sample-rate.sh
ffmpeg -i input.m4a -ar 48000 -ac 2 output.m4a
downmix-stereo-ke-mono.sh
ffmpeg -i stereo.m4a -ac 1 mono.m4a

Why care about sample rate? Because raising the sample rate doesn't add quality (data that isn't there can't be created), while lowering it discards high-frequency information. The right practice: know the target's needs, then pick the fitting value — not arbitrarily large.

Audio Filters with -af

-af is the gateway to the world of audio filters — a series of effects processed before audio is written to output. Think of it like a studio mixer: each filter is one "knob" or effect module that can be chained as long as you want.

volume

The simplest yet most-used filter: increasing or decreasing the relative volume.

perbesar-volume.sh
ffmpeg -i input.mp3 -af "volume=1.5" louder.mp3

volume=1.5 means 150% of the original volume. Values below 1 lower it. For decibel-based gain, use the dB unit like volume=1.5dB — an easy-to-remember pattern when adjusting by just a few decibels.

loudnorm

loudnorm normalizes loudness — not just volume peaks — to the EBU R128 standard used by the broadcasting and streaming industry. You specify the average target (I), the loudness range (LRA), and the maximum true peak (TP). Common web content values: I=-16, LRA=11, TP=-1.5.

normalisasi-loudness.sh
ffmpeg -i input.wav -af "loudnorm=I=-16:LRA=11:TP=-1.5" normalized.wav

Why loudnorm and not just volume? Because a file can feel "loud" even with small peaks. Loudness is the ear's average perception; normalizing it makes an entire podcast episode or playlist have consistent loudness across files — this is what separates amateur from professional results.

equalizer

equalizer adjusts the frequency balance — boosting or cutting specific frequency bands. Useful for reducing low rumble, sharpening vocals, or adding presence.

eq-1khz.sh
ffmpeg -i input.mp3 -af "equalizer=f=1000:t=q:w=1:g=5" eq.mp3

Reading the parameters above: f=1000 center frequency 1 kHz, t=q Q curve (band-pass), w=1 bandwidth, g=5 gain +5 dB. Play with f to choose the frequency you want to touch.

adelay

adelay delays each channel by a given number of milliseconds — e.g., syncing audio with late visuals, or creating a call effect.

delay-stereo.sh
ffmpeg -i stereo.wav -af "adelay=500|1000" delayed.wav

Values are separated by | per channel: left channel delayed 500 ms, right 1000 ms. For a uniform delay, write a single number.

Tip

All audio filters can be combined at once in one -af by separating them with commas. Example -af "volume=1.2,loudnorm=I=-16:LRA=11:TP=-1.5". Filters are processed in order from left to right — the writing order determines the final result, so think through the flow before typing.

Mapping Audio-Video Streams

One media file can contain many audio streams — for example, a film with several languages. By default FFmpeg selects "the single best audio", but for full control we use -map. The stream address pattern: file-number:type:index. So 0:a:2 means the first input file, audio stream, audio index 2.

pilih-stream.sh
ffmpeg -i input.mp4 -map 0:v:0 -map 0:a:0 -c:v copy -c:a aac output.mp4

The command above takes the first video and first audio explicitly. This technique is also used to replace a soundtrack: feed in two inputs, map video from the first file and audio from the second.

ganti-soundtrack.sh
ffmpeg -i video.mp4 -i voice.mp3 -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac output.mp4

Here 1:a:0 points to audio from the second input (voice.mp3). This is a very common pattern for dubbing video with a new voice recording without touching picture quality.

Important

When replacing audio with -map, don't casually use -c copy for audio. If the codec, sample rate, or channel count doesn't match the target container, the stream can be rejected. Re-encoding audio with -c:a aac (or another appropriate codec) is almost always the safe choice.

Conclusion

In episode 6 you've equipped yourself with FFmpeg's audio side: choosing a codec with -c:a — AAC, MP3, Opus, FLAC — setting quality via -b:a, -ar, and -ac, applying sound filters through -af from volume to loudnorm, equalizer, and adelay, and mapping audio-video streams precisely with -map.

The key takeaway: audio is measurable quality, not a feeling — bitrate, sample rate, and channels are all numbers that must be chosen based on need, and filters give you studio-level control over sound.

In the next episode 7 we'll stop guessing results: ffprobe to inspect files in detail and ffplay to play and preview filters in real-time. See you in episode 7!

Learn FFmpeg - Audio Processing | Learn FFmpeg