View previous topic :: View next topic |
Author |
Message |
wolvenwraith n00b

Joined: 28 Dec 2003 Posts: 67 Location: Someplace, Somewhere
|
Posted: Mon Dec 29, 2003 5:45 am Post subject: Burning Audio CDs - Another Way |
|
|
I found that I needed to burn albums of mp3's many times, and I hated all the GUIs out there that do it (poor ATAPI support, bad layout, etc. etc.). I am also a big fan of the powerful Linux CLI. So I hacked something up in order to solve these problems. All you need to do is put all your mp3's into one directory and run this script (I called it mp3burn and copied it into /usr/bin so I can run it anytime, it's nice to have).
Code: |
#!/bin/bash
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=44 -pad -audio -v -gracetime=2 *.wav
rm *.wav
|
Note that the cdrecord line may need to be modified in order to accomadate your burner (notably the dev=, and speed= lines) and gracetime can be modified as you see it as well.
Don't forget to run chmod a+x on the file so that it is executable!
Notes: Just improved it a little bit, it now normalizes (emerge normalize) the .wav files and removes them after they're burnt. Also fixed the [Mm][Pp] thing in the first line. This little script should be pretty easy to alter if it doesn't fit you perfectly. Keep in mind too, this will change the names of you mp3's if they have spaces or caps in them.
Last edited by wolvenwraith on Mon Dec 29, 2003 8:40 pm; edited 1 time in total |
|
Back to top |
|
 |
pem725 n00b


Joined: 26 Sep 2002 Posts: 68 Location: Tucson, AZ USA
|
Posted: Mon Dec 29, 2003 8:55 am Post subject: |
|
|
What do you do with the wav files after burning?
Also, you might find burncenter allows you a similar setup with a few more features. Nice work though.
Like you, I am a fan of the CLI and use abcde and burncenter as console apps - along with the usual straightforward calls to cdrecord. _________________ Cheers,
Patrick
Do the community a favor and answer a few stranded messages. I'm off to answer one now...thanks to gentoo! |
|
Back to top |
|
 |
d99ma Tux's lil' helper

Joined: 21 Jul 2003 Posts: 148 Location: Lund, Sweden
|
Posted: Mon Dec 29, 2003 10:42 am Post subject: |
|
|
Perhaps you should check for [mM][pP] when removing spaces, normalize the wav files and remove them after burning. Then it would be perfect!
/Martin |
|
Back to top |
|
 |
wolvenwraith n00b

Joined: 28 Dec 2003 Posts: 67 Location: Someplace, Somewhere
|
Posted: Mon Dec 29, 2003 8:48 pm Post subject: |
|
|
Thanks for the feedback. I checked out burncenter and it seems pretty cool. However, it doesn't seem to support ATAPI burning out of the box (I didn't play with it much so I could be wrong). The other thing is I sorta like the one-liner style of this script, but that's just me . All in all though burncenter seemed pretty nice.
Thanks to both of you for the suggestions, I made all the necessary changes to the script. |
|
Back to top |
|
 |
Elm0 Apprentice

Joined: 24 Nov 2002 Posts: 281 Location: UK
|
Posted: Mon Dec 29, 2003 10:50 pm Post subject: |
|
|
Nice script, obviously going to be quicker than a GUI if you do this a lot, however well designed the GUI is. The beauty of linux I suppose, why be forced into one way when you can choose your path! |
|
Back to top |
|
 |
Munck n00b

Joined: 06 Feb 2003 Posts: 35 Location: Skive, Denmark
|
Posted: Tue Dec 30, 2003 12:56 pm Post subject: |
|
|
Thanks for the script. I've been looking for some easy way to do this, but I've been too lazy to write a script myself  _________________ Why?
- because I can ! |
|
Back to top |
|
 |
pengo n00b

Joined: 22 Aug 2003 Posts: 53
|
Posted: Sat Jan 03, 2004 9:00 pm Post subject: |
|
|
Hello there! I'm new at this and have a fresh install of Gentoo. What would I need to emerge for this script to work?
Thanks for the contribution! |
|
Back to top |
|
 |
MrNugget Tux's lil' helper

Joined: 15 Nov 2003 Posts: 144 Location: Germany
|
Posted: Sat Jan 03, 2004 9:13 pm Post subject: |
|
|
Just "emerge cdrtools" and you'll be able to use cdrecord. |
|
Back to top |
|
 |
dr_strange Guru


Joined: 16 Apr 2002 Posts: 480 Location: Cambridge, UK
|
Posted: Sat Jan 03, 2004 9:13 pm Post subject: |
|
|
emerge cdrtools lame |
|
Back to top |
|
 |
