Itatsumaki has asked for the wisdom of the Perl Monks concerning the following question:

Perhaps I am fundamentally misunderstanding my formats and protocols, but I was surprised to find that I couldn't easily automate the download of streaming media via LWP.

I have a fairly large set (a couple of hundred) of streaming video/audio clips that I wanted to download regularly for a client across an intranet as a backup procedure, and I just can't seem to make it work. The server is an mms server, which is a micro$oft product, and somehow IE knows well enough to hand it off to Media-Player, so perhaps I could emulate that and just save the streamed output?

It was surprisingly hard to find a web-based MMS server to show a script on, but here is one in Japan. It might be a bit slow, given the distance but the principle should be the same. The file plays okay in media-player, but I can't grab it with LWP using this code:

use LWP::UserAgent; my $agent = LWP::UserAgent->new(); my $response = $agent->get('mms://wms01.aii.co.jp/hotshot/yoshioka.wmv +'); open(OUT, '>test1.wmv'); binmode OUT; print OUT $$response{content};

Any ideas, advice, or suggestions much appreciated. Especially if I'm under some fundamental misconception that it *is* possible to grab streaming media files via PERL! :) I should mention: it fails with both LWP::UserAgent and LWP::Simple, and it seems to just not return any content. I suppose it isn't returning an HTTP-header, which must be the start of my problems....

Tats

Replies are listed 'Best First'.
Re: Download Streaming Media?
by iburrell (Chaplain) on Apr 18, 2003 at 20:56 UTC
    MMS uses a proprietary protocol. Microsoft has not released a specification for it. The SDP project (http://sdp.ppona.com/) is working on reverse engineering the protocol. Nobody has implemented a Perl interface.

    Do you need to the download the files through the streaming interface? Are there files on disk you can copy? You could copy the files using a standard mechanisms, like SMB, NFS, FTP, HTTP, SSH, etc.

      Ahh, that answers it then. I'll check on SDP, but I'll just have to set up an FTP server then. I wanted to avoid that since the mms was already up-and-running. If MS has released an API to it, I suppose someone could implement a wrapper to it but... why go to that much trouble to replace FTP? :)

      Thanks for your help,
      Tats
        The idea behind it all is "content control". That's why it is not to be expected that Microsft will ever release the specification for MMS.

        BTW the home page for the SDP project is here.

        If you're looking for a more open alternative to MMS, you can use the Shoutcast streaming protocol, which is more openly based on HTTP. Apache can serve as such a server, or something very similar, with mod_perl and the module Apache::MP3. That way, you get the best of both worlds.

Re: Download Streaming Media?
by Limbic~Region (Chancellor) on Apr 18, 2003 at 21:25 UTC
    Itatsumaki,
    There is a commercial product here that does what you are looking for. The cost looks fairly inexpensive.

    You can also do a search on ASFRecorder. Best as I can tell, a guy reverse engineered how the streaming media worked and provided open source on how to do it. The author remained anonymous, and got hired by the very company he - well, you get the picture. It provides a batch operation. The two most relavent links are here:

  • Down Load
  • Sourceforge

    Of course this is written in C and would have to be converted to Perl unless you just want to use one of these tools.

    I in no way endorse the use of the this product to make illegal copies of media that is not owned or licensed.

    Cheers - L~R

      Thanks L~R
Re: Download Streaming Media?
by isotope (Deacon) on Apr 18, 2003 at 21:52 UTC
    ls -la /usr/lib/perl5/site_perl/5.6.1/LWP/Protocol total 96 drwxr-xr-x 2 root root 4096 Mar 10 20:18 . drwxr-xr-x 4 root root 4096 Mar 10 20:18 .. -r--r--r-- 1 root root 1279 Nov 19 1998 data.pm -r--r--r-- 1 root root 3827 Aug 6 2001 file.pm -r--r--r-- 1 root root 17014 Oct 26 2001 ftp.pm -r--r--r-- 1 root root 1823 Apr 9 2001 GHTTP.pm -r--r--r-- 1 root root 5783 Nov 19 1998 gopher.pm -r--r--r-- 1 root root 8459 Oct 26 2001 http10.pm -r--r--r-- 1 root root 10566 Sep 20 2002 http.pm -r--r--r-- 1 root root 1822 Oct 26 2001 https10.pm -r--r--r-- 1 root root 1236 Nov 16 2001 https.pm -r--r--r-- 1 root root 4190 Mar 19 1999 mailto.pm -r--r--r-- 1 root root 3749 Nov 19 1998 nntp.pm -r--r--r-- 1 root root 630 May 5 2001 nogo.pm
    LWP only supports a certain list of protocols. mms:// is not one of them. One could certainly learn about the protocol and write mms.pm for LWP, but it appears that no one has done so at this time. If you follow this example, the problem should become more clear:

    # Create a user agent object use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # Create a request my $req = HTTP::Request->new(POST => 'http://www.perl.com/cgi +-bin/BugGl impse'); $req->content_type('application/x-www-form-urlencoded'); $req->content('match=www&errors=0'); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print $res->content; } else { print "Bad luck this time\n"; }
    Note the creation of an HTTP::Request object. --isotope
    http://www.skylab.org/~isotope/
A reply falls below the community's threshold of quality. You may see it by logging in.