Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

The server is overloaded when playing a video #190

Open
irumaru opened this issue Oct 5, 2020 · 1 comment
Open

The server is overloaded when playing a video #190

irumaru opened this issue Oct 5, 2020 · 1 comment

Comments

@irumaru
Copy link

irumaru commented Oct 5, 2020

Expected behaviour

Load the video only for the part to be played.

Actual behaviour

Read all files the moment you play.

Steps to reproduce

Play the video in your browser.

How to improve I think

You should create a new remote.php alternative without using remote.php.

To do that

$dir //Video file location

$size = filesize($dir);
$fp = fopen($dir,"rb");

$etag = md5($_SERVER["REQUEST_URI"]).$size;

if(@$_SERVER["HTTP_RANGE"]){
list($start,$end) = sscanf($_SERVER["HTTP_RANGE"],"bytes=%d-%d");
if(empty($end)) $end = $start + 10000000 - 1;
if($end>=($size-1)) $end = $size - 1;
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes {$start}-{$end}/{$size}");
$size = $end - $start + 1;
fseek($fp,$start);
}

header("Accept-Ranges: bytes");
header("Content-Type: video/mp4");
header("Content-Length: {$size}");
header("Etag: "{$etag}"");

//if($size) echo fread($fp,$size);

echo fread($fp,10000000);
ob_flush();

fclose($fp);

@ghost
Copy link

ghost commented Oct 9, 2020

Not sure if you're talking about in Browser or by Webdav (I'm not the brightest bulbs)
However, will confirm that this happens both on PHP 4.7.10 and PHP-FPM 4.7.10 in the web browser. Not sure about with Webdav. File locking with redis and distributing both being enabled has the same result as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant