During the break before my next semester, I’ve been trying to study a bit, both in preparation for classes I am taking next semester, and to prepare for a CLEP exam I plan to take soon, in order to reduce the total number of classes I need to take.

One resource for some of my studies are the videos available from many universities, where they have recorded classes, such as those on Academic Earth. Since many of these are easily downloadable, and often consist mostly of lectures, it makes sense to strip the audio from them, and copy this audio onto my phone so I can listen to the lectures anywhere I go.

This tip requires you to have the program ffmpeg installed.

To strip the video VideoIn.mp4 and put the audio into an flac file titled AudioOut.flac use the following command:

ffmpeg -i VideoIn.mp4 -ac 2 -vn AudioOut.flac

With this command, the audio will be encoded to ogg vorbis, with a bitrate of 64k, a sampling frequency of 44100 Hz, and two channels.

These three defaults can be changed, although they should do fine for stripping the audio from nonmusical things like lectures. To change the number of channels, simply change the number following -ac. To change the bitrate, add the flag -ab with the a space and then the desired bitrate value (such as 160k. To change the sampling frequency, use the -ar flag with a space following it and then add the desired frequency value (like 44100 Hz.

The -vn flag tells ffmpeg to only output the audio of the input video.

There are undoubtedly other methods to do this, but I have found using ffmpeg simplest for this job and other conversion tasks.