How To Code A Video Streaming Server in NodeJS

  Рет қаралды 162,371

AbdisalanCodes

AbdisalanCodes

Күн бұрын

Пікірлер: 333
@hnasr
@hnasr 4 жыл бұрын
Man this is pretty cool, thanks Abdi!! Keep it up Since the videoSize is unlikely to change, I would move the call to obtain the statsSync outside the /video endpoint.
@abdicodes
@abdicodes 4 жыл бұрын
I’m happy you liked it! I’m a fan of your channel 😄 And that makes a lot of sense, thanks for the feedback!
@Epistemer
@Epistemer 3 жыл бұрын
oh wow, I'm a big fan Hussein ❤
@Iammrunkown
@Iammrunkown 3 жыл бұрын
use stat method
@sanatgawade8045
@sanatgawade8045 3 жыл бұрын
But what if this method is fetching the video dynamically.?
@nirajmotiani
@nirajmotiani 9 ай бұрын
this feels like a PR comment from senior engineer 😂
@gamingllama7464
@gamingllama7464 3 жыл бұрын
You know I have no idea who you are but just from that introduction I can already tell you'll have 100K subs within the next year
@hikari1690
@hikari1690 3 жыл бұрын
One month later and he's 10% of the way. He's ahead of schedule xD
@ShahriyarAlam1
@ShahriyarAlam1 3 жыл бұрын
Looks like this won't happen
@sheesh236
@sheesh236 3 жыл бұрын
@@ShahriyarAlam1 it will happen
@sheesh236
@sheesh236 3 жыл бұрын
@@ShahriyarAlam1 he just stopped uploading videos
@paulchaperon2207
@paulchaperon2207 2 жыл бұрын
Bruh
@edwardmacnab354
@edwardmacnab354 3 жыл бұрын
I don't know why you don't do more videos like this. By just watching stuff like this people learn a lot and what might seem easy and obvious to you is pretty obscure to many of us. Thank you for this nice little presentation , It was very informative. But please, could we have more ?
@TroenderTass
@TroenderTass 3 жыл бұрын
That is because he really don't know what he's doing. he's just copy pasting a tutorial
@midnightcigarettes8564
@midnightcigarettes8564 3 жыл бұрын
I'm trying to build an audio streaming server instead, and this is helping me get the blocks I need to piece things together. Thanks Abdi!
@karabomahlong9368
@karabomahlong9368 3 жыл бұрын
Im on a mission to build one as well but have no clue to go about it.. Im currently debating whether or not I should set up my own server or piggyback off of something like a Soundcloud. Would you kindly please share your journey so far?
@alejandropoirier6493
@alejandropoirier6493 Жыл бұрын
Nice video, I'm a front end developer and I was contacted by a streaming company to have a chat, they offered my a position and I have to learn all this stuff as soon as posible :)
@markericfairweather9722
@markericfairweather9722 2 жыл бұрын
This is Netflix's architecture. Love to see this Abdi!
@ArisFilms
@ArisFilms 2 жыл бұрын
Extremely informative and straightforward. Thank you.
@Epistemer
@Epistemer 3 жыл бұрын
you explained everything so clearly, loved it
@hd3adpool
@hd3adpool 3 жыл бұрын
Great explanation with the pros and cons, and especially the introduction. Keep going brother!
@franktfrisby
@franktfrisby 3 жыл бұрын
very cool and I like the way you walk through the video explaining all of the parts. Thanks
@chadzulu4328
@chadzulu4328 2 жыл бұрын
Very clear and easy to understand explanation, thanks so much Abdi!
@alexandrumarius5004
@alexandrumarius5004 4 жыл бұрын
Thank you man, very well explained, with all the details and very good English!
@shivangchaturvedi237
@shivangchaturvedi237 3 жыл бұрын
Man oh man!! Thank you! I will be waiting for more such content from you.
@aghiadalzein3069
@aghiadalzein3069 2 жыл бұрын
that was the most clear description,thanks
@joselito7776
@joselito7776 4 жыл бұрын
Thanks, dude, for showing me how to stream video. It also gave me the motivation to pay attention to http headers.
@abdicodes
@abdicodes 4 жыл бұрын
They are super important! Happy to have helped :)
@arielspalter7425
@arielspalter7425 3 жыл бұрын
You've earned yourself another subscriber. Awesome tutorial!
@thomasandon2539
@thomasandon2539 Жыл бұрын
Clear and straightforward! Thx.
@elad3958
@elad3958 2 жыл бұрын
Thank you brother. I will try this out. I look forward to more tutorials
@karnatakastatesyllabusexpl39
@karnatakastatesyllabusexpl39 4 жыл бұрын
Thanks for the simple but useful video
@abdicodes
@abdicodes 4 жыл бұрын
Glad it was helpful!
@dhyey2316
@dhyey2316 7 ай бұрын
This was amazing for clearing basics.
@Pikachu-oo5ro
@Pikachu-oo5ro 4 жыл бұрын
Great Video! Hope to see more content! Young and Talented!
@pavithranrocky316
@pavithranrocky316 4 жыл бұрын
Keep it up! Good Work Buddy...Very Helpful
@abdicodes
@abdicodes 4 жыл бұрын
Thanks! 😁
@captainanonymous7090
@captainanonymous7090 4 жыл бұрын
Keep going bro. You’ve got good explanation
@abdicodes
@abdicodes 4 жыл бұрын
Thanks for the support!
@albertmends
@albertmends 3 жыл бұрын
a very cool tutorial.. Thanks mhan
@vaibhavpawar4535
@vaibhavpawar4535 3 жыл бұрын
Amazing 🔥 content ..... This channel is so underrated
@nadaz7333
@nadaz7333 4 жыл бұрын
This is really good! Keep going!
@maskman4821
@maskman4821 4 жыл бұрын
Thank you for this tutorial, it is very cool and practical, we can let everyone access the server to see the video; I have a request, how do we send webcam video stream to server and let everyone views like youtube live stream ? It would be awesome if you can make such a tutorial and I think everyone wants to know how to achieve it !!!
@atalaysezen3391
@atalaysezen3391 2 жыл бұрын
Thank you buddy, you should do more videos like this
@bevedel
@bevedel 4 жыл бұрын
Really helpful, Thank you so much. keep going please ...
@candidodmv
@candidodmv 6 ай бұрын
Congratulations for this simple but very helpful video. I got a question: when you skipt to a specific point of the video, the intermediate chunks are downloaded too or not? Thanks and hello from Brazil!
@kuku5567
@kuku5567 3 жыл бұрын
you've earned a subscriber, thanks dude!
@abdicodes
@abdicodes 3 жыл бұрын
Awesome, thank you!
@arthurk7270
@arthurk7270 3 жыл бұрын
Great tutorial, thanks. How would this work in practice, though? The video blobs will presumably reside on S3/GCS/whatever. When a request for a video comes in, surely the server wouldn't fetch the whole video and keep it in memory, while serving chunks of it? Would it prefetch chunks of the video from blob storage and serve that until the next chunk is required? Or would the server containers somehow connect to a huge local storage area network with all the videos?
@abdicodes
@abdicodes 3 жыл бұрын
Good question! In practice this method should not be used ;) When I made the video it was kind of an experiment and I didn't know much about best practices.
@softwarelivre2389
@softwarelivre2389 3 жыл бұрын
@@abdicodes Hey man! Do you have a video with those "best practices" available anywhere? O really enjoyed the video and I'd also like to know how should I be implementing these "the correct way". Thanks!!
@softwarelivre2389
@softwarelivre2389 3 жыл бұрын
@@abdicodes Ohh, and I just subscribed! Thanks for the content!!
@persianaz6389
@persianaz6389 2 жыл бұрын
@@softwarelivre2389 Take a look at HLS and MPEG-DASH those 2 are the industry standard protocols for video streaming
@softwarelivre2389
@softwarelivre2389 2 жыл бұрын
@@persianaz6389 thanks! I'll take a look. I ended up using WebRTC for some projects and it worked quite well
@ytlagu2010
@ytlagu2010 5 ай бұрын
You deserve more subscribers buddy!!
@CheezePie
@CheezePie Жыл бұрын
You are the best❤ I'll try to implement this in Next.js
@ujwalc9226
@ujwalc9226 3 жыл бұрын
Awesome tutorial ,thank you soo much ♥️♥️♥️
@karnatakastatesyllabusexpl39
@karnatakastatesyllabusexpl39 4 жыл бұрын
It worked perfect Sir!
@jamespatterson1989
@jamespatterson1989 4 жыл бұрын
Hey I really did the clear explanation of both the overview and the line-by-line code. And such a simple code to illustrate the point. From the figure you have at 1:10, the two-way arrows got me wondering: how could we send recorded video from a client to the server in the same kind of bit-by-bit stream? I've build a client-side page that records video that I can then send to a server, but am looking to speed up the process and avoid saving anything client-side. Any ideas? Cheers!
@abdicodes
@abdicodes 4 жыл бұрын
I think that could work! You’ve got a good idea 😁
@silugr
@silugr 2 жыл бұрын
Your video is really interesting . I have a challenge in this . I am downloading the file from a FTP location and the the received file is in the form of a stream . How to send that stream as chunks without storing the ftp received file in the local system ?
@elieonokoko3782
@elieonokoko3782 3 жыл бұрын
This is great! Exactly what I was looking for. I am curious to know how you would implement view count. Thanks so much!
@L1CBot
@L1CBot Жыл бұрын
exactly what am I searching... 👍🏿👍🏿👍🏿
@madbadseagulls1
@madbadseagulls1 3 жыл бұрын
Amazing tutorial, Thank you
@paragbhide1695
@paragbhide1695 Жыл бұрын
awesome. have subscribed.. looking forward for more videos to learn!!!
@mohamedyoussef8835
@mohamedyoussef8835 2 жыл бұрын
Super Awesome explanation & topic ++++++++++++++++++++++ Thank You
@io-er1ex
@io-er1ex 4 жыл бұрын
Thanks this was very helpful. Keep it up
@abdicodes
@abdicodes 4 жыл бұрын
Glad it helped! 😁
@bodolawale5448
@bodolawale5448 3 жыл бұрын
Loved it. Thanks.. I will build upon this
@danielrocha5774
@danielrocha5774 4 жыл бұрын
I don't know if you tested with a longer video. But in my case after 7 minutes playing. Audio starts loosing synchronization with the video
@abdicodes
@abdicodes 3 жыл бұрын
Interesting... I'll look into this
@danielrocha5774
@danielrocha5774 3 жыл бұрын
@@abdicodes in my case I have videos downloaded from the internet some of them are 23fps and those loose sync when streaming. But the other videos at 30fps are fine
@DJFunkyNutti
@DJFunkyNutti 2 ай бұрын
thank you. one question, how did you do the cached refresh? you had a menu under refresh button. thanks
@andrewndotela7407
@andrewndotela7407 3 жыл бұрын
Hey man, this is really helpful. Thanks
@kj2w
@kj2w Жыл бұрын
Great video! It helped me grasp an upcoming feature we are implementing. Question, what tests would be applicable to write for this?
@sungjun94
@sungjun94 7 ай бұрын
Hi, can you deep dive into how pipe works and how req.headers.range is generated with new values?
@FPChris
@FPChris 3 жыл бұрын
Cool but why was the video's name not include in the src = at 3:07? Usually that's where you'd put it.
@abdicodes
@abdicodes 3 жыл бұрын
There's no video name because /video is pointing to the nodejs server that gives the same video every time.
@dhanushkamadushan1989
@dhanushkamadushan1989 3 жыл бұрын
Really good explanation. keep it up.
@sniviobraganca9899
@sniviobraganca9899 2 жыл бұрын
can you make a tutorial on the latter to save the video stream on front-end
@pcmguru6011
@pcmguru6011 3 жыл бұрын
Can you please make a video which can demonstrate how to handle the pre-existing video data in frontend. As you suggested in the last part of the video. Please reply.
@karabomahlong9368
@karabomahlong9368 3 жыл бұрын
Hi there, thanks for the video! Im trying to build an audio streaming site but have no clue how to go about it.. Im currently debating whether or not I should set up my own server or piggyback off of something like a Soundcloud as an example. Would you kindly please share any tips for this kind of approach?
@sem_dev
@sem_dev 3 жыл бұрын
Love you for this video!!! Instant sub
@ignitedroads
@ignitedroads 3 жыл бұрын
got a lot of info here, thanks
@mohammadhosienartaneh
@mohammadhosienartaneh Жыл бұрын
please explain about hls and how can i use that in node js
@thomasminoungou3779
@thomasminoungou3779 4 жыл бұрын
What a great tutorial!!! Just one question, who do I apply this but with a video store in the cloud? If you have any resource I will really appreciate it!
@abdicodes
@abdicodes 4 жыл бұрын
I don’t think this method can work with the cloud :/
@JenilCalcuttawala
@JenilCalcuttawala 3 жыл бұрын
Great tutorial Abdi. It would be helpful if you can also highlight how do we elevate this concept to streaming cloud storage contents i.e google cloud storage, aws s3.
@bhattakshay7816
@bhattakshay7816 7 ай бұрын
Are you using RTSP protocol for this?
@juanoude
@juanoude 3 жыл бұрын
Nice video man. Thanks a lot.
@konandev4278
@konandev4278 3 жыл бұрын
thats great bro, thank for video.
@danielstella2425
@danielstella2425 2 жыл бұрын
very useful, is it possibile to do with any mid-level language? such as Java, C#?
@ejazahmedj2103
@ejazahmedj2103 2 жыл бұрын
this is nice but how do i have to implement with multiple videos and getting the video URL by giving id?
@saramshshrestha7641
@saramshshrestha7641 2 жыл бұрын
Love you man, you're great.
@varunrajkumar2764
@varunrajkumar2764 4 жыл бұрын
Thanks, this really helped.
@abdicodes
@abdicodes 4 жыл бұрын
Glad it helped!
@nicetomeetugaming7024
@nicetomeetugaming7024 2 жыл бұрын
Thanks for this video!
@CodeProps
@CodeProps 3 жыл бұрын
That was really helpful, thanks
@bakamarimo7528
@bakamarimo7528 3 жыл бұрын
Great content man Subscribing hoping for more awesome content
@ofiresaban4510
@ofiresaban4510 2 жыл бұрын
Thanks! very useful
@thanasisathanasi4965
@thanasisathanasi4965 2 жыл бұрын
Is it possible to start streaming from the middle of the file and skip the beginning?
@RupamBumba
@RupamBumba 2 жыл бұрын
great video, make some more in details videos like that
@RivenbladeS
@RivenbladeS 3 жыл бұрын
@AbdisalanCodes Please do a tutorial about caching when user rewinds back the already streamed part of video.
@harshavardhannakkina1843
@harshavardhannakkina1843 4 жыл бұрын
great content thank you so much
@bonbonpony
@bonbonpony 3 жыл бұрын
01:04 So the player is sending those Range requests on its own? We don't have to do anything fancy, it's built in? 10:17 Saving WHERE? And what about those videos that have src="blob:here_some_weird_url_with_numerical_id" ?
@bonbonpony
@bonbonpony 3 жыл бұрын
@Rajat What makes you think so?
@abdicodes
@abdicodes 3 жыл бұрын
Correct, the built-in HTML video player sends the requests for the video and provides the range headers! The saving part was just an idea for how you could possibly preserve the buffer, it's probably a bad idea to save it in local storage now that I think about it. I've had better success giving a range of the entire video in the response. This makes sense because the video player requests "0-" range which means, give me everything from the start to the end.
@abdicodes
@abdicodes 3 жыл бұрын
For videos with a blob source, you can't stream it from the server because the video is already on the client. It's a trade-off of making the user load the entire video when they come to the page, in exchange for a seamless watching experience.
@abdicodes
@abdicodes 3 жыл бұрын
@Rajat I try to get to all the comments but I miss a few sometimes :/ I'll check out your question
@bonbonpony
@bonbonpony 3 жыл бұрын
@@abdicodes Hmm, how about streaming the 1MB chunks with XHR and swapping them in the player as blobs? Would that work? Still, I don't see how could I possibly save the chunks locally if the player sends those range requests itself (that is, I don't have any control over the headers it sends to the server nor the server's responses). But if I could use the blob chunks, then I think this might be possible, because those blobs could be stored locally and swapped in the player if needed without making any remote requests.
@diegomartin6332
@diegomartin6332 5 ай бұрын
Its incredible! Its possible to do the backend in python?
@TechPuzzle_Haven
@TechPuzzle_Haven 3 жыл бұрын
Please make a video on mux with Nodejs for live video streaming.
@samplerun4686
@samplerun4686 3 жыл бұрын
i really like your concept, i have a question if you can answer. how do i switch between audio track if video file have multiple audio tracks? i couldnt find this solution where i can change my audio track in video controller. thank you
@danemiller4852
@danemiller4852 3 жыл бұрын
How would one set up a code to get OBS to communicate with your node?
@sivach8667
@sivach8667 4 жыл бұрын
Hmm... How's this working? I don't see that we're sending any "range" in our request. When I tried to implement it, it went to the "if(!range)" in index.js and got that "Requires Range Header".
@abdicodes
@abdicodes 4 жыл бұрын
The range request comes from putting the endpoint into the HTML5 video player! We don’t make the requests, the video player does :)
@JohnWeland
@JohnWeland 3 жыл бұрын
I would love to see the server-side of this... what Imean is an endpoint you could point something like OBS to and live stream so stream -> server -> client
@hypocritical7379
@hypocritical7379 3 жыл бұрын
this is the server-side
@JohnWeland
@JohnWeland 3 жыл бұрын
@@hypocritical7379, right but in this example, the server is only set up to stream existing files. How does the server handle receiving an encoded stream and sending it out to connected clients. In a situation like that, you don't have the file to reference but an open file stream (would be my guess)
@hypocritical7379
@hypocritical7379 3 жыл бұрын
@@JohnWeland depends, you would save chunks of incoming video, so, you could have it setup so that when you get a new video chunk you send the previous one (might save 20 sec fragments in a encryption setup like base64 for video) (there are other ways of doing this like having a array and when the array gets more than 20 base64 images it sends the images full of images out, then clears the array and starts loading it with images again) edit: I did make a live streaming service like this
@denismbabazi8094
@denismbabazi8094 2 жыл бұрын
is it possible to have one using the dash streaming protocol
@djamaatul
@djamaatul Жыл бұрын
hi, give me reason why videoSize - 1 and end - start + 1?
@voalcalisticTanmay
@voalcalisticTanmay 4 жыл бұрын
thanks a lot for the video ...
@1manbeats869
@1manbeats869 2 жыл бұрын
Very cool video, i like your code style and explanations. Just one thing, i believe this is not good to use statSync (or any sync IO function) inside a request handler, cause this would block the JS runtime event loop.
@ominezx9
@ominezx9 4 жыл бұрын
its lit💥, thanks bruv.
@abdicodes
@abdicodes 4 жыл бұрын
Thank you! 🙏🏾
@Ason_Project
@Ason_Project 3 жыл бұрын
Can I contact u for a small job...
@coffeecuppepsi
@coffeecuppepsi 2 жыл бұрын
this is awesome thank you
@semariaissac9119
@semariaissac9119 4 жыл бұрын
Thanks Abdi! Its a great info, do you have any idea how to stream kinesis video stream in node js within Amazon console?
@abdicodes
@abdicodes 4 жыл бұрын
I haven’t tried that but could be a cool video idea!
@justfun591
@justfun591 Жыл бұрын
what if I want to server videos from S3 bucket using that technique?
@ziranshuzhang6831
@ziranshuzhang6831 2 жыл бұрын
is this something similar KZbin does or KZbin is somehow fundamentally different?
@vishaljoshi6406
@vishaljoshi6406 4 жыл бұрын
really good! appreciate it
@adithyapaib
@adithyapaib 3 жыл бұрын
can you make a like time video streamer like a tv video which doesn't allow you to go forward or backward but steam at the same time for all people ?
@miniburger9323
@miniburger9323 3 жыл бұрын
thanks for the video! may i ask, why it Cannot GET /bigbuck.mp4 when i implement it on hosting (heroku)
@karmadipdodiya4421
@karmadipdodiya4421 Ай бұрын
I am receiving a video stream over a TCP socket. How can I stream that video in a browser? I don't know the length, i just need to transfer the data.
@ulrichnwembe9579
@ulrichnwembe9579 3 жыл бұрын
Great video i liked it i would know if you get a document which explain the Video progress bar When you leave a video without finishing it, a red bar under the video thumbnail shows you where you left off. When you play the video again, it will restart from where you were. I really need help to associate it a video streaming.Thanks
@artificallead499
@artificallead499 3 жыл бұрын
would this mean that someone who steal the code from inspect element couldnt watch the full video if you had a membership site
@jairam2100
@jairam2100 4 жыл бұрын
Really nice one.learned lot.Is it possible to do the same but from mongodb?
@abdicodes
@abdicodes 4 жыл бұрын
Thanks 😊 I think so! I’ve never tried mongodb with big files but I think there’s support for it using GridFS
@abdicodes
@abdicodes 4 жыл бұрын
I made the video! Hope its as helpful as this one!
@jairam2100
@jairam2100 4 жыл бұрын
@@abdicodes Thanks a lot :)
@flyancesystems8328
@flyancesystems8328 3 жыл бұрын
Hi, I created an Android video streaming application but the videos take too long to load and play, what could be the problem?
How To Code A Video Stream using MongoDB
4:49
AbdisalanCodes
Рет қаралды 23 М.
Node JS - HTTP Streaming
37:22
Web Dev Journey
Рет қаралды 21 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
OCCUPIED #shortssprintbrasil
0:37
Natan por Aí
Рет қаралды 131 МЛН
WebRTC in 100 Seconds // Build a Video Chat app from Scratch
11:19
How To Code A LIVE Streaming Server: RTMP & Stream Key #1
17:53
AbdisalanCodes
Рет қаралды 84 М.
A Deep Dive into Node.js Streams | Masterclass
1:15:46
Platformatic
Рет қаралды 14 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 445 М.
Hardest Backend Node.js Concept to Master
11:20
Mehul - Codedamn
Рет қаралды 70 М.
How To Create A Video Chat App With WebRTC
28:53
Web Dev Simplified
Рет қаралды 926 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 665 М.
Setup your own RTMP Server to Receive and Redistribute Live Streaming Video
19:54
Doug Johnson Productions
Рет қаралды 279 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН