How to convert Flac to Mp3 with FFmpeg?
I have a directory filled with Flac audio files and I would like to convert them all to Mp3. How do I go about this using FFmpeg?
I am using the git FFmpeg and Slackware -current.
2 answers
You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
andrew.46 | (no comment) | Jun 11, 2023 at 05:58 |
The best method is to navigate to the folder containing your Flac audio files and use the following 'for' loop:
for j in *.flac
do
ffmpeg -i "$j" -c:a libmp3lame -b:a 128k mp3/"${j%.flac}.mp3"
done
Note the following points:
- The output files will all be created in a subdirectory called 'mp3'
- The output bitrate can be manipulated with the
-b:a 128k
setting - Or by using a quality setting (rather than bitrate):
-q:a 5
- The naming convention of your input files will be preserved in the output files
And enjoy your music!
0 comment threads
I see that this is self-answered, but I disagree that the answer provided is the best way. The best way is to properly utilize the Unix philosophy, by decomposing the problem into simpler sub-problems.
It is probably not hard to figure out how to convert a single file foo.flac
into foo.mp3
. I'll use the other answer's command:
ffmpeg -i foo.flac -c:a libmp3lame -b:a 128k foo.mp3
Now you just need to get a list FLAC files and apply the command to each one:
ls *.flac | parallel \
ffmpeg -i {} -c:a libmp3lame -b:a 128k {.}.mp3
0 comment threads