AirenSoft / OvenPlayer

OvenPlayer is JavaScript-based LLHLS and WebRTC Player for OvenMediaEngine.
https://OvenMediaEngine.com/ovenplayer
MIT License
497 stars 124 forks source link

Adaptive Stream and "Auto" decision #419

Open morbificagent opened 3 months ago

morbificagent commented 3 months ago

Hi together,

I have configured OME for adaptive output and was testing LLHLS and WEBRTC via the demo player. But in both versions i have the same problem:

It always falls to the lowest resolution/bitrate.

I have configured 720 (1,8Mbit), 480 (600kbit), 240 (300kbit) but even when it starts playing at 720 it changes to 480 first and then to 240.

The bandwith-settings are like this:

                <Video>
                    <Name>720p_h264</Name>
                    <Codec>h264</Codec>
                    <Bitrate>1500000</Bitrate>
                    <Width>1280</Width>
                    <Height>720</Height>
                    <Framerate>30</Framerate>
                </Video>
                <Video>
                    <Name>720p_vp8</Name>
                    <Codec>vp8</Codec>
                    <Bitrate>1500000</Bitrate>
                    <Width>1280</Width>
                    <Height>720</Height>
                    <Framerate>30</Framerate>
                </Video>
                <Video>
                    <Name>480p_h264</Name>
                    <Codec>h264</Codec>
                    <Bitrate>800000</Bitrate>
                    <Width>854</Width>
                    <Height>480</Height>
                    <Framerate>30</Framerate>
                </Video>
                <Video>
                    <Name>480p_vp8</Name>
                    <Codec>vp8</Codec>
                    <Bitrate>800000</Bitrate>
                    <Width>854</Width>
                    <Height>480</Height>
                    <Framerate>30</Framerate>
                </Video>
                <Video>
                    <Name>240p_h264</Name>
                    <Codec>h264</Codec>
                    <Bitrate>300000</Bitrate>
                    <Width>426</Width>
                    <Height>240</Height>
                    <Framerate>30</Framerate>
                </Video>
                <Video>
                    <Name>240p_vp8</Name>
                    <Codec>vp8</Codec>
                    <Bitrate>300000</Bitrate>
                    <Width>426</Width>
                    <Height>240</Height>
                    <Framerate>30</Framerate>
                </Video>

I have tested it in chrome on two different machines (home macos, work win) with two different internet speeds (home 16Mbit, work 200Mbit) and the OME server is inside an RZ a few miles away with a good peering. Manual selecting the 720p variant works great without problems...

So i cant understand why it always chooses the badest stream.

I have tested LLHLS in THEOplayer and there everything is fine as it selects my 720p variant.

Does anyone have this problem too?

nums commented 3 months ago

I have the same issue on my side. For now, I don't know if the source of the issue is hls.js or ovenplayer. Maybe, we can resolve this with a custom "Auto decision", while using window.op_hls.abrController.bwEstimator.getEstimate() the data return of this method seems good and then we can adapt the quality level compared to that. I will do some check and let you know

nums commented 3 months ago

I suggest this quick and dirty temporary fix:

ovenPlayer.on('ready', (evt) => {
  setInterval(() => {
    let currentBW = window.op_hls.abrController.bwEstimator.getEstimate();

    let levels = ovenPlayer.getQualityLevels();
    levels = JSON.parse(JSON.stringify(levels));
    levels.sort((a, b) => a.bitrate - b.bitrate);
    let index = -1;
    for(var i in levels) {
      let level = levels[i];
      if(currentBW > level.bitrate)
      index = i;
    }

    if(index != -1 && index != ovenPlayer.getCurrentQuality() && ovenPlayer.getState() == 'playing') {        
      console.log('ABR', 'we change index or quality level', currentBW, index, levels[index]);        
      ovenPlayer.setCurrentQuality(parseInt(index));            
    }

  }, 3000)
})

I have tested it with the bandwidth limitation of chrome developer tool.

morbificagent commented 3 months ago

@nums

Many thanks!

I will test this too and respond after the weekend... Have a nice one