Search code examples
m3u8trafficshaping

The defined BANDWIDTH in M3U8 and Linux tc


I have the following m3u8 file

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-STREAM-INF:BANDWIDTH=87835,RESOLUTION=426x240,CODECS="avc1.640015"
240-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=177512,RESOLUTION=426x240,CODECS="avc1.640015"
240-28/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=267977,RESOLUTION=854x480,CODECS="avc1.640015"
480-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=499454,RESOLUTION=1280x720,CODECS="avc1.640015"
720-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=957645,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1903257,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-28/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3907896,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-22/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=8265879,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-16/media_0.m3u8

I want to run a Linux tc command to shape the bandwidth for each defined bandwidth in the previous file, but I am not sure the bandwidth value is bps or kbps.

for example, I want to run a tc command for the follows

#EXT-X-STREAM-INF:BANDWIDTH=87835,RESOLUTION=426x240,CODECS="avc1.640015"
240-34/media_0.m3u8

which command is right

tc qdisc add dev eth1 root tbf rate 87835kbit burst 16kbit latency 2ms

or

tc qdisc add dev eth1 root tbf rate 87835 burst 16kbit latency 2ms

Solution

  • Section 4.3.4.2. EXT-X-STREAM-INF of the HLS RFC says

          BANDWIDTH
    
          The value is a decimal-integer of bits per second.  It represents
          the peak segment bit rate of the Variant Stream.
    

    So it's bps and you would just pass 87835 as a rate param for your tc command.

    Depending on what you want to do, just be aware that it is defined as the peak bit rate and not the average bit rate.