Tuesday, May 29, 2007

How to save a Showtime (MMS) video stream to disk

Microsoft IT's Showtime offers tons of useful videos. Yesterday I tried to watch Advanced Malware Cleaning, by Mark Russinovich, but got immediately upset by the glitches of the streamed content, even though I tried to watch the low-res 300 kbps version on my 400 kbps connection. Showtime's FAQ says you can download the video if logged through .NET Passport. I didn't find any link which would allow me to do that, however.

After a quick search I found an article explaining how to save any video stream with the excellent VLC player. Unfortunately, it assumes you can view the source code of the web page with the embedded video and copy the actual link to paste into VLC. That's not the case of Showtime's videos. They play on a Windows Media Player control inside the browser which hides the video address.

I found two ways to workaround this. The first is to use URL snooper, whose latest version (v2.18.01 Beta) has a simple mode which starts listing multimedia links as soon as you launch the executable. URL snooper uses WinPCap to analyze every packet transmitted across the network card.

Finding the hidden URL with Firebug
Figure 1


The second way is to use Firefox's Firebug to find the hidden object inside the HTML. Figure 1 shows the hidden link for the Advanced Malware Cleaning video, which, if appended to the domain name, yields:

http://msexp.streamnavig.com/platform/msexp/metafile.asp?e=E0072&s=0369_en_w

That's not yet the real link, but just a metafile that will redirect the player later. You may open that link in Windows Media Player but you still can't view the actual address. To download the metafile paste that link into the address bar of Firefox and press Enter. It'll launch Windows Media Player. Just close it. Back to Firefox type Ctrl-S to save the page. Open the saved file in a text editor and look at the ref tag. That's what we're looking for. This is what I got:

<asx version="3.0">
<abstract>Microsoft</abstract>
<author>Microsoft</author>
<copyright>Microsoft</copyright>
<entry>
<abstract>Microsoft</abstract>
<ref href="mms://a2.v148539.c14853.g.vm.akamaistream.net/5/2/14853/v003/1a1a1a72db3eb01f920167db4fb41745a9188ffd69d8399dcb2c97f865c62f5dc02f9ccbfc30689dd0ff6cdf44bc2c5bc83ba01888b7fc2c5c93c5/0369_w.asf" />
<title>Microsoft</title>
<copyright>Microsoft</copyright>
<author>Microsoft</author>
</entry>
</asx>

In my case, the URL is:

mms://a2.v148539.c14853.g.vm.akamaistream.net/5/2/14853/v003/1a1a1a72db3eb01f920167db4fb41745a9188ffd69d8399dcb2c97f865c62f5dc02f9ccbfc30689dd0ff6cdf44bc2c5bc83ba01888b7fc2c5c93c5/0369_w.asf

If you used URL snooper, at this point you already had the real link. Now just follow the standard procedures for VLC (mine is 0.8.6a):

  1. Go to File, Open network stream...

  2. Select HTTP/HTTPS/FTP/MMS.

  3. In Advanced options, check Stream/save and click Settings.

  4. In the Outputs section, check File, choose a filename, specifying the appropriate extension (in the case above ASF) and, very important, check Dump raw input.

  5. When the download finishes just open the file in Windows Media Player.

When you have a time just check how great VLC is, despite the extremely simple interface. With the exception of Real, it is able to play any kind of input.