BakaO n00b


Joined: 27 Sep 2003 Posts: 74
|
Posted: Wed Jan 14, 2004 9:10 pm Post subject: |
|
|
Hello,
your script is veyr cool, but I have 2 questions :
1-Is the 'normalize' really neccesary ? (I think if the dB levels are not the same, it is normal, no ?)
2-How can we add cd-text support ? I think it is related with the .inf files but how can we auto-generate them (form id-tag) or other method.
Thanks for all ! |
|
Back to top |
|
 |
TechSmurf n00b


Joined: 25 Aug 2003 Posts: 29 Location: ON, Canada
|
Posted: Thu Feb 19, 2004 1:16 pm Post subject: Thanks |
|
|
I would just like to say, Thanks.
This little file saved me alot of time and work.
Keep up the good work.
(it worked 'right out of the box' ) |
|
Back to top |
|
 |
TheEternalVortex Apprentice


Joined: 15 Oct 2002 Posts: 207 Location: San Jose, CA
|
Posted: Thu Feb 19, 2004 8:53 pm Post subject: |
|
|
What's the point of renaming all the files? _________________ -- Andy |
|
Back to top |
|
 |
metalh34d Tux's lil' helper

Joined: 04 Feb 2004 Posts: 126
|
Posted: Tue Apr 27, 2004 5:29 pm Post subject: |
|
|
doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done? |
|
Back to top |
|
 |
icefox13 Tux's lil' helper

Joined: 19 Apr 2004 Posts: 78 Location: Munich, Germany
|
Posted: Tue Apr 27, 2004 5:47 pm Post subject: |
|
|
metalh34d wrote: | doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done? |
Every compressed audio file (mp3, ogg) has to be converted to wav if you make an audio-cd (not mp3-cd), because wav is the format the tracks are stored on the disc.
(But you sometimes can't see this when burning an audio-cd because the mp3s are decoded and recorded nearly simultaneously.) |
|
Back to top |
|
 |
metalh34d Tux's lil' helper

Joined: 04 Feb 2004 Posts: 126
|
Posted: Tue Apr 27, 2004 9:52 pm Post subject: |
|
|
I tried using the script and it didn't work very well. It only burned 2 tracks in the folder I had set to burn to cd. Also it took a very long time and it will only play in my car. Then again I'm having problems with burned cds playing on my cdroms anyway. Any help? Please? |
|
Back to top |
|
 |
MighMoS Guru


Joined: 24 Apr 2003 Posts: 416 Location: @ ~
|
Posted: Thu May 06, 2004 2:43 am Post subject: |
|
|
Could it be added to rename the files back to their originals? Or at least how would I create a script that would remove the underscores? (I have very little programming experience) _________________ jabber: MighMoS@jabber.org
localhost # export HOME=`which heart` |
|
Back to top |
|
 |
diegs Tux's lil' helper

Joined: 06 Aug 2003 Posts: 79 Location: nyc
|
Posted: Sat May 22, 2004 4:42 am Post subject: |
|
|
No renaming:
Code: | GNU nano 1.3.2 File: /home/diegs/music/burn.sh
#!/bin/bash
for i in *.[Mm][Pp]3; do lame --decode "$i" "`basename "$i" .mp3`.wav"; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=24 -pad -audio -v -gracetime=0 *.wav
rm *.wav
|
_________________ knowledge = fv |
|
Back to top |
|
 |
Spack n00b


Joined: 02 Feb 2003 Posts: 32
|
Posted: Sat May 29, 2004 10:45 pm Post subject: |
|
|
This will handle ogg vorbis files aswell:
Code: | #!/bin/bash
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done
for i in *.ogg; do oggdec $i; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=44 -pad -audio -v -gracetime=2 *.wav
rm *.wav |
_________________ Gentoo 2004.4
Gnome 2.8
Athlon XP 1800+ 512MB DDR
Promise SATA |
|
Back to top |
|
 |
fireboy1919 n00b


Joined: 28 May 2002 Posts: 47
|
Posted: Thu Jul 08, 2004 2:19 am Post subject: You've got it backwards |
|
|
metalh34d wrote: | doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done? |
wav is an uncompressed, lossless temporal format - the analog of bmp files in graphics.
mp3, on the other hand, is a compressed, lossy format, and whenever you convert to it, you lose information. Even if you do not compress at all you'll degrade the signal some when you convert to mp3 because it converts it to discrete cosine space (similar to doing a discrete fourier transform), and there's some loss of signal just from converting to it and back. You always have to convert back because you we listen to audio in temporal, not frequency space. Might as well do it by converting it to wav first.
Most people cannot hear the artifacts caused by the conversion; most people can't even hear the artifacts caused by removing a chunk of the signal after this conversion.
The real thing that you have to worry about is lower sample rates, which can cause aliasing if you sample at lower than twice the frequency of the highest frequency in the signal. As long as that doesn't happen (and it's not likely if you keep the audio at CD quality - 48kHz), you probably won't have problems. Well...there are a few more possible problems, but they're a lot less likely. |
|
Back to top |
|
 |
