Do you want to stream video in your app without needing users to download the entire video? Here's how to do exactly that using NodeJS.
F...
For further actions, you may consider blocking this person and/or reporting abuse
right, makes sense. That's what happens when you have a small hiccup in the network and the stream lowers the quality for a moment and resets back to a better quality when it gets better.
Thanks for your reply.
Hey Abdisalan! Great one!
I made the project from scratch from the article, and then noticed it was missing the "require fs". in the repo that's all ok, just the article misses it.
Other than that, perfect start. I'm starting my journey into video and streaming, and was an excellent start! Is this a main interest of yours?
I love it! Glad to have helped you get started! I'll try to fix that issue!
I'm not able to stream the video. I'm getting the
"Requires Range header"
response.I tried doing
const range = "bytes=0-1023";
but that didnt work too. The player just appears and doesnt play the videoi also got same erroot
how it is solve .did u got it?
I ran into the same error. The fix seems to be to set your
Content-Type
header before checking forRange
.wouldn't that require extra processing power? I thought what they did was generate multiple versions of the file and pick one accordingly to the required bandwidth and quality
Thanks for this. The way it's written works in Chrome but not Safari. To make it work in Safari I had to modify the code from this:
To this:
Just came across this post while searching for exactly this, and I'm happy to report that all has gone smoothly! I refactored the code a bit to work with Node's built-in
http
module, since that's what the rest of my project is using, and made a couple changes to ensure downloading (via the default video player's Download option) works correctly.Great articles! Really insightful to me since i'm starting curious in streaming
I wonder that if this stream way uses http protocol, does this mean we use tcp protocol ?
I just recently learned about tcp & udp protocols
where one of the usecases of udp is to serve connectionless data transfer (which is perfect in this video streaming case)
"For a chunk size, I've decided 1MB but you could change that to whatever you like!"
Is there any info on how to decide a chunk size? I've seen 1MB in a few articles but I haven't seen any reasons for it.
Wow I never knew, that’s cool!
does
fs.createReadStream
usessockets
under the hood?Great work! Can you also do the example of play video from remote? e.g example.com/video.mp4
Nice! Love that you used Node instead of some middleware. Keep it up Abdi!
Thanks!
How can we access the URL in frontend if we make this API protected by adding a middleware
wow. this is awesome... thanks for sharing bro
thank man. this is very helpful
Hi, I want to do that, but with webtorrent, how do I do that?
Modern browser like Chrome does this video streaming by default. 🤔
Pls help, I'm tried with 600MB video
It ok in localhost but failed in LAN
Were you trying it on iOS/Safari by any chance? I faced the problem when trying to make it work on iOS, so I followed this blog.logrocket.com/streaming-video.... Safari-based browsers need a different way of handling things.
error net::ERR_FILE_NOT_FOUND
Works perfectly with my own .mp4 files, thank you
Nice article...but I am unable to stream the video. It's showing just blank with the disabled play button. pls refer the screenshot i attached below.
@prernapahwa I had a similar issue and the problem for me ended up being that the options object passed to fs.createReadStream as the 2nd parameter requires the keys to be 'start' and 'end'.
So if you renamed the start and end variables from the tutorial (like i did), you'll need to explicitly pass them to the createReadStream call, e.g.
NB: STARTING_BYTE_POSITION and FINAL_BYTE_POSITION are the names of my own variables, you'll need to replace them with yours.
I also noticed that typos in headers also caused the blank video player error you described. Hope this helps.
How can play more than one video?
How can I stream two different videos?