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

Live stream uses about 10x more bandwidth than browser #498

Open
saepurusass opened this issue Jul 24, 2023 · 7 comments
Open

Live stream uses about 10x more bandwidth than browser #498

saepurusass opened this issue Jul 24, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@saepurusass
Copy link

Context

Please provide any relevant information about your setup

  • Add-on Version: 7.0.2.alpha7
  • Kodi Version: 20.1 from Debian repo x86_64 / LibreELEC nightly 20230715-9a33cd2 on arm64
  • Kodi GUI Language: English
  • Operating System: Debian 12 x86_64 / LibreELEC arm64
  • Operating System Language: English

Expected Behavior

Playing youtube LIVE stream in browser and in Kodi should consume roughly the same amount of bandwidth.


Current Behavior

When playing youtube LIVE stream in Kodi, bandwitdth usage is roughly 10x higer in Kodi.

For example, when playing this stream LIVE right now:
https://www.youtube.com/watch?v=KI8MMnZOWBE

In browser when I select the maximum available quality 1080p60, I see bandwidth usage around 150kiB/s (1.2Mbit/s).
When I play the same stream in Kodi at just 720p (or so Kodi tells me), I see bandwidth usage around 1.5MiB/s (12Mbit/s).

At the time of the testing, the image was pretty static. Bandwidth is higher when the image changes fast.

On evenings, when I have a live steam playing for hours, I often see from my monitoring charts that there is constant average bandwidth usage around 25Mbit/s (about 30Mbit is the max for that particular connection). And nothing else is consuming any noticeable bandwidth at the same time. So Kodi pretty much uses almost all the available bandwidth when watching one single 720p live stream.

At the same time browsers and different 3rd party android apps use significantly less bandwidth and the usage is roughly the same for browsers and android.


Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Use any recent Kodi version
  2. Install youtube plugin (no configuration, no login info, no api keys, nothing)
  3. Use Kore/Yatse (kodi remote control app on mobile) to share/send youtube LIVE stream link to Kodi (that is the way I do it).
  4. Monitor network bandwidth, comapre with non-live stream.

Log

Log: https://hastebin.skyra.pw/suqudanoqe.yaml


Additional Information

Playing non-live videos does not have such behaviour and bandwidth usage seems normal. Only live streams are affected for some reason.

I usually run LibreELEC on little cheap arm tvbox and noticed the high bandwidth usage there.
Just to confirm it, I tried on linux laptop to make monitoring traffic bit easier and I can confirm the same pattern on both machines.


@saepurusass saepurusass added the bug Something isn't working label Jul 24, 2023
@MoojMidge
Copy link
Collaborator

MoojMidge commented Jul 25, 2023

What do you use to monitor your network throughput?

For me the connection speed reported by the Youtube "Stats for nerds" display, the Windows 10 Task Manager and Resource Monitor, and the bandwidth headers that the Youtube servers send to Kodi when it is playing a stream all seem to roughly match, for both live and non-live streams, when playing directly in Kodi. Nothing like an order of magnitude difference that you are seeing.

Can you provide a debug log with libcURL and FFmpeg component logging enabled?

EDIT: Oh, I think I can see this happening when using FFmpeg. Doesn't seem to happen when using InputStreamAdaptive. Not familiar with what FFmpeg is trying to do to cause this though.

@saepurusass
Copy link
Author

saepurusass commented Jul 25, 2023

I am using munin monitoring graphs for longer period monitoring.
And I use bmon on my linux firewall/client machine to see live data.

I am not sure how to enable debug logging for specific components. If you give me instructions, I can provide the logs.

Yes, I think I have FFmpeg and InputStreamAdaptive both installed.

I do not see any options to switch between them. Except under MPEG-DASH I see reference to Inputstream Adaptive and that it is required. However, enabling MPEG-DASH did not work on my ARM64 box, it is very glitchy and video and audio are out of sync.

Should I disable/remove Inputstream FFmpeg Direct? I guess that makes it impossible to use it.
I have to check if that fixes the bandwidth issue. I can't do it right now, I will check it later.

@MoojMidge
Copy link
Collaborator

I am not sure how to enable debug logging for specific components. If you give me instructions, I can provide the logs.

I can replicate the issue and I can generate the logs myself, so no need for you to do this, but FYI https://kodi.wiki/view/Log_file/Easy#Enable_component-specific_logging

I do not see any options to switch between them. Except under MPEG-DASH I see reference to Inputstream Adaptive and that it is required. However, enabling MPEG-DASH did not work on my ARM64 box, it is very glitchy and video and audio are out of sync.

As you have observed, the MPEG-DASH live streams do not currently work with Kodi, but InputStreamAdaptive can also be used with the HLS live streams. This functionality is not available in the Youtube plugin just yet, need some time to create a PR for this.

Should I disable/remove Inputstream FFmpeg Direct? I guess that makes it impossible to use it.
I have to check if that fixes the bandwidth issue. I can't do it right now, I will check it later.

No, don't do this. The FFmpeg I was referring to is used internally by Kodi, not the InputStream plugin version.

Unfortunately nothing really to do at the moment, as I don't have the time to investigate why this is happening (at first glance it looks like the same segment chunks are being downloaded multiple times in parallel for some reason). When the Youtube plugin is updated you will be able to use InputStreamAdaptive instead, to avoid the problem.

You can download this test version and check if this resolves the problem for you. There will be a new option to enable "Adaptive HLS" for live stream instead of just MPEG-DASH.

@saepurusass
Copy link
Author

saepurusass commented Jul 25, 2023

You can download this test version and check if this resolves the problem for you.

Thank you, that version seems to make it lot better.

While testing, I tried to find a live stream to replicate the problem first and I was actually kinda surprised that not every live stream replicates the problem.
I found some live news, live sport and such that used about the same bandwidth and no apparent problem.

Thinking back to the streams I noticed problem with I started to look for live gaming streams and found this random one:
https://www.youtube.com/watch?v=qm3QY87e-qw

During fast moving scenes I observed numbers like this:
1080p browser was around 800-1000kiB/s which is about 6.4-8 Mbit/s
Kodi stream with 7.0.2alpha7 was consistently over 1000kiB/s often hitting over 3MiB/s which is cap for that connection and close to 30Mbit/s

Switching to test version I see about similar numbers for kodi and browser in static screens.
At fast moving scenes Kodi at 720p uses actually bit less bandwidth and that is the expected result, since browser is at 1080p.

At first glance it seems to me that the test version fixes that particular problem for me.
I'll keep an eye on my bandwidth graphs for a few days to monitor it for bit longer.

EDIT:
While fixing one problem, it introduces another. Now I can't play non-live videos.
UnboundLocalError: cannot access local variable 'manifest_url' where it is not associated with a value
Full error log: https://hastebin.skyra.pw/raw/isilotebiv

Switching back to 7.0.2alpha7 non-live videos work again.

@MoojMidge
Copy link
Collaborator

Heh, that's why it is just a test version - I haven't tested it. Anyway silly error and simple fix, you can re-download the test version using the same url and re-install and it should work now.

@saepurusass
Copy link
Author

Thank you very much for such a speedy fix.
Non-live now works too.

@saepurusass
Copy link
Author

So far looks pretty good:

https://imgur.com/a/3OH7dqq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants