Friday, April 04, 2008

audiocassette → mp3

So we have an audiocassette of a 2000? (Nope; it was November 1999) Veritas Forum presentation on "The Bitterness of Truth" by Dallas Willard. As the subject suggests, I wanted to make MP3 files of this.

So I fortunately have an ancient "digital entertainment center", which is great for doing "wavrec" to create ".wav" files. So I said
$ wavrec -S -s 48000 -t 3000 willard1.wav
Why "-S" (stereo) and 48KHz ("-s 48000")? Probably due to some bug in the chip or in my driver (ouch!) it's not possible to set it for mono, or for any rate other than 48KHz. Therefore I have to give it these options to tell wavrec how many samples to look for.

I use a time of 3000 seconds, assuming that the tape might be a little longer than 45 minutes on a side.

So for both sides of a tape, I have two files of about 576Mbytes (oooh). Of course there was quite a lot of empty space in the beginning and end (the tape really was under 45 minutes per side). I used "snd" to trim off the beginning and end.

That gives us two files about 512Mbytes. But I don't want 48KHz stereo; I want maybe 24K mono. Therefore:
$ sox w1.wav -r 24000 -c 1 w1x.wav polyphase
$ lame w2x.wav w2x.mp3

The first command turns 48K stereo into 24K mono. The second creates an MP3 file, 32Kbits/second, which has adequate quality for speech.

The other question is... Is 10 Mbytes too large a file?

But at least we have two files of 10Mbytes each rather than 576Mbytes each. I can at least imagine trying to email the 10Mbyte file.

Splitting into smaller files

OK, I decided to try to make these into smaller files (the better for listening to on primitive mp3 players like your ipod shuffle, where you can't move within a track). Using the excellent snd program, I split the two long WAV files into 10 files of about 9 minutes each, with a few seconds' overlap. I was surprised that although I named the files w1a.wav, w1b.wav (etc.) the generated files were not wav files; they were
$ file ../w1a.wav
../w1a.wav: Sun/NeXT audio data: 16-bit linear PCM, mono, 24000 Hz

This was probably explained in The Fine Manual, which I did not read (When all else fails...). Anyway, I linked these to a set of friendlier filenames:
and then had to feed some parameters to lame, like this:
for f in *.wav; do m=${f%wav}mp3; lame -r -m m -s24 $f $m; done;
which left me with this nice set of mp3 files:
$ ls -lG *mp3
-rw-r--r-- 1 collin 2174784 2008-04-06 10:42 will-truth01.mp3
-rw-r--r-- 1 collin 2197248 2008-04-06 10:52 will-truth02.mp3
-rw-r--r-- 1 collin 2148576 2008-04-06 10:52 will-truth03.mp3
-rw-r--r-- 1 collin 2164992 2008-04-06 10:52 will-truth04.mp3
-rw-r--r-- 1 collin 2017824 2008-04-06 10:52 will-truth05.mp3
-rw-r--r-- 1 collin 2161632 2008-04-06 10:53 will-truth06.mp3
-rw-r--r-- 1 collin 2221344 2008-04-06 10:53 will-truth07.mp3
-rw-r--r-- 1 collin 2160480 2008-04-06 10:53 will-truth08.mp3
-rw-r--r-- 1 collin 2164320 2008-04-06 10:53 will-truth09.mp3
-rw-r--r-- 1 collin 1734624 2008-04-06 10:53 will-truth10.mp3
Finally, for devices with display capability (hint: the ipod shuffle does NOT have this), I thought I'd add some info to the files via "id3v2", like this:
$ for f in will*mp3; do 
P=${f%.mp3}; P=${P#*truth}; P=${P#0};
id3v2 -a "Dallas Willard" -A "Veritas Forum November'99" \
-t "Bitterness of Truth ($P/10)" -y 1999 $f;

No comments: