Extract and Add Audio
Extract audio from video, replace audio tracks, adjust volume, mix streams, and convert between audio formats.
How FFmpeg Handles Audio
A video file typically contains at least two streams: one video and one audio. FFmpeg lets you work with each stream independently — you can extract the audio, replace it, adjust the volume, or mix in additional tracks without touching the video at all.
The key flags for audio work:
-c:a— set the audio codec-an— remove all audio streams-vn— remove all video streams (audio-only output)-af— apply audio filters (like-vffor video)-map— select which streams to include in the output
Extracting Audio from Video
Extract without re-encoding
If you just need the audio track in its original format:
The -vn flag drops the video stream. Combined with -c:a copy, the audio is extracted instantly with zero quality loss. Use the file extension that matches the audio codec in the source — .aac for AAC, .mp3 for MP3, .opus for Opus.
Tip: Not sure which audio codec the file uses? Run ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of csv=p=0 input.mp4 to find out.
Extract and convert to MP3
This re-encodes the audio to MP3 at 192 kbps. Common bitrates: 128k (smaller, acceptable quality), 192k (good balance), 320k (maximum MP3 quality).
Extract to WAV (uncompressed)
WAV files are uncompressed and large, but useful when you need to bring the audio into an editor like Audacity or Adobe Audition for further processing.
Removing Audio from Video
Sometimes you need a silent video — for a muted autoplay embed, a GIF-like loop, or to replace the audio entirely:
The -an flag strips all audio. Combined with -c:v copy, the video passes through untouched.
Replacing Audio
To swap in a new audio track — like background music or a voiceover — use two inputs with the -map flag:
Breaking it down:
-map 0:v— take the video stream from the first input (video.mp4)-map 1:a— take the audio stream from the second input (new-audio.mp3)-shortest— stop when the shorter input ends (so the output does not have trailing silence or video)
Adjusting Volume
The volume audio filter adjusts loudness:
Double the volume
Halve the volume
Set volume in decibels
Normalize loudness
If you are stitching clips from different sources, their volumes will be inconsistent. The loudnorm filter normalizes them to broadcast standards:
This targets -16 LUFS (the standard for YouTube and most platforms) with a true peak of -1.5 dB.
Mixing Audio Tracks
To layer background music under a video's existing audio (like adding a soundtrack to a vlog), use the amix filter:
This keeps the original audio at full volume, brings the music to 30% volume, and mixes them together. The duration=first option stops when the video's audio ends.
Common Audio Codecs
| Codec | FFmpeg Encoder | Best For |
|---|---|---|
| AAC | aac | MP4 video (default), streaming |
| MP3 | libmp3lame | Audio-only files, universal compatibility |
| Opus | libopus | WebM video, voice calls, best quality per bit |
| FLAC | flac | Lossless archiving |
Key Takeaways
- Use
-vn -c:a copyto extract audio instantly without quality loss - Use
-an -c:v copyto strip audio from a video - Use
-mapto pick which streams come from which input when replacing audio - The
volumefilter adjusts loudness;loudnormnormalizes across clips - Use
amixwith volume controls to layer music under speech
Try This With FFmpeg Micro
Instead of running FFmpeg locally, you can use FFmpeg Micro's API to process videos in the cloud. No installation required.