Last active
December 10, 2022 20:02
-
-
Save klappradla/04c41d559f71bcc9527e to your computer and use it in GitHub Desktop.
Using lame command line tool (e.g. convert flac to mp3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert .flac to .mp3 (lossless) | |
for f in *.flac; do ffmpeg -i "$f" -aq 1 "${f%flac}mp3"; done | |
# Convert .flac to .mp3, compress to ~ 120k | |
for f in *.flac; do ffmpeg -i "$f" -aq 5 "${f%flac}mp3"; done | |
# Convert .flac to mp3, compress to ~ 128k | |
for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done | |
# Convert .flac to mp3, compress to variable 190k | |
for f in *.flac; do ffmpeg -i "$f" -aq 2 "${f%flac}mp3"; done | |
# Compress .mp3 files with lame to constant 128k | |
for i in *.mp3; do lame --preset 128 "$i" "${i}.mp3"; done | |
# Compress .mp3 to variable 190k (constant quality) | |
for i in *.mp3; do lame -V2 "$i"; done | |
# Compress .mp3 to variable 190k bitrate and replace files | |
for i in *.mp3; do lame -V2 "$i" tmp && mv tmp "$i"; done |
you should add the -nostdin
option and either -n
or -y
to all the ffmpeg calls
I've been looking for something like this. thanks!
Amazing!!11
This is really great, and thank you. It works fine in a Mac shell, but I'd like to run it from a Perl script. When I do it seems to hang and the perl script does not continue. Ideas / suggestions?
Hm, I don't think I can help you there @trudge42 😞 I put these snippets down at what feel like ages ago because I needed to convert something... I'm not familiar with the details in there plus I don't know the Perl language 🤷♂️
But maybe share you're approach and someone else may be able to chime in?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very nice, but how do you ensure that you do not inflate the bitrate? I have found a few flac files with very low bit rates (why, I do not know) but it would be useful to ensure that it only do a conversion if the flac bitrate is higher than target bitrate.
Is that possible?