I have a code that causes my server to play a video to the user, without the HTTP / 1.1 header 206 Partial Content the speed is ridiculously low (something between 200 / 300kbps) and with this header it jumps to the maximum speed. I do not know exactly the cause of this. With this header, the video can be downloaded but not played through streaming. The syntax for streaming is like normal video in the tag, the difference is that src points to the stream.php page? Link = mysite.com / link.mp4.
I can not use fseek because the video comes from an external server
$link = $_GET['link']; $path = $link; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $path); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); header("Content-Type: video/mp4"); header("Content-Length: ".$size); header('Accept-Ranges: bytes'); $handle = fopen($path, "rb"); while (!feof($handle)) { header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes 0-'.$size); echo fread($handle, 100 * 1024 ); } fclose($handle);