Reading .flv files above 75 MB in JW player by PHP script


I made a script that makes my .flv files secure.

I created something like that in .htaccess:

[code]AddType video/x-flv .flv
Options -Indexes
RewriteEngine On

RewriteRule .(flv|zip)$ controller.php [NC,L][/code]

and in controller.php I’m taking the URL checking if it has the hash in the URL which is in database and then I play the video by using
readfile(); function.

readfile function worked well on files to like 30-40MB, but above that .flv files didn’t even play in JW player so I decided to make this script:

[code] function smartReadFile($location, $filename, $mimeType=‘video/x-flv’)

	  { header ("HTTP/1.0 404 Not Found");
	  { header ("HTTP/1.0 505 Internal server error");
	  { if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches))
	    { $begin=intval($matches[0]);
	    header('HTTP/1.0 206 Partial Content');
	    header('HTTP/1.0 200 OK');  
	  header("Content-Type: $mimeType"); 
      header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
	  header('Pragma: no-cache');  
	  header('Accept-Ranges: bytes');
	  header("Content-Range: bytes $begin-$end/$size");
	  header("Content-Disposition: inline; filename=$filename");
	  header("Content-Transfer-Encoding: binary\n");
	  header("Last-Modified: $time");
	  header('Connection: close');  

	  	echo fread($fm,min(1024*2,$end-$cur));

And now I can play videos above even 70MB, but at about 5-7 minutes download process is being stopped.

Anyone know why could it happen? I read that fread function was taking lot’s of RAM, so I chunked as you can see file to only 2 MB, and there are still problems even tho it should take ONLY 2 MB of RAM. So what’s the problem?

Any suggestions please.

"well look’s like this may be the problem:
“In Apache, the timeout parameter of 300 seconds means that if there is “no action” (or no next action) for 300 seconds, the session is timed out.”

is that possible to change it somehow in DreamHost shared hosting to 10 minutes?
is that possible to send from JW player at least once every 1 minute something to the .flv file that could keep connection?

best regards!

You said that you have a hash in the database? can you provide a zip file? I dont understand… On my account I dont seem to have a limit.

everyone have limit on php script execution of 5 minute in httpd.conf, i changed value there and now it works fine. httpd.conf is over php.ini and any other functions like set_time_limit.