mjs
mjs

Reputation: 22369

hls.js - how to increase the preloaded buffer size

I am generating hls content using ffmpeg from a remote src and I keep experience lagging that I do not understand in the browser.

For instance, even though there are say out8.ts, out9.ts ... hls.js player will be on say out7.ts and not load out8.ts or out9.ts.

It waits until out7.ts has almost finished playing and then it tries to load the out.m3u8 which will contain out8.ts and possibly out9.ts. But it does this so late, it eventually leads to lagging. I am doing this on localhost and in an efficient manner.

This seems to repeat itself once it starts to occur.

How can I make hls.js ask for the m3u8 more often and buffer what ever is present? Or as much as possible?

Also if there is already say 1-10.ts files, how can I make hls.js start on not the last one ( although closer to live ) but maybe on 5.ts so it won't run into this tight deadline issues concerning the next updated m3u8 and possibly lenghty 11.ts preventing it from buffering it?

My options:

    new Hls({
            autoStartLoad: true,
            debug: App.isDevelopment(),
            manifestLoadingTimeOut : 60000,
            /*manifestLoadingMaxRetry : 9,*/
            manifestLoadingRetryDelay : 500,
            levelLoadingTimeOut : 60000,
            /*levelLoadingMaxRetry : 9,*/
            levelLoadingRetryDelay : 500,

            fragLoadingTimeOut : 60000,
            /*fragLoadingMaxRetry : 6,*/
            fragLoadingRetryDelay : 250,
            startFragPrefetch : true
    });

Is there any difference in using clapper instead of hls.js regarding controlling such things?

Upvotes: 2

Views: 15809

Answers (2)

Mr Ji
Mr Ji

Reputation: 1

Try to use maxBufferLength.This is the guaranteed buffer length hls.js will try to reach, regardless of maxBufferSize.

Upvotes: 0

Simon
Simon

Reputation: 1274

The lag you are experiencing may be down to the segment duration. For a live stream, a short duration can cause more frequent requests for the playlist, which can cause additional network traffic. Apple recommends 10 seconds but (I believe) ffmpeg uses a default of 2 seconds. You can set the segment duration with the -hls_time option if you are using ffmpeg's hls muxer or with the -segment_time option if you are using the segment one. I'd try this first.

The HLS specification specifies that the time between reloading the playlist is determined by the target duration of the segments, so I guess the player must adhere to this if it is to be compliant with the spec.

You can use the EXT-X-START tag to start playing the video at a specific point in time.

Upvotes: 2

Related Questions