Search code examples
video-streamingbandwidthhttp-live-streaming

How to properly calculate bandwidth needed for a live video stream?


Say, I have a service where a live video stream is running. For example, there is single HD color video camera in my warehouse which I want to stream all the work process to a site for viewers 24/7.

Now, the camera sends its stream to my server, which translates it to a canvas on a HTML page. If the server is local, I don't care about how much data camera sends to it, but I want to know how much data goes to viewers.

So, if there are no viewers at the moment, no bandwidth is used, right? If there are 1000 viewers, then it's 1000 times more bandwidth needed than for 1 viewer? If there are 2 cameras, then I should multiply it by 2?

How can I properly calculate the bandwidth requirements for these different conditions to know how much it will cost me?


Solution

  • a canvas on a HTML page

    Canvas? Consider using a <video> tag, unless you have a strange requirement where you're decoding video yourself.

    So, if there are no viewers at the moment, no bandwidth is used, right?

    The camera will still send a single stream of bandwidth to the server, but yes, no bandwidth from the server onwards will be used.

    If there are 1000 viewers, then it's 1000 times more bandwidth needed than for 1 viewer?

    Correct.

    If there are 2 cameras, then I should multiply it by 2?

    Correct.

    How can I properly calculate the bandwidth requirements for these different conditions to know how much it will cost me?

    Your basic math is correct, but there are other things you're not considering. If you're really going to have 1,000 people, you're probably also going to want your video to work across various browsers and at different bitrates. These days, it's typical to encode anywhere from 3 to 8 different bitrates of video, with varying resolution. Clients can then choose the bitrate needed. For codecs, you can generally get by with H.264 and AAC audio on most devices.

    If this is a public stream, I recommend just streaming to YouTube and let Google eat the cost of all this. As you can tell, this gets expensive very fast.