Monday, October 13, 2008

Internet Radio Station Part II

Internet Radio Broadcasting

The problem for our students will be they can't do anything in the computer labs as the machines only run Windows. I got the IT staff to install VirtualBox hoping that each student could create a VM but the IT dept won't let them do this - they can only define a VM to boot a livecd with. So how to do broadcasting when you can't set up anything?

The answer of course is open source to the rescue - having access to the source code means you can innovate and come up with solutions to problems. Can't install? - then run the application you want from a USB stick. They are now large enough and fast enough to be useful for this purpose. And while booting Linux from a USB would be the best solution - the lab locks down the BIOS so this is not possible. They should really provide a lab of diskless machines that boot from USB.

Apps that don't need installing are called portable applications and while it is possible to write windows apps that do this (remember the old .com executables?), it is not common because most window apps need to be in the registry and use windows system DLLs. However, many open source apps can be modified to run under windows without being installed. A list can be found at:
http://portableapps.com/support and there is also a large list linked from the wikipedia article.

The download site offers a choice of just the platform or the platform and applications. You can get a full suite of software that will run on a 512k stick.

Download PortableApps.com Suite and Platform

Get all the apps you need at once or add only the apps you want. Pick the download that's right for you:

Platform Only Suite Light Suite Standard
Download PortableApps.com Platform (Do Not Right-Click) Download PortableApps.com Suite Light (Do Not Right-Click) Download PortableApps.com Suite (Do Not Right-Click)
Download Size1MB download35MB download113MB download
Free Space Needed1.2MB installed100MB installed350MB installed
Recommended DeviceAll devices256MB+ devices512MB+ devices
Supported LanguageMultilingualEnglishEnglish
PortableApps.com Platform
PortableApps.com MenuXXX
PortableApps.com BackupXXX
Custom Folders, Icons & AutorunXXX
Bundled Apps
Mozilla Firefox, Portable Edition (web browser)
XX
Mozilla Thunderbird, Portable Edition (email)
XX
Mozilla Sunbird, Portable Edition (calendar/tasks)
XX
ClamWin Portable (antivirus)
XX
Pidgin Portable (instant messaging)
XX
Sumatra PDF Portable (PDF reader)
XX
KeePass Portable (password manager)
XX
Sudoku Portable (game)
XX
Mines-Perfect Portable (game)
XX
CoolPlayer+ Portable (audio player)
XX
OpenOffice.org Portable (office suite)
- Writer (word processor)
- Calc (spreadsheet)
- Impress (presentations)
- Base (database utility)
- Draw (drawing)


X
AbiWord Portable (word processor)
X


We decide to take only the platform as we want to add our own applications, the VLC media player and the Audacity sound editor in particular. VLC can stream audio so we want to see if it can work over a USB stick as a pirate Internet radio station.

Step 1 - Plug in a USB stick.
Step 2 - Download and save the portable apps platform software to your USB stick
Step 3 - Run the portableappscomplatformsetup_1.1.exe installer from your USB stick
Step 4 - Type in the drive letter of your USB stick and click OK
Step 5 - When the install is finished double-click the StartPortableApps.exe file

The menu appears. It can also be minimized to the taskbar. Right now the menu is empty as we just downloaded the platform. Now we need to get some portable apps so off to http://portableapps.com/apps/ we go.

We select Audacity which the site says "Audacity Portable is the popular Audacity audio editor packaged as a portable app, so you can take your audio files along with everything you need to edit and record on the go". We also grab coolplayer, a light audio player that does streaming and the popular and excellent VLC media player.

We first installed Audacity by running the installer and it selected its install folder on the USB drive. We then added MP3 support by copying lame_enc.dll from the winamp folder we had already installed it in to the AudacityPortable\App\LAME directory.

Finally we installed the VLC media player to the USB stick.

The next step was to add the newly installed applications to the portable apps menu. At this point we find out we should have installed from within the portable apps menu and it would have automatically added the apps to the menu. No problem - we quit the p-apps platform and run it again and the new programs are on the menu.

Now to set up VLC as a streaming audio server. First we copy over some content as we want to run both content and server off the USB stick as a test. We then run VLC and set the downloading of album art to manual and turn off the update checking.

Now that the program is running we select Media, File Open and choose a bunch of files. The first file starts playing so we stop it.

We select Audio, Audio Device, Mono from the menu
We select Playlist, Show Playlist from the menu to display our selections
We highlight the selections and right-click and select Stream from the menu

This brings up the Stream Output dialog box. Check the box next to Play Locally under Outputs. When streaming to another system we would not play the file on the server, but this option is useful for testing that our audio plays ok.

We have a number of options under outputs. We can use check the HTTP box and add the IP address of the machine VLC is running on. This should give us access using a web browser - of course the web browser needs to have the proper extensions or plug-ins to play audio files. Since we are using Firefox on Ubuntu the firefox mplayer extension does the job, however users of IE may be out of luck. There is also an icecast option - actually this would be good!

The other option is to click the RTP box which ungreys the UDP box. Either one should work and stream the audio so it could be picked up by another VLC client running on a second comptuer.

Let's try the HTTP option first. We add 191.168.1.108 as the address and the service is running on port 8000.

We also turn on VLC's web interface by selecting Tools, Add Interface, Web Interface from the menu. This seems to do nothing and we cannot connect to port 8080.

Under the Profile section we click the Audio Codec tab and select MPEG audio as the codec with a bitrate of 96bps and 1 channel.

