Apple HLS puts constraints on peak bitrate, for example:
For live/linear content the peak bit rate MUST be within 10% of the BANDWIDTH attribute.
What’s exactly the peak bitrate and how to determine it?
Roughly speaking HLS stream is divided into non-overlapping segments, each segment is specified in the manifest file (m3u8 file), for example
#EXTINF:12.2,
91530609_003.ts
This means that the segment 91530609_003.ts has duration 12.2s. The bitrate of the segment is determined simply: divide the size 91530609_003.ts by its duration 12.2 .
The HLS spec. says:
The segment bit rate is the size of the Media Segment divided by its EXTINF duration.
However the peak bitrate is specified slightly vaguely:
The peak segment bit rate of a Media Playlist is the largest bit rate of any contiguous set of segments whose total duration is between 0.5 and 1.5 times the target duration.
Let’s suppose that target duration is 16s (#EXT-X-TARGETDURATION:16) then all segments with duration between 8s and 24s should be taken in calculation of the peak bitrate.
Outline of Calculation of the Peak Bitrate:
1) take single-element sets, actually each such one-element set is a single segment. Let’s denote bitrate1 as the maximum from all segment bit-rates.
2) take two-elements successive sets (let’ call such set as couple). If the number of segments is N then the number of couples is N-1 (successive elements are in each couple). The bit rate of a couple is calculated by dividing the sum of the segment sizes in the couple by the sum of theirs durations. Let’s denote bitrate2 as the maximum over N-1 couples.
3) take three-elements successive sets (let’ call such set as triple). The number of triples is N-2. The bit rate of a triple is calculated by dividing the sum of the segment sizes in the triple by the sum of theirs durations. Let’s denote bitrate3 as the maximum over N-2 triples.
…..
Finally the peak bitrate is max of {bitrate1,bitrate2,… bitrate_N-1}
Notice that if durations of all segments were identical then the step (1) is sufficient to find Peak Bitrate.
Note:There is no explicit definition how to measure bitrates in Mpeg System spec.
However, in “Measurement guidelines for DVB systems” (old version: ETSI TR 101 290 V1.2.1 (2001-05), the recent version: ETSI TR 101 290 V1.3.1 (2014-07) ) several methods to measure bitrates of transport/video stream are specified, most relevant are MGB1 and MGB2:
MGB1 (most popular method)
- Window (or gate) size is 1s
- Sliding: non-overlapping, the window “hops” each second
MGB2
- Window (or gate) size is 1s
- Sliding: overlapping, the window “hops” each 100ms
Alternatively, i use the following methods to compute instantaneous bitrates:
- window = 1s, step ‘frame_duration’ (overlapping windows)
- window = 1s, step = 1s (i.e. non-overlapping windows of 1s-length). Note, if the frame rate is 29.97 then the step=1s is not achievable.
- Window = 1GOP, step = gop duration (non-overlapping case), it’s required GOP length in frames fixed.
- Window = 1s, step 0.5s (overlapping windows), see the note in the item (2).
23+ years’ programming and theoretical experience in the computer science fields such as video compression, media streaming and artificial intelligence (co-author of several papers and patents).
the author is looking for new job, my resume
Oh my goodness! Impressive article dude! Thanks, However I am going through difficulties with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anyone else having similar RSS problems? Anybody who knows the answer can you kindly respond? Thanx!!
i can add your email in Newsletter, pls. send me directly to slavah264@gmail.com
Good blog you have here.. It’s difficult to find high-quality writing like yours nowadays. I really appreciate individuals like you! Take care!!
Greetings! Very useful advice in this particular article! It’s the little changes that will make the most significant changes. Many thanks for sharing!