I want to extract just the audio from an MP4 movie file I have. The wrinkle: I’m on a Linux system. Is there some way on Linux, maybe on the command line, to extract the audio from a movie file?
There’s a terrific command line tool that can easily do what you ask, but even better, it works on Linux, Windows and MacOS X systems. The program? FFmpeg. You can grab a copy for free off the FFmpeg Web site or since you’re on a Linux system, you can install the module directly too. I’ll show that in a minute, but first, let’s talk briefly about the program itself.
As they say on the Web site, “FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation.”
You indicated that your source file is in MP4 format, but this’ll work if it were an MKV, AVI or even a MOV file too. Audio output as MP3 is also an industry standard at this point but the program supports a wide variety of other audio formats too.
On an Ubuntu Linux box, for example, if I simply invoke the program, it indicates that it’s not installed and gives me the exact command needed to download and install it and all the (many) necessary libraries too:
Different flavors of Linux use different package managers, and if you’re on a Mac system or Windows the install will be a bit different (see the Web site referenced earlier for details) but “sudo apt install ffmpeg” on the Ubuntu command line pushes out quite an installation. Finally, though, it’s done and ready to use.
Now it’s surprisingly easy. If the input file is called “webinar.mp4” then the command line invocation is simply:
Depending on the length of the movie, it might take a few minutes to complete, during which time you’ll see arcane information spew across your screen similar to this:
Pretty interesting if you want to debug the process, but if you don’t basically just ignore it all until ffmpeg finishes up and you see the following at the end of the Terminal window:
You can see that the duration of the mp3 audio is 55:17 for a total file size of 25,918KB or about 25MB. Easy to confirm, of course, with the “file” listing command:
More information about the mp3 audio file, but the real test? Let’s listen to it!
The best audio program in Ubuntu Linux is Rhythmbox, so let’s give that a shot:
Well, the interface isn’t going to win any awards, but you can see that the audio extracted is in a valid MP3 format and is playable. In fact, it’s perfect and lets me listen to it while driving, a bonus versus having a movie.
And that’s how you do it with the handy FFmpeg program. Hope that helps you out!
Pro Tip: We have lots of Linux help here on the site, please spend a few minutes check it out.