Reputation: 317
I am using a simple (unsafe) php script to stream video through my server.
<?php
if(checkToken($_SESSION['token']) && isLoggedIn() && checkIsVideo($_GET['url'])){
$dirFile = $_GET['url']; // http://othersite.com/video.mp4
header("Content-Type: video/mp4");
$fh = @fopen($dirFile, "rb") or die();
while (!feof($fh)){
print(fread($fh, 1048576));
@ob_end_flush();
@ob_flush();
@flush();
@ob_start();
}
fclose($fh);
}
exit();
?>
However this php link (http://mysite123.com/proxy.php?url=othersite.com/video.mp4) is been used by every single user in my website.
This means that I could have trouble with the memory limit of php, which by the way I know I can change it in "php.ini" file. However, I would like to know a better solution, to make this php proxy script a less consuming task in my server. So that I could, also, handle the bandwidth and pay less ;)
Again, I'm also thinking in building a proxy server only for this "streaming video proxy" task. And that way I can have a website server and a proxy server. Each one capable of managing its traffic.
I guess I could get a proxy server and use a link like:
http://myproxy.com/?url=othersite.com/video.mp4
I would like to hear your ideas/solutions about this issue.
Thanks :)
EDIT: these video files are usually 150 MB
Upvotes: 1
Views: 1429
Reputation: 534
I have been working with Nginx for the last 2 years, and I can say it's one of your best choices. Why?
1) It's free 2) Has got a good support team 3) A nice module for your mp4 streaming: http://nginx.org/en/docs/http/ngx_http_mp4_module.html 4) high performance, you don't need to worry about memory and cpu consumption anymore
Upvotes: 1