gnegg programming with passion

ogg2mp3

Introduction

Let's say you are using a device like the excellent Sonos multi room system to listen to music at home (or in the office for that matter). Many of these devices don't support .OGG files and/or streams.

Unfortunately, the only web radio I would really want to listen to, ormgas, which constantly plays community remixes of video game music, comes only as an ogg/vorbis stream.

This means that until now I have been unable to use my Sonos solution to tune into that stream. Until now.

Here comes streamconvert.php which does exactly what it says to do: It uses sox to on-the-fly convert an ogg stream into a mp3 one, allowing it to be played on the Sonos or similar devices.

As the script is in its very early stages, I didn't even bother creating version numbers and stuff, just head over to github - a public clone of the git repository I'm keeping the script in - and download it from there - it's just this one file.

Usage

Copy the script into any webserver directory running PHP 5.1 and later with allow_url_fopen enabled and you have completed the «installation».

Then, call it either with

http://<yourserver>/streamconvert.php?url=http://ormgas.rainwave.cc/ormgas.m3u

which will output an m3u-playlist pointing to itself as it is required by the majority of devices which can't handle a direct stream, or you use

http://<yourserver>/streamconvert.php?url=http://ormgas.rainwave.cc/ormgas.m3u&play=1

to acess the converted stream.

The script will automatically do the right thing whether you provide it with the URL of a playlist (in m3u format) or of the stream itself (this is a new feature since October 2008 - earlier it just looked at the URL and made assumptions).

Known issues

  • I guess the current buffering method is a bit flaky. Aside of not creating a buffer even close to being big enough to be independent of fluctuation in network bandwidth, I could do a much better job in the selection of buffer sizes put into sox
  • I have no idea how to move the metadata embedded in the OGG stream over to the MP3 stream.

Of course I'll gladly accept any patch to fix these issues.

License

The script is licensed under the MIT license which goes like this:

Copyright © 2008 Philip Hofstetter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.