How to play SHOUTcast streams with Subsonic

Tutorials, tips and tricks.

Moderator: moderators

How to play SHOUTcast streams with Subsonic

Postby EnergyCoffee » Sat Mar 10, 2012 11:23 pm


*** This has worked great for me with Subsonic v4.5. I have not been able to get this working in Subsonic v4.6 ***
*** If somebody figures out how to make this work in v4.6, I'd love to know the solution ***

I use my Subsonic server primarily in Jukebox mode, but this also works for streaming via flash player. The disadvantage to using this method is that SHOUTcast playlists must be downloaded to your Subsonic server. This is, however, better than the alternative of not being able to stream SHOUTcast stations via Subsonic.

This is achieved by using a program (mpg123) to convert the SHOUTcast stream to raw PCM, then using LAME to re-encode the PCM audio back to mp3 in real-time. Playlists are saved locally as ".radio" files so that they show up in the web interface as ordinary music files, and so they don't conflict with the way Subsonic handles .pls files (as playlists).

These instructions are for Debian.

Step 1: Download mpg123
Code: Select all
apt-get install mpg123

Step 2: Symlink mpg123 into the Subsonic transcode directory
Code: Select all
ln -s /usr/bin/mpg123 /var/subsonic/transcode/mpg123

Step 3: Go into Subsonic Settings -> Transcoding and add a new transcoding option:
Code: Select all
Name: radio > mp3
Convert from: radio
Convert to: mp3
Step 1: mpg123 -q -s -@ %s
Step 2: lame -b %b --tt %t --ta %l --tl %l -r -S --resample 44.1 - -

Step 4: Enable this transcoding option under Settings -> Players

Step 5: Add ".radio" to the Music mask field under Settings -> General

Subsonic should now transcode ".radio" files into a format that can be streamed through any of its players. ".radio" files are simply .pls files that have been saved locally. You can change the extension to whatever you want as long as you also change the extension in the above steps. I chose to use ".radio" as to not conflict with .pls (playlists) that Subsonic already recognizes.

--------------------

Now you can download .pls files (SHOUTcast stream playlists), rename them to ".radio", and place them in an accessible folder on your Subsonic server.

For instance, on my server, I have a directory "/inet-radio" that I've added into Settings -> Media folders. I can either copy .pls files from my computer into that folder and rename them, or I can use a tool like wget to download playlists directly to the folder.

Here's an example of using wget to download the Digitally Imported Vocal Trance pls file, and place it into my inet-radio folder with the proper .radio extension.
Code: Select all
wget --output-document /inet-radio/Vocal-Trance.radio http://listen.di.fm/public3/vocaltrance.pls

These playlists now show up in Subsonic just like any other audio file. They will play in both Jukebox and flash player modes. I've also successfully streamed stations to my Android phone using the Subsonic mobile app.
EnergyCoffee
 
Posts: 1
Joined: Sat Mar 10, 2012 10:40 pm

Re: How to play SHOUTcast streams with Subsonic

Postby somerandomhash » Wed May 30, 2012 5:01 pm

EnergyCoffee wrote:
*** If somebody figures out how to make this work in v4.6, I'd love to know the solution ***


I can confirm I have gotten this to work with 4.6 (under Windows) I *suspect* the issue may simply be adding:

Step 5: Add "radio" to the Music mask field under Settings -> General (remove the leading . )

These instructions are for Windows.

Step 1: Download mpg123

http://www.mpg123.de/download/win32 -> mpg123-1.14.2-static-x86.zip

Step 2: Copy mpg123 into the Subsonic transcode directory

C:\pathto\subsonic\transcode\mpg123.exe

Step 3: Go into Subsonic Settings -> Transcoding and add a new transcoding option:
Code: Select all
Name: radio > mp3
Convert from: radio
Convert to: mp3
Step 1: mpg123 -q -s -@ %s
Step 2: lame -b %b --tt %t --ta %l --tl %l -r -S --resample 44.1 - -

Step 4: Enable this transcoding option under Settings -> Players

