video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
14.76k stars 2.56k forks source link

Configuration Settings for Playing High Bitrate Video #5031

Closed mattzucker closed 1 year ago

mattzucker commented 1 year ago

What do you want to do with Hls.js?

Video on Demand playlist with 30 second segments, where each segment has a high bitrate (e.g. 30Mbps). This means that each segment has a file size of around 100MB. Chrome's limit for the Media SourceBuffer is 150MB, so when HLS.js tries to load the second fragment, I am presented with a buffer full error and the video stops playing.

Can you please help me set the right configuration options?

What have you tried so far?

I have tried a few different values for setting backBufferLength, maxBufferLength, and maxBufferSize but even changing those to really low values did not make a difference. The only configuration that I got to work was:

backBufferLength: 0,
maxMaxBufferLength: 15

But I think I am using maxMaxBufferLength incorrectly. Also, for other videos with a lower bitrate, I wouldn't want to limit the buffer so drastically.

robwalch commented 1 year ago

Not sure this is a valid use-case for any MSE based player. The buffer options can only limit the number of segments we append ahead of the playhead down to 1. Your stream must be segmented appropriately.

You could try enabling the "progressive" option. Streaming the segment to produce smaller appends should work-around the SourceBuffer Quota limit. Note that this option is experimental, and was developed to support chunk-transfer encoded streams which is not a supported feature of HLS.

mattzucker commented 1 year ago

Thank you. With progressive: true the playback gets further along, but still fails with buffer full. It looks like it is able to append the video in smaller chunks but it is not evicting the back buffer well enough for this use case. I understand it is experimental, just putting some notes here.

What would you recommend for the high bitrate case? Is it just a matter of splitting the video into smaller files?

robwalch commented 1 year ago

What would you recommend for the high bitrate case? Is it just a matter of splitting the video into smaller files?

Six second segments are recommended.