Showing posts with label hacks. Show all posts
Showing posts with label hacks. Show all posts

Sunday, October 26, 2008

The amazing hacks of an amazing researcher

Maybe you remember from way back sometime in 2005 this crazy nerd running around with his "poor man's steadycam", a concoction of some metal pipes, weight, bolt and nuts, as featured on Hak5? (Wow, I just realized I had accidentally unsubscribed to Hak5, now I've got some ten great episodes to watch, yay!)


You don't? Well, turns out this same nutty nerd has really made it big with his Wii remote hacks on TED.com among other places.


So, of course I spent all last night checking out his amazing projects, the projector-based tracking is not bad either. Johnny Chung Lee is now a researcher of interface design and stuff at Carnegie Mellon Universityfor Microsoft Applied Sciences, and a productive one to add. Much more productive than the researchers I remember from Chalmers University, maybe they could inherit some these people's urgency to create amazing prototypes? I dunno. Anyway, not all that many of the "small people" have the opportunity to turn up several times in the limelight and I will continue to be amazed by and admire this guy - go Johnny Lee!

(Update: I am so gonna make these whiteboards myself)

Wednesday, June 18, 2008

How to download webradio and webtv, RealMedia (RTSP) or Windows Media (MMS) streams easily - a comprehensive ripping tutorial

Now that it's once again time for P1 Sommar (check out my talker schedule!) for me it also means it's time to freshen up the streaming media dumping skills. I happen to enjoy my webradio with music left in rather than the crippled music-less media files Swedish Radio / SVT provide. Below I in three (an optional fourth) steps show that there is little practical difference between providing something through a streaming media protocol or providing it for download - it is pretty easy to download and save it for later anyway.

The case is pretty simple - when you listen to webradio or webtv, the browser window commonly embeds a player which is given the URL of a "playlist" provided over regular HTTP. The playlist however contains the URL of the actual media stream, commonly "hidden" to only be accessible using a streaming media protocol like RTSP or MMS. Media providers think (or hope, or assume, it doesn't really matter) that players able to receive these protocols will not allow the user to save the media stream to be replayed later and thus are more relaxed about letting licensed content be broadcasted through streaming media protocols. Fortunately using an open-source player like MPlayer or a download manager like FlashGet, also media streams can be saved like a charm.

The gray areas of radio ripping is discussed over at copyriot.se (in Swedish) and also don't miss out my list of great SR and SVT shows with all URLs conveniently in one place. Curiously this is not a simple case of piracy - the DMCA would surely be quick to decide, but there are plenty of arguable fair use purposes for stream ripping such as saving the content for replay later, bringing it with you on a portable player or converting it into a suitable format. The case is especially strong for content which is anyway broadcasted over analog radio or TV and as such are anyway freely available. However, IANAL, do this on your own risk and don't break any applicable laws.

  1. Open the source code of the page or frame the regular player is embedded in. Get the playlist SRC by looking for the player object parameter "PARAM NAME="SRC" VALUE="...". However, what comes after "VALUE=" commonly does not start with "http://" and thus is a relative URL, see the next point for where to find the base location to be able to download the playlist. Update: You can also try right-clicking on the Real Player embedded in the page and selecting "Copy clip URL" instead of even touching the source code




    If the playlist SRC above was a relative URL, get the base location from the location displayed in the frame or page info:



  2. Add the location and the playlist name together to download the playlist from that URL. The playlist then contains the stream URL at a line saying "src=":
    $ wget -O "030702 Mustafa Can.ram" "http://www.sr.se/webbradio/include/CreatePlaylist.asp?Type=db&Id=1115295&broadcastDate=&IsBlock=0&AudioFormat=1&AvailableAudioFormats=1"
    $ grep src "030702 Mustafa Can.ram"
    <audio src="rtsp://lyssna-rm.sr.se/isidor/p1/2008/04/47_webb_rh_sthlm_mustafa_cans_sommar_2_jul_p1-063383a05_376ff8c2_r2.rm"/>

  3. Download the stream with a program capable of receiving the protocol at hand (see wikipedia lists for rtsp:// and mms://, though I know for a fact some download programs like FlashGet for Windows or CocoaJT for Mac (in French ?!) and others listed here are also very capable of that). Below I use MPlayer, which works the same both for Linux, Windows and Mac OS X (except under Windows the binary is mplayer.exe, and under Mac OS X you should use /Applications/MPlayer OS X 2.app/Contents/Resources/mplayer.app/Contents/MacOS/mplayer ):

    $ mplayer -dumpfile "030702 Mustafa Can.rm" -dumpstream "rtsp://lyssna-rm.sr.se/isidor/p1/2008/04/47_webb_rh_sthlm_mustafa_cans_sommar_2_jul_p1-063383a05_376ff8c2_r2.rm"

  4. If you want to, edit the audio with Audacity, convert it to mp3 with lame or even iTunes. Video you can edit with JayCut and convert with FFmpeg or any from the jungle of mediocre video conversion tools there are out there, like Handbrake for Mac OS X or Videora iPod Converter for Windows.

    A note about file types, with RealMedia the playlist is a .ram file and the audio or video contained in .ra, .rv, .rm or .rmvb streams. With Windows Media, the playlist file is commonly an .asx or .asf file containing a .wmv or .wma stream. Also, in an .asx file, the stream address is found by the href parameter. I have not looked currently looked into ripping other formats such as Quicktime or Flash video.


And friends, remember sharing is caring!

(Update: I found out that my MPlayer OS X is both a bit outdated and while it has RTSP-streaming support, it doesn't seem to have the RealMedia codec. So to be able to decode the .rm to .wav on my mac before I clean it up in Audacity and export to wav, I found out the monster package of codes FFmpeg (it's Mac gui sister program is the somewhat less reliable FFmpegX) of course does it excellently like this:
$ ffmpeg -i foo.rm foo.wav
I also checked out the blogger exertia who seems to like Videolan/VLC, but while it's better maintained than MPlayer OS X, it didn't help me this time)