Video Streaming Api Nodejs Here

res.writeHead(206, { 'Content-Range': `bytes ${start}-${end}/${fileSize}`, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': 'video/mp4', });

const stream = fs.createReadStream(filePath, { start, end }); video streaming api nodejs

stream.pipe(res); } else { res.writeHead(200, { 'Content-Length': fileSize, 'Content-Type': 'video/mp4', }); fs.createReadStream(filePath).pipe(res); } }); { 'Content-Range': `bytes ${start}-${end}/${fileSize}`

app.get('/video/:filename', (req, res) => { const filename = req.params.filename; const filePath = path.join(__dirname, 'videos', filename); const stream = fs.createReadStream(filePath