I have recently made a youtube tutorial that is base on how to stream video with node js but i just recently recoded in php and it was shorter to code in php like ok so here is the node js code. I will post the code below.
Node JS Code
var http = require(“http”);
var fs = require(“fs”);console.log(“Server starting at localhost 3000”);
http.createServer(function (request,response) {
response.writeHead(200,{‘Content-Type’: 'video/mp4’});
var rs = fs.createReadStream(“cat.mp4”);
rs.pipe(response);
}).listen(3000);
and here is the php code
Php Code and Html 5
$files = “cat.mp4”;
$size = filesize($files);
header(“Content-Type: video/mp4”);
header(“Content-Length:”.$size);
readfile($files);<!DOCTYPE html>
<html>
<head>
<meta charset=“UTF-8”>
<title>video stream</title>
</head>
<body>
<h1> video </h1>
<video src=“video.php” type=“video/mp4” controls></video>
</body>
</html>
This was the php code was more reuseable i could stream a file into a html video tag but i’m not that experienced in node js or php i just dabble with both. i feel like php is great and node js is the future of web dev but maybe php is still more useful.