Slashdot Mirror


MP3 Streaming on Demand?

Joe asks: "I've checked freshmeat a number of times, but I can't seem to find any software that will stream mp3 files 'on demand'. Most software for mp3 streaming (be it windows or unix) is based on the broadcast model (shoutcast/icecast), where a fixed or growing playlist keeps playing at all times. What I want is something that works on the 'play samples' model, where a sample of the tune is played automatically through a streaming protocol, rather than downloaded and played once downloaded. Any such beast exist? If not, why not?"

"I suppose with enough fidgetting, one could write a cgi program (even as a /bin/sh script) that would start a new icecast process on a particular port, start the shout stream, and return to the browser the "playlist" that would signal the browser to start winamp/xmms on the appropriate port; the "start the shout stream" process would wait play silence for a few seconds before shouting the desired mp3 in order to give time to the player...but that seems rather kluge-like."

14 comments

  1. cgi is the key by billcopc · · Score: 3

    You stepped right over the solution without noticing it. Just make a CGI that will stream the MP3 directly to the player. Just make a normal playlist that points to your CGI (probably with a parameter for the desired soundfile). The playlist will be passed on to the mp3 player, which will then HTTP open the CGI, where you can start feeding the music data requested. Piece of cake.

    --
    -Billco, Fnarg.com
  2. icecast can do it, but... by jmoffitt · · Score: 1

    icecast can do it. if you drop files into the static_dir, you can get them from http://icecast-server.whatever.com:8000/file/some. mp3 icecast isn't built for on demand streaming, since apache does that job quite nicely. just get an m3u file, and link to the mp3 on the web server. it works quite nicely. try this for details.

  3. Mp3 Streaming - history, hints by RomulusNR · · Score: 2

    People have correctly pointed out that most "decent" mp3 players have had this functionality for a while. Winamp actually didn't have it at first if I recall. Other than that though, the ability to stream MP3 has been around -- and been done the same way -- since the very first MP3 player, WinPlay3. Winamp's method was more or less copied WP3's.

    Anyway, if you enter a URL in the Play Location: window of Winamp (ctrl-click on the eject button, or Ctrl-L), it will stream an MP3 at that location.

    The bitch is that most web browsers will preempt streaming, waiting for the file to be fully downloaded before it passes it onto any helper app. This is in theory safer, but ya oughtta be able to turn off the deferral.

    The answer of streaming from web links is to use M3U playlists for the file(s) you want to stream. The playlist contains the URL of the streamworthy file, and the web browser is none the wiser -- it passes the very small M3U onto the player, which then takes over the downloading of the file listed inside, streaming it in the meantime.

    I suppose therefore you might want a script on your server that will generate M3U output on the fly for your online music collection. Such a script would be very simple -- in theory it only needs to output text data consisting of a URL to the actual file.

    However, I usually just use "Copy Link Location" or "Copy Shortcut" from the right-click-over-link menu, and then paste it into the Winamp "Play Location" window. And there you have it, instant streaming on demand. :)
    --

    --
    Terrorists can attack freedom, but only Congress can destroy it.
    1. Re:Mp3 Streaming - history, hints by RomulusNR · · Score: 1

      By the way, mpg123 for linux/unix will also accept an http URL on the command line and will stream.
      --

      --
      Terrorists can attack freedom, but only Congress can destroy it.
  4. This has been under our noses forever. by billcopc · · Score: 1

    Quick answer : just look at MP3.Com and see how they did it.. a CGI that spits out M3U (or is it PLS) playlists.

    --
    -Billco, Fnarg.com
  5. bagh by angry+old+man · · Score: 3
    bagh. Back in my day we didn't have fancy schmancy streaming digital audio.

    If we wanted to listen to something on our computer, we plopped a music CD in the CDROM tray. If we wanted to listen to something in a different part of our house, we didn't stream it to the computer in that room, we turned the volume up in the other room.

    Nowadays, all you kids with your stream this, or rip that attitudes are causing those hard working record industry executives to get there panties in a bundle. The recording industry barely gets by on its razor thin profit margins, and any of this digital streaming might cause them to to go bust! If you weren't such lazy hooligans, you'd carry around your store bought CD around with you and listen to that.

    --
    -vax computer, vi, lynx. 'nuf said
  6. Here's one we use by steve9000 · · Score: 2



    http://www.lyra.org/greg/edna

    It's a standalone http mp3 server. In one
    python script. It sends .m3u to your player
    so that the mp3s are streamed. It can also
    shuffle and play recursively.

    Highly recommended.

    Stephen.

    (for the other end of things 'jack' is an
    excellent ripper/encoder btw.)

  7. http is fine by pbryan · · Score: 2

    As long as you are not looking for neato features like direct seek and realtime "live audio" streaming, http is a fine protocol for streaming mp3. Most decent mp3 players (xmms, mpg123 -b, sonique, winamp) buffer the input stream to handle bumps in the stream. Icecast streams through the http protocol -- it's designed to provide content using the broadcast model instead of pointcast. Apache is a good platform for individual streams.

    --

    My car gets 40 rods to the hogshead, and that's the way I likes it!

  8. HTTP Streaming by qux.net · · Score: 1

    I've had a solution like this for about 6 months now. XMMS (and Winamp, and I think a few people have used Real* stuff with it too) supports streaming via HTTP. I just set up an apache virtualhost pointing to my MP3 shares, and another pointing to index pages. To make the index pages I just created playlists of the files and threw them through a perl script that spit out the HTML complete with lists and such (I usually did one each time I had a bunch to add an customized them greatly for the task, but I could probably dig one out if it'd help). The links they created were basically the filename with characters escaped and the hostname prepended, and thrown after a m3u creating cgi (basically returned a text listing of whatever addresses were passed). This allowed me to have it request entire categories as long as the cgi could sort it.

    The two virtualhosts were on the same machine, and could be setup on one if needed - I split them for easy of use, maintenance, and security (I set it up while at school, so I wanted the thing restricted so I didn't become the biggest bandwidth user on campus).

    As for speed and such. When I click on a link the song is usually started before my finger is lifted off the mouse button (both at home on 100Mbps LAN and at school on the 10Mbps LAN). The response time is basically a factor of how fast the server is, how fast your browser can get the address to the player, and how fast the player can parse and request the address.

  9. Check MP3.com by barbaBob · · Score: 1
    And see how they do it. They send you a playlist, which causes your browser to open your MP3 player (if your browser is configured correctly) which starts to stream the file requested.

    Look at a typical MP3.com URL:
    http://chooser.mp3.com/cgi-bin/play/play.cgi/[sn ip session id]/electronic.m3u

    Probably a simple CGI which stores the session data (things like IP, browser, OS etc.) and serves you the MP3 trough the playlist.

    bBob

    --

    --

    --
    *sig*

  10. cgi streaming by Jamie+Zawinski · · Score: 2

    Streaming an MP3 file out of a CGI works fine, but if you're concerned about bandwidth, you should be sure to rate-limit it: don't send the data much faster than the bitrate of the file.

    1. Re:cgi streaming by DrSkwid · · Score: 1

      how?
      .oO0Oo.

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  11. Apache::MP3 by nazgul@somewhere.com · · Score: 1

    You should be able to get it from any Perl respository. It makes your Apache server treat directoryname.pls as a playlist, and returns a list of streaming mp3 links suitable for WinAmp or your favorite player. Not fancy, but works well.

  12. thanks for the help... by acroyear · · Score: 2
    I found edna about 2 days after i submitted the question, and it seemed to do the job well.

    In addition, I got the apache system to work well enough for my needs (though i need to fitz with LAME to get smaller files -- 44/128s would kill my bitrate quota). the trick was to add the "audio/x-mpegurl m3u" line to the server mime.types file (it isn't there by default).

    If you are using someone else's server (you can't change conf info), you can also do it by puting the line "AddType audio/x-mpegurl .m3u" in the .htaccess file for the directory containing the m3us. to minimize constant .htaccess accessing (apache will look it up for every load in that path), you might consider putting all the .m3u files in a single directory by themselves.

    Thanks for the pointers...

    --
    "But remember, most lynch mobs aren't this nice." (H.Simpson)
    -- Joe