We click Stream to start the audio server playing. Now off to the second computer and run firefox and goto http://192.168.1.108:8000 and all we get is a spinning loading. We can hear the file playing locally. So we return to the Stream Output dialog box and change the setting to RTP with the same address and fire up VLC on the second computer.

Select File, Open Network Stream. UDP is selected so we click OK and VLC should start playing, but it does not. We change to udp/multicast and enter in the ip address of 192.168.1.108 but this returns an 'unable to open' error message. It looks like our laptop is not streaming at all.

Perhaps download a portable version of icecast? WE do but it is in .rar format so we also download the excellent 7-zip portable app and add it to our keychain usb stick. Once we extract we find a portable icecast.exe file in an icecast folder. Do we run this - is it an installer or is it the executable? It does not look to be in paf format. We decide to copy the icecast folder to the portableapps directory on the USB stick as well as our working icecast.xml file.

When we run the program it asks for the location of the M3U file to stream. M3U is a winamp file that stores playlists. It is actually a text file that looks something like this:

#EXTM3U
#EXTINF:134,Have A Holly Jolly Christmas - A Holly Jolly Christmas
\xmasprogram\Burl Ives\Have A Holly Jolly Christmas\A Holly Jolly Christmas.mp3

M3U files are now used as a single entry point for streaming content over the internet.

Each location is placed on a new line. The 134 indicates the length in seconds, although a value of -1 should be used when the media file is a streaming file. Next comes the display title. The next line indicates the location of the content. The location can be either an absolute or relative path pathnames (e.g., "E:\ives\holly.mp3" or "\ives\holly.mp3") or they can be URLs. The file can also include comments, prefaced by the "#" character. For portability reason it would be best to use relative paths.

Probably the easiest thing to do would be to put all the content into a folder and then place the folder path into the M3U file so that when the media player starts it plays all the content which then gets streamed. Here is an example from Wikipedia:

#EXTM3U

#EXTINF:123,Sample title
Sample.mp3

#EXTINF:321,Example title
Greatest Hits\Example.ogg
So first step is to move all the content on the flash drive to a folder and edit the M3U file. So we created a content folder on the flash drive. Instead of hand-coding the M3U file we ran winamp and right-clicked and choose Playlist Editor from the menu, removed the existing entries in the playlist and pointed winamp to the content folder on the USB drive. We then re-arranged the content in the desired sequence and clicked the List Opts button and saved the list to the USB stick as playlist.m3u.

Ok now we are almost ready to try again. We did notice during the last attempt that the IP address of the portable icecast was incorrect. This could be due to the configuration so we check the icecast folder on the USB stick. We had copied our working icecast.xml file to the stick but let's take a look:

ezstream_mp3.xml is a configuration file - uses localhost:8000 and it looks for a m3u filename but it is currently set to look in c:\program files\winamp\winamp.m3u

This could be a problem as what if the computer you are running the pirate internet radio station on does not have winamp but something useless like windows media player? There was no portable winamp listed on the portableapps site but since winamp doesn't really hook into windows it should be portable. Let's search. Ok there is a :

Portable Winamp 5.35:

So we switch to the windows laptop and download. We start up the portable apps environment and select Options, Install a New App. However, the winamp.exe is not in the portable applications (paf) exe format. So we have to do it by hand. We create a folder in the Portable Apps directory on the USB stick. Run the winamp install and select the folder and click install.

It's writing tons of crap to the stick - all sorts of stuff we don't want. It is the FULL version - 33mb of stuff is installed. We don't need no stinkin visualizations of skins or dsp effects for streaming audio! So don't use the softpedia download. I now either have to prune it manually or uninstall and find a portable lite version. What we need to find is the portable winamp lite 5.1

No joy yet - there is on out there but either you end up at scary sites or get the redirect runaround. Too dangerous to take a windows machine. Let's try installing the non-portable lite version to the USB stick first and removing things like file associations etc.

Run the winamplite installer and choose the minimal version which takes 2.7mb of space. We deselect all associations or icons or other hooks with a custom install and then choose a destination of d:\portableapps\winamp. We select shared settings for all users but choose NOT to copy them to the c:\program files\winamp folder. No downloading of codecs and we click install. We untick the anon stats and tick the do not ask again until the next install in case it has a nag setting.

Next we examine the winamp configuration settings in install.ini and see that everything is pretty much set to =0 but we change the associate with m3u playlist files to =1 and add the line no_registry=1

Since there is no need to unininstall or to run the winamp agent we delele the uninstallwa.exe file and the winampa.exe file. We also run winamp from the USB Stick and right click and select Preferences. We untick the check for new instances and the show winamp in systray stuff and untick the show winamp in windows folders, and untick restore file associations. Not sure about disabling the 3 default plugins - we leave them alone for now.

Next we want to add winamp to the portableapps menu and test it out on a computer without winamp installed.

First we run portableapps and the winamp icon is displayed in our list. If it was not we would select Options, Refresh Apps Icons from the menu.

When we run the portableicecast and feed it our playlist.M3U file we get the message:

"your stream is on: http://172.33.16.23:8000/stream.m3u" which should not be as the ip address of the machine is 192.168.1.110. Could it be the person who created this version hard-coded the server ip? There are no notes with the file.

Ok for now looks like we will have to come back later to the idea of running a portable pirate radio station from USB and work on running it from the laptop.

No comments: