AI Video Editing Flows

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.

JobCommand (shortened)What we measured
Extract, no re-encode-i tos.mp4 -vn -c:a copy tos_audio.m4a1.47 MB, codec aac, 60.0 s
Extract to MP3-vn -c:a libmp3lame -q:a 21.32 MB, 175.6 kbit/s
Extract to WAV-vn -c:a pcm_s16le10.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.

Copy the audio: 1.47 MB, 194.0 kbit/s
ffmpeg -i tos.mp4 -vn -c:a copy tos_audio.m4a
Re-encode to MP3 (quality 2): 1.32 MB
ffmpeg -i tos.mp4 -vn -c:a libmp3lame -q:a 2 tos_audio.mp3
Decode to WAV: 10.58 MB
ffmpeg -i tos.mp4 -vn -c:a pcm_s16le tos_audio.wav

Copy 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!"

This fails: AAC cannot be copied into .mp3
ffmpeg -i tos.mp4 -vn -c:a copy bad.mp3

WAV 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.

Fixed 192 kbit/s: 1.44 MB
ffmpeg -i tos_audio.wav -c:a libmp3lame -b:a 192k wav192.mp3
SettingFile sizeMeasured bit rate
-b:a 192k1.44 MB192.2 kbit/s
-q:a 21.32 MB175.4 kbit/s
-b:a 128k960.9 kB128.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.

Replace the audio: video h264, 300 frames
ffmpeg -i a.mp4 -i music.wav -map 0:v -map 1:a -c:v copy -c:a aac -shortest replaced.mp4

We 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.

Merge, longest wins: 12.0 s
ffmpeg -i v_only.mp4 -i long.wav -c:v copy -c:a aac merged_long.mp4
Merge with -shortest: 10.0 s
ffmpeg -i v_only.mp4 -i long.wav -c:v copy -c:a aac -shortest merged_short.mp4

Trim 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.

WAV, 10 s from second 5: 10.0 s
ffmpeg -ss 5 -t 10 -i tos_audio.wav trim.wav
MP3 copy: 10.031 s
ffmpeg -ss 5 -t 10 -i tos_audio.mp3 -c copy trim.mp3
M4A copy: 10.0 s
ffmpeg -ss 5 -t 10 -i tos_audio.m4a -c copy trim.m4a

Normalise 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.

Measure: I, LRA and true peak are in the summary at the end
ffmpeg -i tos_audio.wav -af ebur128=peak=true -f null -
One pass loudnorm to -16 LUFS
ffmpeg -i tos_audio.wav -af loudnorm=I=-16:TP=-1.5:LRA=11 -ar 44100 norm1.wav
Pass one of two: prints JSON with the measured values
ffmpeg -i tos_audio.wav -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json -f null -
Pass two, using those values
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
FileIntegrated loudnessLoudness rangeTrue peak
Before-16.8 LUFS12.4 LU-0.4 dBTP
One pass-15.9 LUFS9.5 LU-1.5 dBTP
Two pass-16.0 LUFS9.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.

Make a.mp4
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.mp4
Make music.wav
ffmpeg -f lavfi -i sine=frequency=660:duration=10:sample_rate=48000 music.wav
Make long.wav
ffmpeg -f lavfi -i sine=frequency=330:duration=12:sample_rate=48000 long.wav
Make v_only.mp4, a.mp4 without audio
ffmpeg -i a.mp4 -an -c:v copy v_only.mp4

Limits: 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.