How can I create a video streaming server using node.js?

Until now I have only worked with rest-APIs but now I need to create a server which serves several hundred videos of different lengths to client and I have zero experience in video or audio streaming.

I have seen few tutorials and know data will be served in chunks and I can control chunk size and client will need to have a range header and all that stuff, but all those tutorials were for simple servers that had a single endpoint and video. Will I be able to manage hundreds of videos the same way?

It would be a great help if you can answer the questions below and guide me about things I need to know before I start development.

  1. Can I handle video files the same way I usually handle other files by storing it on server or using services like amazon s3 bucket?

  2. I read that webRTC can also be used for streaming should I use it or stick to the simple method?

  3. Are there any useful packages or technologies that can make development easier?

  4. Videos also need to be served on mobile application platforms will that change things, do I need something else to make it mobile app compatible?

  5. If you have a tutorial you think can be suitable for my needs, Can you please share it?

I really appreciate your help and time. Feel free to mention any thing that I missed or need to know, thanks in advance.

1 answer

  • answered 2022-05-03 02:04 jfriend00

    Can I handle video files the same way I usually handle other files by storing it on server or using services like amazon s3 bucket?

    Yes. But, you will want to support the Range header since most media players will request a range of bytes, not the entire file at once. And, there's a way that the media players gets the total length of the media too (so it knows how to show a slider in the player and so it knows that ranges of bytes are available).

    I read that webRTC can also be used for streaming should I use it or stick to the simple method?

    There are some specific situations where webRTC is useful (like peer to peer video), but you haven't described anything that would make me think you should go that way vs just http delivery as described above.

    Are there any useful packages or technologies that can make development easier?

    It's not clear what you want here. Asking for library references here is considered off-topic. There are zillions of packages on NPM related to streaming, but there's no particular reason to "need" one of them. You should do a search and see if you find something that seems to uniquely fit your needs. Generic streaming does not need such a package.

    Videos also need to be served on mobile application platforms will that change things, do I need something else to make it mobile app compatible?

    No difference, except that you must support the Range header for partial downloads as described above.

    If you have a tutorial you think can be suitable for my needs, Can you please share it?

    This is off-topic for stackoverflow (as a request for an outside resource). I'd suggest you search, read and then ask a more specific question if you find something you don't understand in the tutorials you find.

    Will I be able to manage hundreds of videos the same way?

    Your server does not need to be designed any differently whether its only serving one video or capable of serving thousands of different videos. Obviously, you will need to be able to meet whatever scaling/load that is present, but the fundamental design of how you serve a video doesn't change whether you're serving 1000 copies of one video or 1000 requests for 1000 different videos.


    FYI, there are more advanced concepts for video streaming that do things like:

    1. Select an appropriate resolution for the client capabilities and deliver one of many different resolutions that you've pre-built.
    2. Do adaptive compression or resolution based on the ability of the bandwidth to keep up with the streaming - when the video can't keep up, you down-res or down-compress to lessen the volume of data sent so the bandwidth can handle it better.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum