Solved

Stream out file in PHP

Posted on 2007-03-29
1
4,350 Views
Last Modified: 2008-01-09
I'm making an application where members can stream out videos (as FLVs) a set number of times.

I know in ASP you can stream files out as I've done it. When I try it in PHP, the entire film has to download before the Flash applet starts playing. Due to the size of the videos this is hardly ideal.

This worked when I was testing the FLV directly (not going through PHP, just HTTP GETting it off the server).

Here's the important part of my code:

<?
session_start();
ob_start();

header("Content-Type: video/x-flv");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

$fh = fopen(realpath("filename.flv"), "rb");
fseek($fh, 0);
while (!feof($fh)) {
      print (fread($fh, 500));
      ob_flush();
}
fclose($fh);
?>

Either that or the flash player cannot understand what the data means, like it can via direct download. I don't know how to tell the difference.
0
Comment
Question by:OliWarner
1 Comment
 
LVL 23

Accepted Solution

by:
Zeffer earned 500 total points
ID: 18821856
so it has to Content-Type at fault..
the flv is being loaded like a swf ..
the php needs to let the player know it's a streaming flv ..like the other platforms it works on.
video/x-flv.. must be wrong..

and looking around..
this is for you..! almost at the bottom of the page//up a dozen posts..stefan has the same problem..
http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take-two

I hope this helps :)

Z
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question