Convert shn (Shorten) to MP3 or FLAC in Linux - Adventures in Switching to Linux

Thursday, April 3, 2008

Convert shn (Shorten) to MP3 or FLAC in Linux

Many months ago I downloaded some Jump Little Children live shows from the Internet Archive Live Music Archive. The files, of course, were in a lossless format but it was the older Shorten (*.shn) format instead of the newer and open FLAC. Shorten has limited support in Linux (and Windows too) so instead of trying to play them as shn I decided to convert them to mp3.

Tappers: I know you hate when your lossless recordings are converted to mp3. Heck, the notes that come with the files explicitly say "DO NOT ENCODE INTO MP3!" I am going to do it anyway. I would go with FLAC since it is also lossless, creates smaller files than Shorten and is better supported but I still have problems with FLAC. First, it is still much larger than an mp3 and my hearing and/or audio systems are not good enough for it to matter to me. Second, FLAC does not play on my iPod so I would have to convert it to something else to listen to it there. I promise though that I will not distribute these crappy mp3 copies of your recording and I plan to keep a copy of the shn files around (or maybe a FLAC copy as an archive). Thanks and keep up the good work!

I first installed the shntool package using Synaptic. This page showed me the command line arguments. But that didn't work as planned.

$ shntool conv -o wav *.shn
shntool [conv]: warning: failed to read data from input file using format: [shn]
shntool [conv]: + you may not have permission to read file: [jlc2003-02-14d1t01.shn]
shntool [conv]: + arguments may be incorrect for decoder: [shorten]
shntool [conv]: + verify that the decoder is installed and in your PATH
shntool [conv]: + this file may be unsupported, truncated or corrupt
I needed to download the Shorten codec too (shorten-3.6.1.tar.gz)... but would not compile because the C compiler cannot create executables. Fixing that was a simple:
$ sudo apt-get install libc6-dev g++ gcc
Then I was back to compiling and installing with:
$ ./configure
$ make
$ make check
$ sudo make install
And now I can convert the Shorten files to wav files (or FLAC but that takes more processing and I want to go to mp3 eventually so instead of going Shorten -> FLAC -> WAV -> mp3 I decided to just go Shorten -> WAV -> mp3. I did convert a few to FLAC which worked well. (To do FLAC, use shntool conv -o flac *.shn, wav is the default as you see below.)
$ shntool conv *.shn
Converting [jlc2003-02-14d1t01.shn] (0:35.65) --> [jlc2003-02-14d1t01.wav] : 100% OK
Converting [jlc2003-02-14d1t02.shn] (5:18.22) --> [jlc2003-02-14d1t02.wav] : 100% OK
...
To then convert your wav files to mp3 I would suggest lame (LAME Ain't an Mp3 Encoder). What else is there anyway?
$ sudo apt-get install lame
lame does not support batch processing thought like shntool did so I found a good FLAC to mp3 post that helped me write this little gem:
$ for file in *.wav; do $(lame -V2 "$file" "${file%.wav}.mp3"); done
using the -V2 option will encode the mp3s with variable bit rate at a fairly high quality (4 is default with a range of 0 to 10 and 0 being the best quality)

Now instead of the about 1.2GB of shn files, I have 272MB of mp3s to listen to most anywhere.

One final resource I found helpful was the shn in Ubuntu thread. Enjoy your music.

11 comments:

noomninam said...

Thank you! Found this at just the right moment to prevent another annoying, defeatist reboot into the incredibly slow, annoying, painted-itself-into-a-corner kludgy version of Windows. Now playing an incredible Sigur Ros show, Hamburg in 2000, originally broadcast in FM. Su-weet for a Sunday afternoon.

Happy adventuring in Linux!

Neil said...

etree-scripts is a set of perl scripts that includes a shn2mp3 script that should simplify the conversion process.

http://etree-scripts.sourceforge.net/blog/

MarKco said...

Thank you so much! :-)

Joshua said...

I stumbled across this and it is great. Thank You! The only thing I would add is to use checkinstall to keep inside your package manager. Thanks!

Guido Mureddu said...

Thank you! This post was extremely useful. :)

Amy S said...
This comment has been removed by the author.
Amy S said...
This comment has been removed by the author.
alanforduk said...

Just wanted to add my thanks

van_Zeller said...

googling "linux shn converter" brought me here. Just want to thank you for this simple guide.

sunshinetom said...

The following will introduce a step by step guide on how to convert SHN to any other audio formats with the help of the powerful SHN Converter at http://www.bigasoft.com/articles/how-to-convert-shn-to-flac-mp3-wav.html

This guide applies to:

Directly convert SHN to FLAC, WAV, AIFF, Apple lossless ALAC and more lossless audio format
Directly convert SHN to MP3, WMA, AC3, MP2, OGG, AU, RA and etc lossy audio format
Straight convert all kinds of albums, concerts or shows in SHN to any other audio formats
Besides converting SHN, it also applies to convert more recent lossless audio codecs such as FLAC, Monkey's Audio (APE), TTA, and WavPack (WV) to MP3, WAV, WMA, M4A, AC3, OGG, FLAC, MP2, RA, AIFF, AU and etc.

mi25 said...

Note that in Linux, you can convert with ffmpeg. I just converted a folder of .shn to .flac with

for f in *.shn; do b=$(basename "$f" ".shn"); ffmpeg -i "$f" "$b.flac"; done