in reply to Perl vs. PHP in streaming a file

I don't understand why you are using perl at all... what is it you are doing that Apache can't do? Taking a static file, and feeding it to a network socket is exactly what httpd does all day and night, and presumably is optimised pretty well to do... this isn't meant to sound negative - I'm really curious what you are gaining. I can certainly stream music that way, and mplayer has worked with divx too, although I do that less often.

Replies are listed 'Best First'.
Re: Perl vs. PHP in streaming a file
by krkeegan (Novice) on Nov 24, 2004 at 21:12 UTC
    Thanks for your help so far. To the response of 280kbps I get the same speed out of my machine too with the perl script but for some reason the Tivo box really lags when I use perl, but not with php. My assumption is that the data is not reaching it fast enough, since this is a streaming file, but it could be another problem too. I am just trying to figure out what is different with PHP and perl in this respect.

    And to answer the question why I don't use apache. I actually am, TiVo and the homemedia option always use an alias http://server/TiVoConnect so in order to make it function right I have to use a script to be able to determine what is a query or what is a data transmission.

    Thanks again.
      TiVo and the homemedia option always use an alias http://server/TiVoConnect so in order to make it function right I have to use a script to be able to determine what is a query or what is a data transmission.

      According to a document I found on TiVo's website, the TiVo uses two different request formats:

      http://{machine}/TiVoConnect?{parameters}
      Meta-data requests
      http://{machine}/TiVoConnect/{document}?{parameters}
      File requests

      These are different enough that you could use Apache's mod_rewrite to direct file requests directly to the file, and then you would need neither PHP nor Perl to serve them.

      If your getting that high throughput I'd venture a guess that speed is not your issue. Is your script running on windows? If you are running on Windows you will almost cretanly need binmode(filehandle). I didn't see it in the code you posted. With out it Perl will open the file assuming that it is text and it will likely corrupt it as it's read.
Re^2: Perl vs. PHP in streaming a file
by superfrink (Curate) on Nov 25, 2004 at 05:15 UTC
    I don't know what is going on in this case (and I don't know TIVO at all) but in the past I have worked on www sites that charge for media files (ie images and videos). I have used CGI so I could check that the user is logged in and allowed to download the file.

    I don't really know why krkeegan is having trouble though if he is able to downlaod at 280kb/second unless that is not fast enough for the video stream. How fast does it download using PHP's fpassthrough function?