aussieaddons / repo

Aussie Add-ons repository for Kodi
http://aussieaddons.com/installation/
103 stars 45 forks source link

SBS on demand 720p movies are listed as "SD" #28

Open demidog opened 8 years ago

demidog commented 8 years ago

I just noticed that all of the movies on your SBS demand addon are listed as "SD" in the list of movies. When playing the movie some of them say 720p in the now playing interface. For example see the movies Kenny, and Leon the Professional that are available at the moment and are 720p. Could you fix this so we can see the HD/720p movies in the lists.

andybotting commented 8 years ago

I think the issue here is that we don't know what the quality will be until we begin the stream. Due to the type of streaming, I believe the quality can be upgraded or downgraded depending on the quality of the connection - so I think maybe the right answer here is to not provide any movie quality information.

natumbri commented 6 years ago

Something that I would find useful would be being able to choose the video quality from the qualities available. If, for some reason, I'm using a crappy internet connection, it would be useful to be able to force it to get the 512kbps stream instead of the 1500kbps stream. It would also be useful to force it to NEVER select the 128kbps stream, which is a waste of time.

I think SBS generally has up to 4 bit rates available. Is it possible to choose the video quality?

The following information might be helpful for achieving that:

[Using Berlin Station, S1E1 for an example] This is the url that triggers playback - I'll call this ('the first url'): https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,512,1500,1000,128,K.mp4.csmil/master.m3u8?__b__=500&b=0-2000&__a__=off&set-akamai-hls-revision=5

It generates a m3u8 file with four streams in it, reflecting the four bit rates [in order, roughly 512,1500,1000,128 kbps]. The only difference between the url for the four streams is the number in the "index" part of url. The number corresponds to the position of the bitrate in the first url [so: 0=512, 1=1500, 2=1000, 3=128]. https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,512,1500,1000,128,K.mp4.csmil/index_0_av.m3u8?set-akamai-hls-revision=5 https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,512,1500,1000,128,K.mp4.csmil/index_1_av.m3u8?set-akamai-hls-revision=5 https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,512,1500,1000,128,K.mp4.csmil/index_2_av.m3u8?set-akamai-hls-revision=5 https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,512,1500,1000,128,K.mp4.csmil/index_3_av.m3u8?set-akamai-hls-revision=5

If you edit the first URL, omitting any of the stream qualities, the m3u8 file that is generated omits the stream. So, for example, if you make the first URL: https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,1500,K.mp4.csmil/master.m3u8?__b__=500&b=0-2000&__a__=off&set-akamai-hls-revision=5

The m3u8 file that it generates contains only: https://sbsvodns-vh.akamaihd.net/i/vod/SBS_Production/managed/2017/09/05/2017-09-05_592354_,1500,K.mp4.csmil/index_0_av.m3u8?set-akamai-hls-revision=5

Which plays the 1500Kbs stream.

glennguy commented 6 years ago

Hi @natumbri Kodi supposedly (from Krypton onwards) will select the best stream for your connection. The pause at the beginning of each video is where that is happening - it downloads the first chunk from each of the sub playlists (index_0_av, index_1_av etc.) and tests the speed of download/length of chunk to determine which one to choose. I have no idea though if this actually works well or not.

However, going forward some Kodi devs have stated that they won't be putting any more work into improving the way this works within Kodi's core and instead relying on inputstream binary add-ons to provide this functionality.

The inputstream.adaptive add-on is now HLS capable in both Krypton and Leia and so we'll look at implementing a settings option to use it instead of the default (Kodi/ffmpeg). The add-on settings of inputstream.adaptive itself provides options to select minimum/maximum bandwidth and that should help select the correct stream. At some point in the future adaptive bitrate switching will also be added to inputstream.adaptive so the stream will change on the fly if available bandwidth increases/decreases.

glennguy commented 6 years ago

Also interesting to know that the playlist generation seems to be dynamic, thanks for the info and research. I wonder if we could ask it for higher than 1500K?

natumbri commented 6 years ago

Hi,

I haven't had much luck with automatic selection of the correct stream; it always seems to misjudge the quality of my connection, and never seems to get back on track.

