FFmpeg is a free open-source command-line tool for converting multimedia files. If you’re looking for a solution to quickly convert audio files from one format to another, FFmpeg is the go-to tool to do so with ease. This tutorial will guide you to batch convert FLAC to MP3 using FFmpeg on Linux.
Installing FFmpeg
Install FFmpeg from the repo using the following command if you’re using a Debian-based distro. Otherwise, make sure to have it installed correctly from your distro’s repo.
sudo apt-get update sudo apt-get install ffmpeg
Converting FLAC to MP3
Go to the directory where a FLAC file you want to convert to MP3 is in. Run the following command to convert the FLAC file to MP3. You can change the bitrate in the command if you would like, such as 256k, 192k, or 128k.
ffmpeg -i input.flac -b:a 320k output.mp3
Batch converting multiple FLAC files to MP3
You can easily batch convert all the FLAC files in a directory to MP3 using the following one-line command. It will read all the FLAC files and convert them to MP3 320 kbps individually with all the metadata info preserved.
for i in *.flac; do ffmpeg -i "$i" -b:a 320k "${i%.*}.mp3"; done