Reputation: 573
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
Upvotes: 5
Views: 1596
Reputation: 133
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
Upvotes: 0
Reputation: 727
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.
Upvotes: 0