videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
38.02k stars 7.45k forks source link

Accessing hls.js properties #8067

Closed gregfr closed 1 year ago

gregfr commented 1 year ago

Greetings

How can I access properties from hls.js, such as latency, from the VideoJS player object?

Thanks in advance

Regards

Yie3 commented 1 year ago

TQ

gkatsev commented 1 year ago

It would depend on what plugin you're using for integrating hls.js.

gregfr commented 1 year ago

The default plugin, I think it's an embedded version of VHS:

                html5: {
                    vhs: {
                        overrideNative: true,
                        limitRenditionByPlayerDimensions: false,
                        experimentalLLHLS: true,
                        experimentalBufferBasedABR: true,
                        liveSyncDuration: 2.5,
                        maxLiveSyncPlaybackRate: 1.1
                    }
                },

Thanks in advance

Regards

gkatsev commented 1 year ago

VHS isn't hls.js, they're separate playback engines.

You can get to it via player.tech().vhs but it's not recommended.

gregfr commented 1 year ago

Oh I thought VHS were using hls.js underneath, thanks! So is there a way to access in VHS properties such as latency?

Regards

gkatsev commented 1 year ago

What do you mean by latency? VHS documentation is available here: https://github.com/videojs/http-streaming

gregfr commented 1 year ago

Thank you for your answer.

I've been using VideoJS for years but now I need to move to low-latency (HLS and wRTC). In my tests VideoJS is "more late" than others players, and frequently stops (the user has to reload the page). I've been comparing several players and hls.js gives a latency parameter (the number of seconds the stream is late compared to the real time) which can be used to "reset" the playback if the drift is too high. I was wondering how to access this value in VideoJS.

Regards

gkatsev commented 1 year ago

You need to set llhls (for Video.js 8) or experimentalLLHLS (for Video.js 7) to true to enable low latency.

var player = videojs('my-video', {
  html5: {
    vhs: {
      llhls: true
    }
  }
});