We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, I am trying to load the stream into the player but, am not able to load it.
Full Stream Code on Server :
`const express = require("express"); var cors = require("cors"); var ip = require("ip") const app = express(); const fs = require("fs"); app.use(cors()) app.use('/video/:name', express.static('uploads')) app.get("/", function (req, res) { res.sendFile(__dirname + "/index.html"); });
app.get("/video/:name", function (req, res) {
const range = req.headers.range === undefined ? "byte=0" : req.headers.range; console.log('inside stream range: ' + JSON.stringify(req.headers)); console.log('range: ' + range); if (!range) { res.status(400).send("Requires Range header"); } const videoPath = "./video.mp4"; const videoSize = fs.statSync("./video.mp4").size; const CHUNK_SIZE = 10 ** 6; const start = Number(range.replace(/\D/g, "")); const end = Math.min(start + CHUNK_SIZE, videoSize - 1); const contentLength = end - start + 1; const headers = { "Content-Range": `bytes ${start}-${end}/${videoSize}`, "Accept-Ranges": "bytes", "Content-Length": contentLength, "Content-Type": "video/mp4", }; res.writeHead(206, headers); const videoStream = fs.createReadStream(videoPath, { start, end }); videoStream.pipe(res);
});
app.get("/final", function (req, res) {
var path = __dirname; console.log('path', path); res.sendFile(path+'/video.mp4')
app.listen(3004, function () { console.log("Listening on port 3004!"); console.log('ip address', ip.address()); });`
I have tried both first stream data and other server file as static, Static file working fine but stream not loading
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, I am trying to load the stream into the player but, am not able to load it.
Full Stream Code on Server :
`const express = require("express");
var cors = require("cors");
var ip = require("ip")
const app = express();
const fs = require("fs");
app.use(cors())
app.use('/video/:name', express.static('uploads'))
app.get("/", function (req, res) {
res.sendFile(__dirname + "/index.html");
});
app.get("/video/:name", function (req, res) {
});
app.get("/final", function (req, res) {
});
app.listen(3004, function () {
console.log("Listening on port 3004!");
console.log('ip address', ip.address());
});`
I have tried both first stream data and other server file as static, Static file working fine but stream not loading
The text was updated successfully, but these errors were encountered: