How to Add Audio to a Video with FFmpeg
To add an audio track to a video with FFmpeg and keep the picture untouched, the command is ffmpeg -i video.mp4 -i audio.m4a -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -shortest out.mp4. The two -map flags are the part that matters and the part the widely shared version leaves out: without them FFmpeg picks the audio stream itself, and its rule for picking usually chooses the audio the video already had rather than the file you just supplied. The tool below runs the mapped version in your browser, so there is nothing to install and nothing is uploaded.
Add your audio track to the video
1. The video
or drag and drop a .mp4 / .m4v / .mov file here — up to 100 MB
2. The audio to add
or drag and drop a .mp3 / .wav / .m4a / .ogg / .flac file here — up to 100 MB
This tool runs the open-source FFmpeg engine in your browser. First use downloads it once (a 32 MB file, roughly 10 MB compressed in transit); after that it loads from your browser cache. Your files are never uploaded. The engine is ffmpeg.wasm, distributed unmodified under the GPL-2.0-or-later.
Processed on your device — files are never uploaded to Filesvo.
The command everyone copies keeps the wrong audio
The line that circulates is ffmpeg -i video.mp4 -i audio.m4a -c copy out.mp4. In three of the four cases measured below it silently discards the audio file you just added and keeps the one the video already had. The output carries a single audio stream, so there is nothing to switch to in a player: the track you wanted is not in the file at all. Nothing in the run warns you, and the finished MP4 plays perfectly — with the old sound.
The reason is in FFmpeg's own manual, under automatic stream selection. With no -map flag FFmpeg chooses for you, and for audio it takes “the stream with the most channels”; where several rate equally, “the stream with the lowest index is chosen”. Your video is input 0 and your audio file is input 1, so on a tie the video always wins. The only case where the file you added survives is when it has more channels than the video's own track.
That is what makes this hard to spot: the outcome depends on the channel counts of two files nobody deliberately chose. The same command works for one person and quietly fails for the next, with no visible difference between the two runs. Naming the streams with -map 0:v:0 -map 1:a:0 removes the guesswork — picture from input 0, sound from input 1, every time. That is exactly what the tool above runs.
Which audio survives, measured in all four cases
A six-second test video and a ten-second audio file, each prepared in mono and in stereo, run through every combination with FFmpeg 9.0.1 using ffmpeg -i video -i audio -c copy out.mp4. The duration and channel count of the single audio stream in the output say which track it is: the video's own runs six seconds, the one being added runs ten.
| Video's own audio + the file you add | What ends up in out.mp4 |
|---|---|
| mono + mono | the video's own — 6.0 s, 1 channel |
| mono + stereo | the file you added — 10.0 s, 2 channels |
| stereo + mono | the video's own — 6.0 s, 2 channels |
| stereo + stereo | the video's own — 6.0 s, 2 channels |
| all four again, with -map 0:v:0 -map 1:a:0 | the file you added — 10.0 s, every time |
One in four is the score for these particular files, not a general failure rate — but the pattern is not luck either. Camera and screen-recording audio is very commonly stereo, and music or narration you add is stereo too, which lands on the fourth row: the tie goes to the lower input index, and that is always the video.
The commands, and the flags the short one is missing
The version worth using names both streams explicitly: ffmpeg -i video.mp4 -i audio.m4a -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -shortest out.mp4. Read it as four decisions. -map 0:v:0 takes the first video stream of the first input; -map 1:a:0 takes the first audio stream of the second. Those two are the fix.
-c:v copy is the reason this finishes in seconds rather than minutes: the encoded picture is lifted out of one container and dropped into the other without being decoded, so the video is not re-encoded and loses nothing. -c:a aac re-encodes the sound, which is cheap by comparison and makes the result an ordinary MP4 that plays everywhere.
One flag is worth adding for playback rather than correctness: -movflags +faststart moves the index to the front of the file so a browser can begin playing before the whole thing has downloaded. It costs one extra pass over the finished file and nothing in quality. The tool on this page includes it.
If you would rather check the result than trust the command, run ffprobe -show_streams out.mp4 and look at the audio stream's duration and channel count. That is precisely the check that produced the table above, and it is the only reliable way to tell the two outcomes apart — both files play.
Deciding where the finished file should end
A video and an audio file are almost never the same length, so something has to give. FFmpeg's default is to run until the longest input is exhausted, which is rarely what anyone wants when the audio is a three-minute song and the clip is forty seconds.
Measured on the six-second video and ten-second audio: with -shortest the output is 6.0 seconds and the audio is cut to 5.99. Without it the container is 10.0 seconds long while the video stream still ends at 6.0 — the picture simply runs out, and what a player shows for the remaining four seconds is up to the player.
So pick deliberately. -shortest for a clip that should end when the picture does, which is the common case. Leave it off when the audio is the point and the video is a still or a loop meant to sit under it. The tool offers the same two choices as a dropdown rather than making the decision for you.
Trimming the audio to length beforehand is the third option and often the best one, because it lets you choose which part of the track is used rather than always taking the opening. Trim the video first if the clip is the part that needs cutting.
When the audio cannot simply be copied across
Copying an audio stream instead of re-encoding it — -c:a copy — is free and lossless, but it only works when the container can hold that stream exactly as it is. An AAC track from an .m4a and an MP3 both go straight into an MP4 with no trouble.
Raw PCM from a WAV, and FLAC, depend on the build. FFmpeg 9.0.1 on a desktop accepted both in testing; the browser engine on this page, compiled from an older FFmpeg, refused the WAV and failed the run part-way through with a message about codecs that made it look as though the file was damaged.
Rather than hand you a run that dies a minute in for a reason you could not have guessed, the tool only offers the copy option when the audio is an .m4a or an .mp3, and re-encodes everything else to AAC at 192 kbps. That is one lossy generation on the audio only; the picture is still copied bit for bit either way.
If what you actually want is the sound out of a video rather than into one, extract the audio to MP3 instead.
Replacing the audio, not layering it
The mapped command replaces sound rather than adding to it. -map 1:a:0 names exactly one audio stream for the output, so whatever the video arrived with is dropped. For narration over a silent screen recording, or a music bed on a clip whose original audio is wind noise, that is the desired behaviour.
Keeping both at once is a different job and a different command — the two streams have to be mixed together with the amix filter, which means decoding both and choosing relative volumes. Mapping alone cannot do it, and neither can this tool.
You can, however, get there in two steps: extract the video's existing audio, mix it with your new track in an audio editor where you can actually hear the balance, then bring the finished mix back here.
Why this runs in a browser at all
FFmpeg here is the real FFmpeg, compiled to WebAssembly and fetched into the page once — about 32 MB, roughly 10 MB over a compressed connection — then cached. It runs on your own device, so neither the video nor the audio is uploaded, queued or stored anywhere.
For this particular job that trade is unusually good. Because the picture is copied rather than re-encoded, almost no computation happens: the slow part of a video conversion is the video, and there is no video conversion here. A clip that would take minutes to compress is muxed in seconds even inside a browser tab.
The limit is memory rather than speed. A browser tab gets a fraction of what a desktop process gets, and both files have to fit in it, so a feature-length source will fail where a two-minute one is instant. For the length of clip people usually add music or narration to, it is not a constraint you will meet.
Frequently asked questions
- Why does my video still have its original audio after running the FFmpeg command?
- Because the command had no -map flags, so FFmpeg chose the audio stream itself — and its rule is to take the one with the most channels, breaking ties by lowest input index. The video is input 0, so it usually wins. Add -map 0:v:0 -map 1:a:0 and the file you supplied is used instead.
- What do -map 0:v:0 and -map 1:a:0 mean?
- They name streams by input, type and index. 0:v:0 is the first video stream of the first input file; 1:a:0 is the first audio stream of the second. Together they tell FFmpeg to take the picture from one file and the sound from the other, instead of guessing.
- Does adding audio re-encode or degrade the video?
- No. With -c:v copy the encoded picture is moved into the new container without being decoded, so it is bit-for-bit the same video. Only the audio is re-encoded, and only when the format requires it.
- What does -shortest do, and do I need it?
- It ends the output when the shorter input runs out. On a six-second video with ten seconds of audio, -shortest gives a six-second file; without it the container is ten seconds long while the picture stops at six. Use it whenever the clip should end when the picture does.
- Can I keep the video's original audio and add the new track on top?
- Not with mapping alone. Mapping selects streams; combining two into one requires the amix filter, which decodes both and needs volume levels chosen. Extract the existing audio, mix it with the new track in an audio editor, then add the finished mix back to the video.
- Is my video uploaded to a server?
- No. FFmpeg is compiled to WebAssembly and runs inside this page on your own device. Both files are read from disk by the browser, combined locally, and the result is handed straight back to you.
Related Filesvo tools
Add Audio to Video
Put a music or voice track into an MP4 without re-encoding the picture — the browser equivalent of ffmpeg -c copy.
MP4 to MP3
Extract the audio track from an MP4 video as an MP3 file — entirely in your browser with the FFmpeg engine.
Video Trimmer
Cut a clip out of a video with a live preview — frame-exact re-encode or instant lossless keyframe copy.