5

We generate hls files with segment size of 3 seconds. We use hlsjs for non Safari browsers and Safari has native hls support.

In hlsjs world we were able to restrict how much ahead we should be in terms of buffer using maxMaxBufferLength, where as we are unable to find similar solution for Safari. In Safari, after loading video m3u8, even if I pause after a second, in the network tab I can see that all the segments are being fetched which I would like to restrict.

I'll not be able to share our examples due to company polices. But, a public example file by hls.js is attached below:

https://test-streams.mux.dev/x36xhzz/url_6/193039199_mp4_h264_aac_hq_7.m3u8 try opening this url in Safari, and try pausing the video, you'll see that it continues to download. Where as if you open same one using https://hls-js.netlify.app/demo/ with maxMaxBufferLength: 5 it won't happen.

Is there an option at ffmpeg to make it controlled buffer or some solution that we should do for Safari by listening to events?

Found the same question here -> https://developer.apple.com/forums/thread/121074

Charan Kumar
  • 553
  • 2
  • 13

2 Answers2

0

Once checking out this resource, it highlights the fact that:

hls.js tries to buffer up to a maximum number of bytes (60 MB by default) rather than to buffer up to a maximum nb of seconds. this is to mimic the browser behavior (the buffer eviction algorithm is starting after the browser detects that video buffer size reaches a limit in bytes).

It is a good idea to check out Lines 175 and 176 of this script file here showing the 8 times of maxBufferSize to act as the maxBufLen. You might think about changing this.

Bilal Qandeel
  • 727
  • 3
  • 6
  • maxBufferSize, maxBufLen and maxMaxBufferLength etc hls.js configs are not something that I'm looking for, how can we mimic same behaviour on a browser which has native hls support (meaning where hls.js is not involved). – Charan Kumar Jul 25 '21 at 21:11
  • What I am trying to say is that you either customize your system's `hls.js` response, as you obviously did, or you sit back and give the lead to the native support to do whatever it was designed to do. You can't have both at the same time and expect the same results. My understanding is that those parameters should be still accessible programmatically (assisted by browser-type detection) or as `Safari` settings. i.e. Don't think `js` only. It could be `iOS` or `Safari` parameters too. – Bilal Qandeel Jul 25 '21 at 23:21
0

try to remove the src attribute from video element removeAttribute('src');

You may also need to call load method of video element to avoid browser crash

learntech
  • 123
  • 1
  • 9