noizZze

Adding Audio Track to Video With Ffmpeg

I enjoy many TV Shows, but it’s hard to find an acceptable (read respectable) quality, and so recently I downloaded a translated version of Stargate Atlantis but with an original English track sitting in a separate MP3 file. I’m on Mac OS X and love using VLC for playing media, and to give it a credit, it supports this scenario, but in an inconvenient way – you have to choose two files manually each time. That’s when the grey matter comes in.

There’s a wonderful tool – FFMPEG – that is used everywhere to recode and augment video streams. It’s like Image Magick of the video world. Here’s how you add a track to the source video without touching the original:

ffmpeg -i source.mkv -i new_audio.mp3 \
   -vcodec copy -acodec copy \
   -acodec copy \
   destination.mkv \
   -newaudio

Here we tell it to pick two sources, then tell to copy video and audio from the first one plus audio from the second one and put it inside the destination file. We tell that there’s new audio track to be created with the newaudio flag.

Since everything is raw, we get it super-fast. I had an entire season processed in about 5 minutes. Sweet.