Convert mp4 to mp3 in Linux Terminal
First things first, install the required software packages. Most Linux distros ship with FFmpeg pre-installed but to ensure the required packages are installed, run this command anyway.
sudo apt install ffmpeg && sudo apt install libavcodec-extra-53
After installation, let’s use it to convert mp4 video file into mp3 audio file.
For FFmpeg with Constant Bitrate Encoding (CBR), use this command.
ffmpeg -i video.mp4 -vn \
-acodec libmp3lame -ac 2 -ab 160k -ar 48000 \
audio.mp3
If you want to use Variable Bitrate Encoding (VBR), use this command.
ffmpeg -i video.mp4 -vn \
-acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \
audio.mp3
If it says ffmpeg is depricated
or ffmpeg: command not found
which is the case in old Ubuntu distros, so, use this command instead.
avconv -i video.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 audio.mp3
The meaning of arguments
argv | meaning |
---|---|
-i | input file name |
-vn | disable video recording |
-acodec | force audio codec to libmp3lame |
-ac | set the number of audio channels |
-ar | set the audio sampling frequency |
I hope this post helps you. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .