ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Yes, I know that there have been other threads with similar subjects but none seem to have the outcome that I am looking for.
What I would like to do is convert my entire (all 2.5GBs) music collection to mp3 so that I can play them on my media player.
(I looked at the stats. It only plays the proprietry formats, boo.)
Oh, and I'm trying to avoid using Audacity to convert them one by one and manually edit the ID3 tags.
You can use oggdec to decode ogg files to raw PCM, then pipe that into an mp3 encoder (lame, etc.). You'll probably need to specify the sample rate and bitwidth manually (44100KHz, 16-bit, or whatever). Something like,
Code:
#!/bin/sh
for f in "$(find "$@" -name "*.ogg")"; do
oggdec -R -b 16 -e 1 -o - $f | lame --verbose -r -m j -s 44.1 --bitwidth 16 - ${f%.*}.mp3
done
Feed it a directory (or list or directories) and it'll convert all the ogg files in that tree. (Well, it should....) You might need to play with the options a bit if your samples aren't at 44100/16-bit etc.
edit:
You may or may not need the '-e 1' option to oggdec. This swaps the endiannesss of the output. -e 1 uses big endian output, I found that I need this (on x86), presumably lame assumes big endian input (the man page doesn't specify). If the output file is just noise, then remove this option.
Only 2.5gb? I've ripped about 60 gigs of oggs already from my cd collection, and I still have about a hundred disks to go.
Check out soundconverter. It can convert several formats and keep the tags. It can be used in cli batch mode or from it's gui. You'll need lame and the gstreamer-lame plugin for mp3 support.
I should warn you though. the last time I tried it, for some reason the mp3 tags it generated wouldn't display in either easytag or audiotagtools. Probably an id3 version problem or something. They showed up just fine in audacious and konqueror (with the metadata plugin) though.
BTW, it bears repeating that converting from one lossy format to another always means some level of sound degradation. Re-ripping from the original media is recommended for best quality.
Oh yeah, one more thing. Some no-brand mp3 players can play .ogg files, even if it's not stated as such on the box. If you're player is one like that, you might want to test it out.
It does a folder at a time, and places it in a destination (e.g. if you select "/media/music/Radio Head - Kid A" as the source and "/tmp/convert" as the destination, it will created a new folder called "/tmp/convert/Radio Head - Kid A" and place the mp3s in it)
You can place calls to the script in a for loop to take care of all your directories.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.