freebit50 n00b


Joined: 26 May 2004 Posts: 56
|
Posted: Sun Jul 11, 2004 3:39 am Post subject: |
|
|
I love this little script!!! I was going to install k3b, but it was going to install a bunch of junk that I didn't want to wait for. This script works great, however, I added a little bit to it so cdrecord doesn't get messed on on weird filenames. I also made it so that in the end all the original files are back with no filename modifications. I also added comments. My CS teachers at school are always whining about comments and stuff.
Gotta go for a cruise with the new cd I just burned!!! Laters....
Code: |
#!/bin/bash
#
# create backups so that we leave originals untouched
#
mkdir ./bak
cp *.mp3 ./bak
#
# get rid of of stuff in the filename that could fubar cdrecord
#
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '-'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '('`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d ')'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '+'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d "'"`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '[0-9]'`; done
# oops, stripped the 3 from mp3....gotta add it back in
for i in *.[Mm][Pp]; do mv "$i" `basename $i .mp`.mp3; done
#
# decode mp3 to wav using lame
#
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done
#
# normalize is a tool for adjusting the volume of audio files
# to a standard level.
#
normalize *.wav
#
# let us burn!!!
#
cdrecord dev=ATAPI:0,0,0 speed=16 -pad -audio -v -gracetime=2 *.wav
#
# get rid of temp files and restore originals
#
rm *.wav
rm *.mp3
mv ./bak/*.mp3 ./
rm -rf ./bak
|
|
|
Back to top |
|
 |
AGM Apprentice

Joined: 02 Nov 2002 Posts: 171
|
Posted: Sun Jul 11, 2004 8:38 am Post subject: |
|
|
You could also check out bashburn, that's what I use. It's very cool. |
|
Back to top |
|
 |
MighMoS Guru


Joined: 24 Apr 2003 Posts: 416 Location: @ ~
|
Posted: Sun Jul 11, 2004 4:13 pm Post subject: |
|
|
Rather than moving all these files back and forth, wouldn't just using symlinks be easier? _________________ jabber: MighMoS@jabber.org
localhost # export HOME=`which heart` |
|
Back to top |
|
 |
freebit50 n00b


Joined: 26 May 2004 Posts: 56
|
Posted: Mon Jul 12, 2004 5:29 am Post subject: |
|
|
Quote: |
Rather than moving all these files back and forth, wouldn't just using symlinks be easier?
Code: |
Probrably. I am a newb and didn't think of it. On the other hand, when I was doing the testing, for the 16 songs that I used to fill a cd, all the moving around seemed instantanious. |
|
|
|
Back to top |
|
 |
agnitio Tux's lil' helper

Joined: 17 Apr 2004 Posts: 136
|
Posted: Thu Jul 15, 2004 7:33 pm Post subject: |
|
|
Why not use [:upper:] and [:lower:] insead of [A-Z] and [a-z] so that it works for non-english characters as well. |
|
Back to top |
|
 |
cottonmouth Tux's lil' helper

Joined: 24 Jan 2004 Posts: 105
|
Posted: Sat Sep 11, 2004 12:08 pm Post subject: |
|
|
freebit50 wrote: | I also added comments. My CS teachers at school are always whining about comments and stuff. | Very nice. I don't know shell-scripting, but your comments make unintelligble bash-code much more understandable. Thanks!
Programming is about communication and exchange of ideas between people, the machine is just the medium. Code for people, not for machines.
Or, as the Yukihiro Matsumoto said:
Quote: | Code is an expression of the thoughts, attitudes, and ideas of the programmer. By reading code, you can not only figure out what particular task the programmers were trying to accomplish and understand how they did it, but you can also gain insight into how they were thinking. This is the reason that reading code makes programmers better. |
Matsumoto created Ruby, and no matter if you're interested in the language, his philosophy is enriching for all developers, no matter how skilled one is or which language one works in. Read more here _________________ Answer an unanswered post |
|
Back to top |
|
 |
|