Home OS Projects Flv4Php Stream flv files with php using flv4php
Stream flv files with php using flv4php PDF Print E-mail
Written by Administrator   
Sunday, 25 February 2007 09:15

if you're looking for a low cost streaming solution, you might want to consider using something like flv4php.

 

Here is a small code eksamble on how you could do this, using flv4php.

Streaming with php ? no problem
  1. <?php
  2. $path = '/path/to/flv/files/'// Path to flv files (could be behind web root)
  3. if( !isset($_GET["file"]) ) die(header("HTTP/1.0 404 Not Found"));
  4. $file = $path . htmlspecialchars($_GET["file"]);
  5.  
  6. if( !isset($_GET["offset"]) ) $_GET["offset"] = 10000;
  7. if( !isset($_GET["duration"]) ) $_GET["duration"] = 5000;
  8. if( !isset($_GET["speed"]) ) $_GET["speed"] = 100;
  9.  
  10. require_once('/path/to/flv4php/FLV.php'); // Path to flv.php / (flv4php)
  11. if ( file_exists($file) ) {
  12.   $flv = new FLV($file);
  13.   if( $_GET["type"] == "thumb" ) {
  14.     echo $flv->getFlvThumb($_GET["offset"]);
  15.   } else if( $_GET["type"] == "metadata" ) {
  16.     $newMetaData = $flv->defaultMetaData(true);
  17.     $metadata = $flv->createMetaData($newMetaData);
  18.     print("FLV".pack('C', 1 ).pack('C', 1 ).pack('N', 9 ).$metadata);
  19.   } else if( $_GET["type"] == "preview" ) {
  20.     echo $flv->getFlvPreview($_GET["offset"],$_GET["duration"],true,$_GET["speed"]);
  21.   } else {
  22. //    $flv->playFlvLock(1,$_GET["position"],false,true,true);    // stream using lock system
  23.     $flv->playFlv(1,$_GET["position"]);              // public stream, less "secure"
  24.   }
  25. } else {
  26.   die(header("HTTP/1.0 404 Not Found"));
  27. }
  28. ?>

 

 This is an easy wat to stream your flv files via http protocol. You can see an eksamble here on how it could work in real life

Last Updated on Monday, 25 August 2008 16:38
 
Copyright © 2013 fanno.dk. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.