Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS streamer - improve latency #1268

Merged
merged 4 commits into from
Feb 18, 2023

Conversation

ericderace
Copy link
Contributor

The HLS Streamer's video latency increases over time. By leaving the browser tab open, the latency would add up to a few minutes over time. With the defautl settings, HLS.js never catches up to the edge and continues playing at 1x speed despite being minutes late.

By adding these configuration options, the latency is limited to 2 seconds.

from HLS.js documentation, this is what these changes should achieve:

{
                    "enableWorker": true, // actually defaults to true, but hls.js examples typically include this setting anyway. 
                    "lowLatencyMode": true, // Enable Low-Latency HLS part playlist and segment loading, and start live streams at playlist PART-HOLD-BACK rather than HOLD-BACK.
                    "maxLiveSyncPlaybackRate": 2, // Enables catching-up to the edge by enabling up to 2x playback (defaults to 1)
                    "liveSyncDuration": 0.5, // Starts the stream after 0.5 seconds is buffered
                    "liveMaxLatencyDuration": 2 // maximum number of seconds behind the edge, must be greater than the previous setting.
}

These settings has target latencies of min 0.5s, max 2s. (at the expense of stalling, but we're not watching a movie here, we're trying to monitor the 3d printing with as much low-latency as possible)

In my testing, I have counted about 2 - 3 seconds of delay using these settings. (with docker-wyze-bridge as my HLS stream source running on the Pi4, and a Wifi Wyze cam v2)

@ericderace
Copy link
Contributor Author

also added this option:

"backBufferLength": 5

the default was infinity, which would cause the browser tab to accumulate back buffer until the tab crashes

@meteyou
Copy link
Member

meteyou commented Feb 16, 2023

thx! can you run prettier to fix the code style?

@meteyou meteyou merged commit a529c41 into mainsail-crew:develop Feb 18, 2023
meteyou pushed a commit that referenced this pull request Feb 18, 2023
meteyou pushed a commit that referenced this pull request Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants