FFmpeg audio: extract, convert, replace, merge, trim and normalise
FFmpeg handles the usual audio jobs in one command each. Using the sound from our test clip, extracting with -c copy took the AAC track out unchanged as a 1.47 MB file. Loudness normalising moved the integrated loudness from -16.8 LUFS to -15.9 LUFS in one pass and -16.0 LUFS in two passes.
What to choose
Use -c copy when the audio is already in the format you want: nothing is re-encoded and nothing is lost. Re-encode when you need another format or a lower bit rate.
| Job | Command (shortened) | What we measured |
|---|---|---|
| Extract, no re-encode | -i tos.mp4 -vn -c:a copy tos_audio.m4a | 1.47 MB, codec aac, 60.0 s |
| Extract to MP3 | -vn -c:a libmp3lame -q:a 2 | 1.32 MB, 175.6 kbit/s |
| Extract to WAV | -vn -c:a pcm_s16le | 10.58 MB, 1411.2 kbit/s |
Extract audio from a video
-vn drops the video. With -c:a copy FFmpeg writes the original AAC stream into an M4A file.
ffmpeg -i tos.mp4 -vn -c:a copy tos_audio.m4affmpeg -i tos.mp4 -vn -c:a libmp3lame -q:a 2 tos_audio.mp3ffmpeg -i tos.mp4 -vn -c:a pcm_s16le tos_audio.wavCopy only works if the target container accepts the codec. We tried -c:a copy into an MP3 file from this AAC track. It failed with "[mp3 @ ...] Invalid audio stream. Exactly one MP3 audio stream is required." and then "Conversion failed!"
ffmpeg -i tos.mp4 -vn -c:a copy bad.mp3WAV to MP3
Set a fixed bit rate with -b:a, or a variable quality with -q:a (a lower number is higher quality). All three were made from the 10.58 MB WAV above.
ffmpeg -i tos_audio.wav -c:a libmp3lame -b:a 192k wav192.mp3| Setting | File size | Measured bit rate |
|---|---|---|
| -b:a 192k | 1.44 MB | 192.2 kbit/s |
| -q:a 2 | 1.32 MB | 175.4 kbit/s |
| -b:a 128k | 960.9 kB | 128.1 kbit/s |
Replace or merge audio and video
Replace the sound of a.mp4 with another file. -map picks video from input 0 and audio from input 1, -c:v copy leaves the picture alone, and -shortest stops at the shorter stream.
ffmpeg -i a.mp4 -i music.wav -map 0:v -map 1:a -c:v copy -c:a aac -shortest replaced.mp4We estimated the tone frequency by counting zero crossings in the first second: about 440 Hz before and 660 Hz after, so the audio was replaced.
To add audio to a silent video, use the same idea. Our silent video was 10.0 s and the audio was longer. Without -shortest the file ran 12.0 s, with the video stream ending at 10.0 s. With -shortest the file ran 10.0 s.
ffmpeg -i v_only.mp4 -i long.wav -c:v copy -c:a aac merged_long.mp4ffmpeg -i v_only.mp4 -i long.wav -c:v copy -c:a aac -shortest merged_short.mp4Trim audio
-ss is the start and -t is the length. For a WAV the cut is exact. A copy cut of MP3 or AAC can only start and end on frame boundaries, so the length can differ a little.
ffmpeg -ss 5 -t 10 -i tos_audio.wav trim.wavffmpeg -ss 5 -t 10 -i tos_audio.mp3 -c copy trim.mp3ffmpeg -ss 5 -t 10 -i tos_audio.m4a -c copy trim.m4aNormalise loudness
The loudnorm filter targets an integrated loudness. We measured with the ebur128 filter before and after. The one pass command lands near the target. The two pass command measures first, then corrects with the measured values.
ffmpeg -i tos_audio.wav -af ebur128=peak=true -f null -ffmpeg -i tos_audio.wav -af loudnorm=I=-16:TP=-1.5:LRA=11 -ar 44100 norm1.wavffmpeg -i tos_audio.wav -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json -f null -ffmpeg -i tos_audio.wav -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-16.94:measured_TP=-0.40:measured_LRA=11.90:measured_thresh=-27.30:offset=-0.07:linear=true -ar 44100 norm2.wav| File | Integrated loudness | Loudness range | True peak |
|---|---|---|---|
| Before | -16.8 LUFS | 12.4 LU | -0.4 dBTP |
| One pass | -15.9 LUFS | 9.5 LU | -1.5 dBTP |
| Two pass | -16.0 LUFS | 9.5 LU | -1.5 dBTP |
We set -ar 44100 so the output keeps the input sample rate; the one pass output measured 44100 Hz.
Method and limits
All commands ran on FFmpeg 8.1.2 (a full Windows build) on a Windows 11 laptop, Ryzen 7 7735U, CPU only, on 2026-11-06. We added -y and -threads 4 to every run; they are left out of the commands shown. In quoted FFmpeg messages the hex address after @ changes on every run, so we replaced it with ...
tos.mp4 is a copy of Tears of Steel clip tos_a_0020_60s.mp4 (60 s, 1280x534, 24 fps), (c) Blender Foundation, licensed CC-BY 3.0. We credit it here as the licence asks. Its audio is AAC, 44100 Hz, stereo. a.mp4 is a synthetic 10 s test file (testsrc2 picture and a sine tone, 1280x720, 30 fps, a keyframe every 2 seconds), made with the command below.
ffmpeg -f lavfi -i testsrc2=duration=10:size=1280x720:rate=30 -f lavfi -i sine=frequency=440:duration=10:sample_rate=48000 -c:v libx264 -pix_fmt yuv420p -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -shortest a.mp4ffmpeg -f lavfi -i sine=frequency=660:duration=10:sample_rate=48000 music.wavffmpeg -f lavfi -i sine=frequency=330:duration=12:sample_rate=48000 long.wavffmpeg -i a.mp4 -an -c:v copy v_only.mp4Limits: one run of each command, so the sizes and times are single measurements and not averages. Times were taken on a laptop that was doing other work. Results depend on the input file and the FFmpeg version, so check yours. Loudness was measured with the ebur128 filter on one clip of music and speech, so other material may land differently. We did not listen to the results.
Related: FFmpeg for video editors, FFmpeg convert video format: MOV, MKV, MP4 and WebM, FFmpeg trim video: accurate cuts by time, Join videos with FFmpeg without errors and FFmpeg command builder.
Page checked on Nov 4, 2026.