Thread PHP-Code zum flv-Pseudostreaming in Perl umschr.?
(9 answers)
Opened by perlpower at 2007-09-16 23:26
das PHP-Skript:
Code: (dl
)
1 <? Mein Perl-Versuch: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 #!usr/bin/perl -w # get GET data if($ENV{'REQUEST_METHOD'} eq 'GET') { $Daten = $ENV{'QUERY_STRING'}; } else { $Daten = null; } # modify GET data array $Daten =~ s/%([\da-fA-f]{2})/pack("c",hex($1))/ge; $Daten =~ tr/+/ /; for(split/&/,$Daten) { ($key , $val) = split/=/,$_,2; $Form{$key} .= $val; } # full path to dir with video $path = "./"; # get position $seekat = $Form{'position'}; # get filename of video $filename = $Form{'file'}; $filename =~ s/\&/&/g; $filename =~ s/</</g; $filename =~ s/>/>/g; $filename =~ s/\"/"/g; # get filename ending $ext = substr($filename,length($filename)-4,4); # file is path + filename $file = $path . $filename; # if file exists do the pseudo streaming: if( (-e $file) && ($ext==".flv") && (length($filename)>2) && (!($filename =~ m/flvprovider.pl$/)) ) { print "Content-type: text/html\n\n"; if($seekat != 0) { print("FLV"); print(pack('C', 1 )); print(pack('C', 1 )); print(pack('N', 9 )); print(pack('N', 9 )); } # $fh = fopen($file, "rb"); open (FILE, $file) or die $!; binmode FILE; seek (FILE, $seekat, 0); while (!eof(FILE)) { read(FILE, $scalar, stat($file)); print $scalar; } close(FILE); } else { print "Content-type: text/html\n\n"; print "ERROR: The file does not exist"; } |