Stream switching/adapting in HLS

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
takoi Offline
Team-Kodi Member
Posts: 1,022
Joined: Oct 2009
Reputation: 21
Location: Norway
Post: #1
Here's an example:
http://links.latincdn.com/vod/hls/big_bu...p_001.m3u8

It contains the following streams:

Code:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1896000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001/big_buck_bunny_1080p_h264_HLS_16x9_480p_001.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1596000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_1500Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_1500Kb.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1296000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_1200Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_1200Kb.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=996000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_900Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_900Kb.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=864000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_768Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_768Kb.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=608000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_512Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_512Kb.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=352000
big_buck_bunny_1080p_h264_HLS_16x9_480p_001_256Kb/big_buck_bunny_1080p_h264_HLS_16x9_480p_001_256Kb.m3u8
Code:
Stream #0:0: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 1896000
    Stream #0:1: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 852x480 [SAR 1:1 DAR 71:40], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 1896000
    Stream #0:2: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 1596000
    Stream #0:3: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 852x480 [SAR 1:1 DAR 71:40], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 1596000
    Stream #0:4: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 1296000
    Stream #0:5: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 852x480 [SAR 1:1 DAR 71:40], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 1296000
    Stream #0:6: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 996000
    Stream #0:7: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 996000
    Stream #0:8: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 864000
    Stream #0:9: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 864000
    Stream #0:10: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 608000
    Stream #0:11: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 512x288 [SAR 1:1 DAR 16:9], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 608000
    Stream #0:12: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, s16
    Metadata:
      variant_bitrate : 352000
    Stream #0:13: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 512x288 [SAR 1:1 DAR 16:9], 24 tbr, 90k tbn, 48 tbc
    Metadata:
      variant_bitrate : 352000

How, if you play the master m3u8, xbmc seems to always just pick the first stream and stick with it, no matter what. Not automatically switching as expected. Am i doing something wrong here or is it that adaptive bitrate is not supported?
If it isn't, is there a way to pick the stream to play manually? For audio I can use setAudioStream through python or select it through gui, which works fine. But what about video stream?
find quote
spiff Offline
Retired Developer
Posts: 12,384
Joined: Nov 2003
Post: #2
not yet supported. i started working on it ages ago, there's a (dysfunctional) pr. haven't found the time to look at it again.

however the fact that nrk is moving to hls, will bump it on my priorities..
find quote
a_wein Offline
Junior Member
Posts: 2
Joined: Sep 2013
Reputation: 0
Post: #3
Any update on this issue?
find quote
takoi Offline
Team-Kodi Member
Posts: 1,022
Joined: Oct 2009
Reputation: 21
Location: Norway
Post: #4
Since frodo it picks the best stream based on the bandwidth setting instead, which is good enough for me. Adaptive switching is probably very hard to get right anyway.
(This post was last modified: 2013-09-19 17:23 by takoi.)
find quote
a_wein Offline
Junior Member
Posts: 2
Joined: Sep 2013
Reputation: 0
Post: #5
(2013-09-19 17:22)takoi Wrote:  Since frodo it picks the best stream based on the bandwidth setting instead, which is good enough for me. Adaptive switching is probably very hard to get right anyway.

Thanks for this hint. Thats fine for me too.
I'll just upgrade to 12.2 now. (Sorry - I should have tested the latest release prior to complaining.)
find quote
nero12 Offline
Senior Member
Posts: 214
Joined: Feb 2010
Reputation: 1
Post: #6
Bumping this post back up


is Kodi able to change on the fly to the best stream ?
or will it pop up with a dialog box askign which stream i like to play ?

or no further development is made on this ?
find quote
takoi Offline
Team-Kodi Member
Posts: 1,022
Joined: Oct 2009
Reputation: 21
Location: Norway
Post: #7
(2015-07-04 06:06)nero12 Wrote:  Bumping this post back up


is Kodi able to change on the fly to the best stream ?
or will it pop up with a dialog box askign which stream i like to play ?

or no further development is made on this ?
Quoting myself "it picks the best stream based on the bandwidth setting". See http://kodi.wiki/view/Settings/System#Internet_access Setting's called "Internet connection bandwidth limitation ". Set it to what your connection can handle and you'll consistently get the best quality.
find quote
nero12 Offline
Senior Member
Posts: 214
Joined: Feb 2010
Reputation: 1
Post: #8
not really user friendly i could just simply open the m3u8 file and copy the link and save it to a strm file and play, its the same thing

If an adaptive stream is not possible, i wish kodi team would at least popup a dialog box for user to select which playlist.m3u8 to playback from master.m3u8 file.

The problem users face today, is the fact that if u watch or playback a stream during none peak hours u will be fine, but the same stream during peak hours ur line is congested to a stage that it becomes unwatchable, thats how internet is unfortunately.
so a simple dialog could fix this, i just started learning python and making good progress, hope one day i can make kodi understand when playing an adaptive stream it must list all url inside this file for user to select. (this i believe will only work for http adaptive based streams) (.ts formats).

as the file structure goes like this typically for http based adaptive streaming

master.m3u8 -> 4 individual playlist.m3u8 files inside with different aspect ratio (240,480,720,1080) -> each of these 4 files has a bunch of .ts url files inside.
(This post was last modified: 2015-07-05 05:58 by nero12.)
find quote