
I'm huge fan of music -- especially hard rock and thrash metal. I feel almost dead if I don't get a chance at least once a day, to listen to them. So I wanted to put my huge collection into my mobile phone's memory chip so I can carry them anywhere I go. But, my poor memory chip is just 1 GB. It's not enough at all! So, the only way to pack as much as I can is, reduce the bitrate of the MP3 files.
The next problem... I don't use Windows, nor Windows based software. But, if occurs a situation where I don't have any chance with Linux, I have installed Windows inside a virtual machine for use. But I rarely use that. Of course I can use JetAudio or any other audio conver to do this easily, but, as a professional and permanent Linux user, that's not my style.
So I asked our smart genie... Google to find out a solution. Here's what I've got:
#!/bin/bash for file in `ls` do file=`echo $file | sed s/\ /_/g` echo $file lame --decode $file lame -b 128 $file.wav rm $file rm $file.wav mv $file.wav.mp3 $file done
http://www.linuxquestions.org/questions/linux-software-2/reduce-mp3-bitrate-336791/
It's a shell script for batch processing. It will process all the MP3 files inside a given directory. Yes, that's more than what I wanted, but, what would happen if filenames contain whitespaces? The solution is not much practical, because most MP3s we get contains at least one whitespace in filename. I don't have time to rename each and every file. So I wsa thinking about a suitable solution.
It is based on lame encoder, if you don't have it, please install it first.
# apt-get install lame
Yes, the find command! Got that!!! Here's the code I've wrote:
Copy this into a text file (mp3enc.sh).
if [ $# -eq 2 ] then mkdir $1/output cd $1 find . -maxdepth 1 -exec lame -h -b $2 {} ./output/{} \; else echo "Invalid arguements, please refer http://portal.shaakunthala.com/2009/10/mp3-batch-transcoding-with-linux.html" fi
Then execute,
$ chmod +x mp3enc.sh
Now run it,
$ ./mp3enc.sh <mp3_files_directory> <target_bitrate_kbps>
Eg:
$ ./mp3enc.sh /home/ubuntu/Music/MyMusic 128
It will make a directory called output inside your music directory, and put the encoded files in.
It's simple as that! I think it's easier than JetAudio, isn't it? ;)
Comments (3)
October 26, 2009 at 11:02 PM
I don't know, shell scripting and regexp are still too complicated for me.
Perhaps, I will try it someday. Thanks, nice job as usual
October 27, 2009 at 2:33 PM
@Dappi Sira,
Thank you for your comment. At the moment, egexp is somewhat complicated for me too, but, shell scripting is not. It's almost like writing .bat files in Windows. I conduct a shell scripting tutorial on diGIT (http://digit.lk) online Magazine in Sinhala. You can refer it if you are interested :)
January 26, 2023 at 7:32 PM
Besides the stellar real money slots repertoire powered by over 10 suppliers, you may also|you can even} enjoy all the classic desk games and a few live blackjack and roulette games. This mythological recreation wins gamers' hearts time after time for good reasons. With 30 paylines, five reels, and endless moments of enjoyable, you’ll enjoy every minute spinning free slots online with the traditional Gods. Features like The Hot Hot 메리트카지노 Super Respin make this classic slot machine as real and thrilling as the unique WMS recreation discovered within the world’s largest casinos.
Post a Comment