Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming on low bandwith #7

Open
nikolajsheller opened this issue Jan 25, 2017 · 7 comments
Open

Streaming on low bandwith #7

nikolajsheller opened this issue Jan 25, 2017 · 7 comments

Comments

@nikolajsheller
Copy link

I am currently in Africa, and miss seeing DR. My son misses Ramasjang.

We have a stable, but slow (1.25 Mbit) connection. I cannot stream with the default quality, as this exceeds my available bandwidth.

Is there a way to set set quality/bandwidth manually, or have it change automatically like DR's flash player?

@msj33
Copy link
Contributor

msj33 commented Feb 7, 2019

@donkeylobster @TermeHansen @twinther

Do you know, if choosing streaming quality/rate is possible via the DR API?

I can't seem to find anything related to streaming quality on the API documentation
https://www.dr.dk/mu-online/Help/1.4 or 1.2 version for that sake.

Unless anyone knows a specific method, I think we should close this issue - Leaving this open for a couple of weeks to see if we have some luck finding a way.

@pank
Copy link

pank commented Feb 7, 2019

I don't really understand how HLS and DASH work, but I think it's in the protocol, somehow. To clarify, I think DASH chooses itself based on bandwidth.

You can definitely get the information somehow, here's sample output from youtube-dl

$ youtube-dl -F $url
...
HDS-272      flv        unknown     272k 
HLS-272      mp4        640x360     272k , avc1.66.30, mp4a.40.2
HDS-427      flv        unknown     427k 
HLS-427      mp4        640x360     427k , avc1.66.30, mp4a.40.2
HDS-743      flv        unknown     743k 
HLS-743      mp4        854x480     743k , avc1.640029, mp4a.40.2
HDS-1724     flv        unknown    1724k 
HLS-1724     mp4        1280x720   1724k , avc1.640029, mp4a.40.2
HDS-2643     flv        unknown    2643k 
HLS-2643     mp4        1280x720   2643k , avc1.640029, mp4a.40.2
HDS-4030     flv        unknown    4030k 
HLS-4030     mp4        1280x720   4030k , avc1.640029, mp4a.40.2 (best)

This may or may not be the relevant part of youtube-dl. It seems to look at qualities in the channels api (example).

You can get a list of all links using this.

$ url="..."
$ echo $(youtube-dl -F $url) | grep -E -oh "H[DL]S-[0-9]+" | xargs -L1 -I qual sh -c "echo qual && youtube-dl -g -f qual $url"

It seems HDS links are all the same; we can't simply select the quality via the url.

For HLS links it seems pretty easy (I only checked one video), we just need to add a suffix to the decrypted url:

ID resolution url suffix
HLS-272 640x360 /index_0_av.m3u8
HLS-427 640x360 index_1_av.m3u8
HLS-743 854x480 /index_2_av.m3u8
HLS-1724 1280x720 /index_3_av.m3u8
HLS-2643 1280x720 /index_4_av.m3u8
HLS-4030 1280x720 /index_5_av.m3u8

iplayerwww supports quality selection BTW (might serve as an inspiration).

@msj33
Copy link
Contributor

msj33 commented Feb 7, 2019

Thanks pank - Exactly what we are looking for here.

Is it both on LiveTV and Archive it is available?

MPEG-DASH is an adaptive streaming method - So not sure i understand why their is a link per fixed bitrate!?

I have seen that the DR website uses DASH - So we should be able to implement it. Only "downside" risk would be the "bad" picture quality untill the video buffer have build up.

A simple settings.json selector config option with a dropdown of the 6 options could also be viable solution

My python skills are limited, so if anyone are up for the job, i'll happily assist with testing and getting it into official KODI release.

@msj33
Copy link
Contributor

msj33 commented Feb 7, 2019

Just tested one of the DASH streams.......

You can actually specify the bitrate range directly in the DASH url - So you can partially define both min and max :-)

https://dr01-lh.akamaihd.net/i/live/dr01_0@147054/master.m3u8?b=100-500

https://dr01-lh.akamaihd.net/i/live/dr01_0@147054/master.m3u8?b=3000-4000

Note: Not all bitrates are accepted by the endpoint