Step 5: Add "radio" to the Music mask field under Settings -> General (remove the leading . )

Subsonic should now transcode ".radio" files into a format that can be streamed through any of its players. ".radio" files are simply .pls files that have been saved locally. You can change the extension to whatever you want as long as you also change the extension in the above steps. I chose to use ".radio" as to not conflict with .pls (playlists) that Subsonic already recognizes.

Many thanks to EnergyCoffee for the original solution :)
somerandomhash
 
Posts: 1
Joined: Wed May 30, 2012 4:47 pm

Re: How to play SHOUTcast streams with Subsonic

Postby chown » Sat Aug 18, 2012 4:55 am

Did you guys get these streams to play in the Android Subsonic client? Mine plays ok in the web player unless the flash player catches up with the stream and just stops playing. The Android client plays like 1 second of the station then acts like it downloaded/cached the song/station so not a true stream. It would probably be easier to just use a Shoutcast player for your phone but I wanted to transcode it to a lower bitrate if the stream doesn't have any <128kbps. :(
chown
 
Posts: 1
Joined: Sat Aug 18, 2012 4:52 am

Re: How to play SHOUTcast streams with Subsonic

Postby stozher » Sat Jun 22, 2013 6:55 pm

/var/subsonic/transcode/radio.sh
Code: Select all
wget -q -O - -i "$1" | cut -d "=" -f 2 | grep "^http://" | sort -R | xargs -L 1 wget -q -O -

chmod X attribute to create script executable!

Transcoding: radio-mp3 | radio | mp3 | radio.sh %s
Settings/General: add "radio" to "Music files"... if you need add second step to transcode to some bitrate.

example.radio file
Code: Select all
http://***/public3/the80s.pls
http://music.stozher.com:8080/login.view?user=guest&password=
User avatar
stozher
 
Posts: 313
Joined: Tue Nov 16, 2010 10:56 am
Location: Sofia, Bulgaria

Re: How to play SHOUTcast streams with Subsonic

Postby lolomm » Mon Dec 02, 2013 10:28 am

Hi,
Does it still work with 4.8 windows? Sounds great if its would working.

I have setup how it was described, but it don't works. :-(

If i remove the phase 2 (lame encoding) , the flashplayer's "seconds counter" run very fast, I think because the input RAW stream.

When i add the second phase lame encoding again, it seems that the stream is played, but the "second counter" freezed at 0 seconds...

[02.12.13 11:47:30 MEZ] WARN StreamController Unknown duration for Radio - Chillout Dreams. Unable to estimate transcoded size.
[02.12.13 11:47:30 MEZ] INFO PlayQueueInputStream lolomm listening to "radio\Radio - Chillout Dreams.radio"
[02.12.13 11:47:30 MEZ] DEBUG TranscodeInputStream Starting transcoder: [c:\subsonic\transcode\mpg123] [-q] [-s] [-@] [d:\musik\radio\Radio - Chillout Dreams.radio]
[02.12.13 11:47:30 MEZ] WARN TranscodingService Failed to transcode Radio - Chillout Dreams. Using original.

EDIT:

i modifies the second phase encoding:
lame -b %b -r -S --resample 44.1 - -

now it works.....
lolomm
 
Posts: 13
Joined: Fri Nov 29, 2013 10:20 am

Re: How to play SHOUTcast streams with Subsonic

Postby santivdk » Fri Apr 17, 2015 11:47 am

Hi,

I know this is an old thread, but I hope someone is still "listening". Thanks for providing this great solution, it still works like a charm in version 5.2.1. There is, however, one thing I can't seem to figure out. Most .pls files play great after going through the 2 step conversion describes, but there are a few that play at double speed (or at least way too fast..) after the conversion. I tried changing the sample rate, but that did not help. Did any one else gave this problem and is there a known solution perhaps?
KInd regards,
Santi
santivdk
 
Posts: 3
Joined: Fri Apr 17, 2015 11:38 am


Return to Tutorials

Who is online

Users browsing this forum: Bing [Bot] and 1 guest