Skip to main content
Participant
March 8, 2007
Question

FLV streaming through PHP help

  • March 8, 2007
  • 1 reply
  • 535 views
First of all i know nothing of PHP, but after this incident i will teach myself.

I found this link: http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take-two

It shows you how to stream FLV's and use a scrub bar without using a streaming server using a PHP file. The problem is i dont know exactly what to do to make the PHP file work for me. I've tried a number of things but it wont work. please help me.

PHP code given:
<?
/*/
security improved by by TRUI
www.trui.net

Originally posted at www.flashcomguru.com

//*/


//full path to dir with video.
$path = 'C:/.../clips/';


$seekat = $_GET["position"];
$filename = htmlspecialchars($_GET["file"]);
$ext=strrchr($filename, ".");
$file = $path . $filename;


if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) && (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$', $filename)))
{
header("Content-Type: video/x-flv");
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");
fseek($fh, $seekat);
while (!feof($fh)) {
print (fread($fh, filesize($file)));
}
fclose($fh);
}
else
{
print("ERORR: The file does not exist"); }
?>
This topic has been closed for replies.

1 reply

Inspiring
March 8, 2007
Hi infoVac,

what have you got so far?

OTTOMH, you should query the php from the
ns.play("......php?file=yada.flv&position=bitnumberofkeyframe")

the thing is that the php streams the file in chunks to the flashplayer.
The flv itself can only be played from a keyframe onwards so the php
file needs to know:
* which file
* from which position (bit)

the bit info on the keyframes can be aquired throu use of the FLVMDI
from BURAKS ( http://www.buraks.com/flvmdi/)

HTH
Manno

infoVac wrote:
> First of all i know nothing of PHP, but after this incident i will teach myself.
>
> I found this link:
> http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take
> -two
>
> It shows you how to stream FLV's and use a scrub bar without using a streaming
> server using a PHP file. The problem is i dont know exactly what to do to make
> the PHP file work for me. I've tried a number of things but it wont work.
> please help me.
>
> PHP code given:
> <?
> /*/
> security improved by by TRUI
> www.trui.net
>
> Originally posted at www.flashcomguru.com
>
> //*/
>
>
> //full path to dir with video.
> $path = 'C:/.../clips/';
>
>
> $seekat = $_GET["position"];
> $filename = htmlspecialchars($_GET["file"]);
> $ext=strrchr($filename, ".");
> $file = $path . $filename;
>
>
> if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) &&
> (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$',
> $filename)))
> {
> header("Content-Type: video/x-flv");
> 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");
> fseek($fh, $seekat);
> while (!feof($fh)) {
> print (fread($fh, filesize($file)));
> }
> fclose($fh);
> }
> else
> {
> print("ERORR: The file does not exist"); }
> ?>
>

--
----------
Manno Bult
http://www.aloft.nl
manno@xs4all.nl