@pank
Copy link

pank commented Feb 8, 2019

Ah cool. Is there any advantage of hls or dash when constraining size?

When I use iPlayer I specifically set the hls link as dash anyway doesn't manage to select an acceptable bitrate in terms of not lacking.

Do you know which bitrates work with dash? We could also make an option for dash vs hls and an option for quality.

I know python but not the xbmc libraries. It shouldn't be too hard to add, tho.

@neslo
Copy link
Contributor

neslo commented Nov 7, 2019

Hi @msj33 and @pank ,

(The below only relates to playing a show/episode and not the live TV channel streaming (e.g. DR1))

I live in Australia and i am experiencing problems with the bitrate too (I think it is a mix of distance and a slow connection). It does not even buffer data and nothing happens when I select a show.

I have experimented a bit based on your comments (I have otherwise no knowledge about streaming protocols)

Controlling the bitrate via

https://dr01-lh.akamaihd.net/some/show/url/master.m3u8?b=100-500

seems to be specific to each show regarding the best setting. And i have so far not got close to an ok picture quality.

But if I go e.g.

https://dr01-lh.akamaihd.net/some/show/url/index_2_av.m3u8

Then it works great and I also get an ok picture quality on any show i have picked so far.

Just wanted to add this to your findings.

Cheers,

@sdaau
Copy link

sdaau commented Oct 9, 2022

Hi all,

I was having a similar kind of issue: I use Kodi 19.4 on Android 9 device that is limited in resolution to 480p; however the DR Kodi plugin would always start with the largest (HD?) resolution/bandwidth; then my device has to start downsampling to 480p, and it had a really hard time doing that, which results with audio and video interruptions, quite irritating.

Some months ago, I even tried to build @neslo's PR #28 ; I managed to do that, and I was happy to choose the low quality streams, so I can enjoy uninterrupted video and audio playback. What I learned from this, as far as I can remember, is:

  • DR servers serve archived content with already muxed/interleaved audio/video streams, and they were easier to handle
  • However, they serve the live content in separate video and audio streams of differing qualities; so they have to be mulitplexed at runtime, and as far as I can tell, the only thing that does that in Kodi is InputStream Adaptive, and I think also the DR addon outsorces stream muxing to this plugin

Nevertheless, device crashed a month or so ago, and I needed reset to factory sattings, so all that was gone. So I started with the vanilla DR addon again, and like a week or so ago I also got an update for it.

Nevertheless, I got into the same problems again - and just as I was ready to waste some more hours on getting into Python for Kodi again, I played around a bit, and I was happy to realize: with this addon version (TermeHansen-6.0.0-matrix.1), there is no more need for patching; I can select live stream quality in the vanilla addon!

Not exactly sure what I did, but I was first playing with InputStream Adaptive (it only gets listed in the My add-ons/All list):

image

Then from there, on Configure, and I ended up with these settings:

image

Now I go to DR addon, and play a live stream, say DR1 - you have to show the player bar there, and select the Settings (cogwheel) icon:

image

... then in the Settings submenu, Select Program:

image

... and voilà - select your variant_bitrate program:

image

Great to have this again, and not even having to hack the addon myself :)

Thanks for the great work to the developers!


EDIT: turns out, "Select Program" is a built-in Kodi functionality for m3u8 streams (see e.g. xbmc/PlayListM3U.cpp); if you would like to have a lower bitrate by default when you select a channel (DR1, DR2 etc) from the plugin, use the advice from this post Changing playback quality:

Actually, in some cases, it is possible to lower the stream quality by limiting your bandwidth in the Kodi settings.

System -> Settings -> System -> Internet access -> Internet connection bandwidth limitation

The option is only visible with the Settings level at 'Advanced' or 'Expert'.

For me, with a setting of "1024 kbps" for Internet connection bandwidth limitation, I consistently get lowest quality stream chosen, when I click on (say) DR2 channel from this addon -- which is is great, because it's exactly how I want it setup (otherwise my device chokes on being unable to render the highest quality stream, and then there's a minute fight to lower the bitrate manually via "Select Program", unless Kodi crashes in the meantime).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants