How can I streaming a video from an URL using express JS? #1847
-
|
I know how to save the video on a file, but I would like to not save the vide and streams its content directly so I have something like: app.get("/download/video", async (req, res) => {
const videoUrl = req.query.url
await pipeline(
got.stream(videoUrl),
fs.createWriteStream("video.mp4")
);
res.json({ url: "video.mp4" })
})I read some docs and tutorials, but I still have no idea what to change to stream the video directly. Thanks in advance for your help. |
Beta Was this translation helpful? Give feedback.
Answered by
iim-ayush
Aug 18, 2021
Replies: 1 comment
-
app.get("/download/video", async (req, res) => {
const videoUrl = req.query.url
let stream = got.stream(videoUrl)
stream.pipe(res)
res.json({ url: "video.mp4" })
})This should work in my opinion. OR app.get("/download/video", async (req, res) => {
const videoUrl = req.query.url
await pipeline(
got.stream(videoUrl),
res
);
res.json({ url: "video.mp4" })
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sindresorhus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work in my opinion. OR