Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a small collection of mp3 files that have a "huge" bit rate (320kbps). I would like to transform all the files so they would have a "normal" bit rate of, say, 128 kbps and simultaneously keep the ID3 tags. I think this can be done by a bash script, but I don't know exactly how.
I use "Lame" for this and have a shell script wrapper around it. One thing though, it doesn't preserve ID3 tags - need to sort that out when I get time or you can modify the below to do that.
Code:
#!/bin/bash
if [ $# -eq 1 ]
then
dir=./
br=$1
elif [ $# -eq 2 ]
then
dir=$1
if [ $2 == 'vbr' ]
then
br='standard'
else
br="cbr $2"
fi
else
echo "Usage: $0 [directory] New_Bitrate"
exit -1
fi
if [ ! -d $dir ]
then
echo "$dir is not a directory"
exit -1
fi
echo "Converting files in $dir to bitrate: $br"
find "$dir" -name "*.mp3" | sort | while read i
do
tmpfile=$(mktemp)
lame --mp3input --preset $br -S --add-id3v2 "$i" "$tmpfile"
mv "$tmpfile" "$i"
chmod 644 "$i"
echo "Sucessfully converted $i"
done
exit 0
Search the site. Get on Google. The number of people who've wanted to do exactly the same thing must number in the tens of thousands by now. And I know at least a few of them found solutions and have posted them for others to use.
But overall I concur with cascade9. If you don't need to convert a lossy file, don't. It's better to go back to the original lossless source, assuming it exists, and simply rip it again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.