How To Code A Video Streaming Server in NodeJS

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии •

  • @hnasr
    @hnasr 4 года назад +165

    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 года назад +15

      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 года назад +1

      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 8 месяцев назад

      this feels like a PR comment from senior engineer 😂

  • @gamingllama7464
    @gamingllama7464 3 года назад +55

    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 года назад +2

      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 года назад +1

      @@ShahriyarAlam1 he just stopped uploading videos

    • @paulchaperon2207
      @paulchaperon2207 2 года назад +1

      Bruh

  • @midnightcigarettes8564
    @midnightcigarettes8564 3 года назад +7

    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 года назад +1

      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?

  • @edwardmacnab354
    @edwardmacnab354 3 года назад +15

    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 года назад +1

      That is because he really don't know what he's doing. he's just copy pasting a tutorial

  • @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!

  • @chadzulu4328
    @chadzulu4328 2 года назад

    Very clear and easy to understand explanation, thanks so much Abdi!

  • @hd3adpool
    @hd3adpool 3 года назад +1

    Great explanation with the pros and cons, and especially the introduction. Keep going brother!

  • @franktfrisby
    @franktfrisby 3 года назад +1

    very cool and I like the way you walk through the video explaining all of the parts. Thanks

  • @ArisFilms
    @ArisFilms 2 года назад +1

    Extremely informative and straightforward. Thank you.

  • @arielspalter7425
    @arielspalter7425 3 года назад +1

    You've earned yourself another subscriber. Awesome tutorial!

  • @shivangchaturvedi237
    @shivangchaturvedi237 3 года назад

    Man oh man!! Thank you! I will be waiting for more such content from you.

  • @Epistemer
    @Epistemer 3 года назад +3

    you explained everything so clearly, loved it

  • @joselito7776
    @joselito7776 4 года назад +1

    Thanks, dude, for showing me how to stream video. It also gave me the motivation to pay attention to http headers.

    • @abdicodes
      @abdicodes  4 года назад +1

      They are super important! Happy to have helped :)

  • @alexandrumarius5004
    @alexandrumarius5004 4 года назад +3

    Thank you man, very well explained, with all the details and very good English!

  • @aghiadalzein3069
    @aghiadalzein3069 2 года назад

    that was the most clear description,thanks

  • @ytlagu2010
    @ytlagu2010 5 месяцев назад

    You deserve more subscribers buddy!!

  • @Pikachu-oo5ro
    @Pikachu-oo5ro 4 года назад +1

    Great Video! Hope to see more content! Young and Talented!

  • @elad3958
    @elad3958 2 года назад

    Thank you brother. I will try this out. I look forward to more tutorials

  • @pavithranrocky316
    @pavithranrocky316 4 года назад +2

    Keep it up! Good Work Buddy...Very Helpful

  • @nadaz7333
    @nadaz7333 4 года назад +3

    This is really good! Keep going!

  • @vaibhavpawar4535
    @vaibhavpawar4535 3 года назад +1

    Amazing 🔥 content ..... This channel is so underrated

  • @karnatakastatesyllabusexpl39
    @karnatakastatesyllabusexpl39 4 года назад +1

    Thanks for the simple but useful video

    • @abdicodes
      @abdicodes  4 года назад

      Glad it was helpful!

  • @dhyey2316
    @dhyey2316 7 месяцев назад

    This was amazing for clearing basics.

  • @thomasandon2539
    @thomasandon2539 Год назад

    Clear and straightforward! Thx.

  • @captainanonymous7090
    @captainanonymous7090 4 года назад +1

    Keep going bro. You’ve got good explanation

    • @abdicodes
      @abdicodes  4 года назад +1

      Thanks for the support!

  • @albertmends
    @albertmends 3 года назад +1

    a very cool tutorial.. Thanks mhan

  • @karnatakastatesyllabusexpl39
    @karnatakastatesyllabusexpl39 4 года назад +1

    It worked perfect Sir!

  • @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!

  • @kuku5567
    @kuku5567 3 года назад +1

    you've earned a subscriber, thanks dude!

  • @candidodmv
    @candidodmv 5 месяцев назад

    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!

  • @DJFunkyNutti
    @DJFunkyNutti Месяц назад

    thank you. one question, how did you do the cached refresh? you had a menu under refresh button. thanks

  • @paragbhide1695
    @paragbhide1695 Год назад

    awesome. have subscribed.. looking forward for more videos to learn!!!

  • @CheezePie
    @CheezePie Год назад

    You are the best❤
    I'll try to implement this in Next.js

  • @atalaysezen3391
    @atalaysezen3391 Год назад

    Thank you buddy, you should do more videos like this

  • @dhanushkamadushan1989
    @dhanushkamadushan1989 3 года назад

    Really good explanation. keep it up.

  • @ujwalc9226
    @ujwalc9226 3 года назад

    Awesome tutorial ,thank you soo much ♥️♥️♥️

  • @L1CBot
    @L1CBot Год назад

    exactly what am I searching... 👍🏿👍🏿👍🏿

  • @andrewndotela7407
    @andrewndotela7407 3 года назад

    Hey man, this is really helpful. Thanks

  • @saramshshrestha7641
    @saramshshrestha7641 2 года назад

    Love you man, you're great.

  • @sungjun94
    @sungjun94 7 месяцев назад

    Hi, can you deep dive into how pipe works and how req.headers.range is generated with new values?

  • @maskman4821
    @maskman4821 4 года назад +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 !!!

  • @bevedel
    @bevedel 3 года назад +2

    Really helpful, Thank you so much. keep going please ...

  • @sem_dev
    @sem_dev 3 года назад

    Love you for this video!!! Instant sub

  • @io-er1ex
    @io-er1ex 4 года назад +1

    Thanks this was very helpful. Keep it up

    • @abdicodes
      @abdicodes  4 года назад

      Glad it helped! 😁

  • @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.

  • @amalbabu6607
    @amalbabu6607 3 года назад

    If I use fetch get request to get the video then where should I include ranges. When I include in header the subsequent requests shows 401 because of authentication middleware

  • @arthurk7270
    @arthurk7270 3 года назад +4

    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 года назад +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 года назад +1

      @@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

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад

    Super Awesome explanation & topic ++++++++++++++++++++++ Thank You

  • @kj2w
    @kj2w Год назад

    Great video! It helped me grasp an upcoming feature we are implementing.
    Question, what tests would be applicable to write for this?

  • @sniviobraganca9899
    @sniviobraganca9899 2 года назад

    can you make a tutorial on the latter to save the video stream on front-end

  • @djamaatul
    @djamaatul Год назад

    hi, give me reason why videoSize - 1 and end - start + 1?

  • @justfun591
    @justfun591 Год назад

    what if I want to server videos from S3 bucket using that technique?

  • @danielrocha5774
    @danielrocha5774 3 года назад +1

    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

  • @danemiller4852
    @danemiller4852 3 года назад

    How would one set up a code to get OBS to communicate with your node?

  • @sadekhossain9566
    @sadekhossain9566 3 года назад

    Hi this works, but getting error sometime saying
    The value of "start" is out of range. It must be an integer. Received NaN
    How to solve this?

  • @mathewkurian4322
    @mathewkurian4322 3 года назад

    dear bro,
    how to customize youtube using code.
    need is , use the same url (youtube link) after a live stream ends, (reuse).??

  • @learn_Japanese_with_sam
    @learn_Japanese_with_sam 3 года назад +1

    You are great man

  • @poolman7786
    @poolman7786 Год назад

    hey bro i need you help please do reply i am trying to stream multiple videos from local storage but i am unable to read the local storage folder used readdir, readfile non of those work is i try to read the files in folder but when i do like you did it works because it is directly reading main file but i am trying to access folder and files within that folder plssssss do reply i am egarly waiting for your reply

  • @bakamarimo7528
    @bakamarimo7528 3 года назад

    Great content man
    Subscribing hoping for more awesome content

  • @madbadseagulls1
    @madbadseagulls1 3 года назад

    Amazing tutorial, Thank you

  • @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?

  • @ejazahmedj2103
    @ejazahmedj2103 Год назад

    this is nice
    but how do i have to implement with multiple videos and getting the video URL by giving id?

  • @miniburger9323
    @miniburger9323 3 года назад

    thanks for the video! may i ask, why it Cannot GET /bigbuck.mp4 when i implement it on hosting (heroku)

  • @juanoude
    @juanoude 3 года назад

    Nice video man. Thanks a lot.

  • @MechanicusOfficial
    @MechanicusOfficial 2 года назад

    What i did notice, after a while the audio is not sync with the video. The audio will have a delay bigger and bigger. If you pause and replay the audio will be resync.

  • @mohammadhosienartaneh
    @mohammadhosienartaneh Год назад

    please explain about hls and how can i use that in node js

  • @silugr
    @silugr 2 года назад +1

    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 ?

  • @digitalpamuk4468
    @digitalpamuk4468 Год назад

    Is there a way that you can build a small web app (frontend UI - html, css, javacript) that plays a video playlist just by drag and drop and use node.js as backend server). Something like a lighter version of Caspar CG for broadcasting.
    You would kill with views on a youtube video like that.

  • @manavdixit3355
    @manavdixit3355 Год назад

    Why do we set end=(start+chunkSize,vediosize-1) instead of end=(start+chunkSize,vediosize)

  • @thanasisathanasi4965
    @thanasisathanasi4965 2 года назад

    Is it possible to start streaming from the middle of the file and skip the beginning?

  • @s.k.y2665
    @s.k.y2665 Год назад

    Hey can someone explain how to solve this with ffmpeg (fluent-ffmpeg library)?
    I need it to (on-the-fly) transcode the video if the browser/final device does not support the codecs
    Everything i try wont play the video correctly :c

  • @sonsimp3468
    @sonsimp3468 2 года назад

    Hey I wanted ask but in containerized environments the video will not be on localhost, so what would be the ideal place to story them would s3 make sense ?.

  • @sivach8667
    @sivach8667 3 года назад +2

    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  3 года назад +1

      The range request comes from putting the endpoint into the HTML5 video player! We don’t make the requests, the video player does :)

  • @bodolawale5448
    @bodolawale5448 3 года назад

    Loved it. Thanks.. I will build upon this

  • @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 года назад +1

      There's no video name because /video is pointing to the nodejs server that gives the same video every time.

  • @JenilCalcuttawala
    @JenilCalcuttawala 3 года назад +1

    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.

  • @jamespatterson1989
    @jamespatterson1989 4 года назад +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  3 года назад +1

      I think that could work! You’ve got a good idea 😁

  • @wairokpamnehrusingh7080
    @wairokpamnehrusingh7080 3 года назад

    How to make different option resolution? I mean 480p, 720p etc

  • @pushkarmahajan9294
    @pushkarmahajan9294 2 года назад

    Awesome video!

  • @denismbabazi8094
    @denismbabazi8094 2 года назад

    is it possible to have one using the dash streaming protocol

  • @konandev4278
    @konandev4278 3 года назад

    thats great bro, thank for video.

  • @bhattakshay7816
    @bhattakshay7816 7 месяцев назад

    Are you using RTSP protocol for this?

  • @karabomahlong9368
    @karabomahlong9368 3 года назад +1

    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?

  • @chineduifeanyi552
    @chineduifeanyi552 2 года назад

    Please can I send individual bytes headers with php, rather than sending the whole chunk of the video to the browser.

  • @ArnavSingh-im5bj
    @ArnavSingh-im5bj 3 года назад

    How can we do this through a CDN like cloudflare?

  • @RupamBumba
    @RupamBumba 2 года назад

    great video, make some more in details videos like that

  • @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 ?

  • @Superuser-r1y
    @Superuser-r1y 2 года назад +1

    Can i stream RUclips video to Facebook through this application using youtube video link??????❤️🔥👍

  • @RivenbladeS
    @RivenbladeS 3 года назад

    @AbdisalanCodes Please do a tutorial about caching when user rewinds back the already streamed part of video.

  • @nicetomeetugaming7024
    @nicetomeetugaming7024 2 года назад

    Thanks for this video!

  • @saifhossain4644
    @saifhossain4644 3 года назад

    hey, in my code, the first file chunk is repeated again and again the whole time..
    can anyone tell me how to fix this??

  • @byronalas7848
    @byronalas7848 2 года назад

    You're so awesome!!! 😎😎😎😎

  • @sanatgawade6456
    @sanatgawade6456 3 года назад

    This works on the web, but how to implement this in react native .?

  • @thang8617
    @thang8617 2 года назад

    If i have multiple .mp4 files how to can i get it?

  • @henryjiang4407
    @henryjiang4407 3 года назад

    Hey, I am trying to deploy it on Heroku, but I couldn't see the video on another device. Any idea how to fix this?

  • @CodeProps
    @CodeProps 3 года назад

    That was really helpful, thanks

  • @moghauptag
    @moghauptag 3 года назад

    awesome !! loved it!!

  • @infinityApologeticsClips
    @infinityApologeticsClips 3 года назад

    This was amazing

  • @sudarshanv9797
    @sudarshanv9797 3 года назад

    what if we have more than one client, how do server handle more than one client at the same time? not just about video streaming but in general?