Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

How to convert Flac to Mp3 with FFmpeg?

+5
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

2 answers

+4
−0

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:

  1. The output files will all be created in a subdirectory called 'mp3'
  2. The output bitrate can be manipulated with the -b:a 128k setting
  3. Or by using a quality setting (rather than bitrate): -q:a 5
  4. The naming convention of your input files will be preserved in the output files

And enjoy your music!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »