If you have downloaded a video podcast or a recorded lecture and simply want to listen to the audio on your phone, converting the massive video file into a small MP3 or AAC file is essential. In Linux, you don’t need heavy, graphical video editing software to do this. You can instantly strip the audio track out of any video using the powerful command-line tool, FFmpeg.
Step 1: Install FFmpeg
First, ensure the tool is installed on your system. Open your terminal and run the following command (for Ubuntu/Debian-based systems):
sudo apt install ffmpeg
Step 2: Extract the Audio
The beauty of FFmpeg is that it can extract the audio without re-encoding it, which means the process takes literally one second and results in zero loss of audio quality.
- Use the
cdcommand to navigate to the folder containing your video file. - Run the following command to extract the raw audio stream:
ffmpeg -i input_video.mp4 -vn -acodec copy output_audio.m4a
Understanding the Command
Here is exactly what that command is doing:
- -i input_video.mp4: Specifies the input file you want to process.
- -vn: This stands for “video no.” It explicitly tells FFmpeg to discard the entire video stream.
- -acodec copy: This tells FFmpeg to simply “copy” the existing audio codec exactly as it is, rather than wasting CPU power trying to convert it into a different format.
- output_audio.m4a: The name of the brand new audio file you are creating. (Most MP4 videos use AAC audio, which should be saved with an .m4a extension).
If you specifically need an MP3 file instead, you must re-encode the audio. In that case, drop the “copy” command and run: ffmpeg -i input_video.mp4 -vn output.mp3.