I have a 4GB .mp4 video I need to allow authenticated users to stream.
I have the video in a directory which is secured via .htaccess like this:
Deny from all
When a user requests access to the video, I use a PHP script to check for authentication, then send the video like this:
<?php
header('Content-Type: video/mp4');
header('Content-Disposition: inline; filename="' . $video . '.mp4"');
header('Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
ob_clean();
$wasdownloaded = readfile('video/' . $video . '.mp4');
if ($wasdownloaded===true){
Flush();
}
?>
I am using Floatbox.js which has built-in (and simple) capability to stream video. I am not tied to using that, though.
I am finding that I can stream 1-3 minutes of the video before it times out, even on a good connection. I would think there are a couple of potential bottlenecks, and not sure where to start: