Transmitting video streams with high resolutions and framerates requires a lot of network bandwidth, even with compression. It is not always known if the network between the sending and receiving ends of a video stream can handle a given bitrate. Once a video stream has started, various methods can be used to measure its quality. This article presents an algorithm that can give a rough estimate of how much network bandwidth is available for the video stream. The algorithm takes a measurement for each video frame, so it can be used to continuously monitor the available bandwidth.
The algorithm makes a few assumptions about how the video stream is transmitted. It assumes that the sending side is transmitting the bitstream one frame at a time at the expected frame rate. It assumes that the bitstream for each frame is divided into multiple smaller pieces (NALs), at least two. It also assumes that the transmitting side will generate the NALs for a frame all at once and try to send them as fast as possible. These requirements can be met by many existing video encoders, including H.264.
On the receiving end, the NALs will arrive after they travel through the network. If the network has limited bandwidth, some amount of time will be required to transmit each NAL, so they will arrive slower than they were transmitted. To get a sense of how much bandwidth is used, the receiving side can measure the time it takes to receive all NALs for a single frame (see Figure 1).
The measured time can be compared to the frame period to get a sense of how much bandwidth is being used. A ratio is computed:
If the ratio is greater than one, the frames are taking too long to transmit and the receiving side will eventually fall behind. If the ratio is close to one, then the network is barely managing to get the video stream across on time. If the ratio is close to zero, the network is having no trouble getting the frames across.
This algorithm could be used as part of a quality control system. Along with other information, it could be used to adjust the video quality dynamically according to changing network conditions.