Sometimes, it would be useful for me to be able to exclude the lowest quality (unwatchable) and the highest quality (endless buffering) and limit any automatic selection to mid-rate streams.

To that end, I hacked together the following:

In comm.py:

def get_stream(program_id):                     
resp = fetch_protected_url(config.stream_url % program_id)
    xml = BeautifulSoup(resp, 'html.parser')         
    stream = {}                                                     
stream['url'] = xml.video['src']                            
settings = xbmcaddon.Addon(id='plugin.video.sbs') 
    if settings.getSetting("low_bitrate")=="false": stream['url'] = stream['url'].replace(',128,',',')
    if settings.getSetting("med_bitrate")=="false": stream['url'] = stream['url'].replace(',512,',',')                                                   
    if settings.getSetting("high_bitrate")=="false": stream['url'] = stream['url'].replace(',1000,',',')     
    if settings.getSetting("max_bitrate")=="false": stream['url'] = stream['url'].replace(',1500,',',')
subtitles = xml.find('textstream', attrs={'type': 'text/srt'})
    if subtitles:                                    
        stream['subtitles'] = subtitles['src']                
    return stream

In settings.xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
  <!-- Debugging -->
  <category label="10090">
    <setting label="10094" type="bool" id="low_bitrate" default="false"/>
    <setting label="10095" type="bool" id="med_bitrate" default="true"/>
    <setting label="10096" type="bool" id="high_bitrate" default="true"/>
    <setting label="10097" type="bool" id="max_bitrate" default="false"/>
    <setting type="sep"/>
    <setting label="10098" type="action" action="RunPlugin(plugin://plugin.video.sbs/?action=sendreport)"/>
  </category>
</settings>

In strings.xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
    <string id="10000">SBS On Demand</string>

    <!-- Categories -->
    <string id="10080">Settings</string>
    <string id="10090">Debugging</string>

    <!-- Settings -->
    <string id="10093">Enable Subtitles</string>
    <string id="10094">Enable 128kbps</string>
    <string id="10095">Enable 512kbps</string>
    <string id="10096">Enable 1000kbps</string>
    <string id="10097">Enable 1500kbps</string>

    <!-- Debugging -->
    <string id="10098">Send error report</string>

</strings>

I haven't tested it with the settings functionality enabled and I don't really know anything about kodi, python or programming, but I did test it with the following hard-coded into getstream():

stream['url'] = stream['url'].replace(',128,',',')
stream['url'] = stream['url'].replace(',1500,',',')

It seemed to work.

I tried some bitrates < 128kbps and > 1500kbps, and some intermediate values different to 512 and 1000, but I wasn't able to get a stream.

Cheers, Nik

glennguy commented 6 years ago

Hi Nik,

Despite not knowing anything as you say you've done well to come up with that!

I found these resources that give some more concrete explanation to get what we want from the API: https://learn.akamai.com/en-us/webhelp/media-services-live/media-services-live-stream-packaging-rtmp-ingest-hds-and-hls-outputs-user-guide/GUID-7DAB5FF4-1B8C-4D5E-906F-5B07BD9D8FE0.html https://support.brightcove.com/support-akamai-hds-remote-asset-delivery

I had a play too with different values, but I think there's not likely to be any more stream renditions that they don't use. Removing the bandwidth filter (&b=0-2000) didn't give anything more.

Removing the 128k stream probably would have no practical effect but maybe an option similar to the one in the iView add-on which would enable/disable HD streams would get the job done. What do you think @andybotting ?

andybotting commented 6 years ago

@glennguy Either low/medium/high or HD on/off is cool with me

natumbri commented 6 years ago

Using a high latency (but usually plenty fast enough once it gets going) wireless connection, I occasionally get the 128k stream, which is unwatchable. I could use an option to disable that stream.

When the wireless connection is not performing well, even 1000kbps can be difficult, so it is useful to me to be able to force 512k, even though the quality isn't great.

glennguy commented 6 years ago

@natumbri - thanks for doing the legwork - changes made in aussieaddons/plugin.video.sbs#1280

You can use this version now if you have the development repo installed