How the Playback Buffer Size is Determined
What is a Playback Buffer?
First of all, let’s understand what video streaming is. When you want to watch a movie stored on your computer’s hard drive, the player opens its file and plays it instantly. In the case of video streaming, the movie file is stored on a remote server and must first be downloaded to your device’s local storage. Only then will the device be able to start playing it back. What happens if the movie is stored on the server as a single file? You’ll have to wait a good while for the movie to start. That’s why in streaming large video files are divided into small chunks of a few seconds, recorded as separate files, and players request and download them sequentially from a video server. In this way you can start playback by downloading only the first segment of the movie. Information about the chunks (their URLs, duration, binding to real time, etc.) is stored in the manifest, a special file that is downloaded by the player when the video is opened.
This approach also solves the problem of live TV broadcasting. The studios continuously record the footage in small chunks and then stream them to the IPTV/OTT operator’s video servers. The video server then re-saves these streams into chunks whose length is adapted for playback on end-user devices. The devices download these chunks to the local storage, in a buffer. The number of chunks to be stored in a buffer is always limited. In this way, fresh chunks are continuously written to this buffer and already played chunks are deleted.
If the max buffer size is set too small, the player may not have time to load the next chunk before it finishes playing the current one (due to insufficient network speed, for example). In this case playback will stop until the next chunk is loaded. If the device does not have enough free memory, and the buffer is too large, the application may crash when it is close to full or other negative effects may occur.
How the Buffer Size is Determined
The max buffer size is calculated taking into account many parameters: stream bitrate, network speed, available free memory, stream type (Live or DVR), protocol (HLS or MPEG-DASH), and chunk size.
Media players of the SmartTUBE applications are configured to load as many chunks into the buffer so that they are sufficient for stable stream playback. Under normal conditions, 15–20 seconds of content in the buffer is enough. Frequent drops in network speed for more than 15–20 seconds are not normal and in this case the subscriber or IPTV/OTT operator should solve the network connection problem.
In case of live TV broadcasting, the buffer volume used (i.e. how much content is currently available for playback on the device) depends directly on the player’s parameter offset. Depending on the device type, the logic of a player used, type of a stream (HLS/DASH) and its manifest, this parameter defines the offset of the playhead from the end of the manifest when playback starts. For example, the player may set the offset to 10 seconds. However, it can start a stream with only 2.5 seconds of content in the buffer.
In order to protect low-memory Android devices from playback problems and application stability, especially when playing nDVR and VoD, the maximum buffer size is additionally limited to 70% of the Java Heap Limit. This way, operators can be calm for the trouble-free app performance on various devices in any playback modes.