How to use PHP to output an mp4 video ?

phpmind-mp4
I want my videos URL to keep hidden from the users while still, they can able to see the video. 

It have 2 parts.

1. PHP code and
2. HTML video Code

0||$end<$size)
  header('HTTP/1.0 206 Partial Content');
else
  header('HTTP/1.0 200 OK');

header("Content-Type: video/mp4");
header('Accept-Ranges: bytes');
header('Content-Length:'.($end-$begin));
header("Content-Disposition: inline;");
header("Content-Range: bytes $begin-$end/$size");
header("Content-Transfer-Encoding: binary\n");
header('Connection: close');

$cur=$begin;
fseek($fm,$begin,0);

while(!feof($fm)&&$cur<$end&&(connection_status()==0))
{ print fread($fm,min(1024*16,$end-$cur));
  $cur+=1024*16;
  usleep(1000);
}
die();
?>



Share

One thought on “How to use PHP to output an mp4 video ?

Leave a Reply

Your email address will not be published. Required fields are marked *