Repository navigation
fix: Don't restart a video that is still loading in libMPV - #1187
Open
TheBinaryLoop wants to merge 2 commits into
Open
TheBinaryLoop wants to merge 2 commits into
TheBinaryLoop wants to merge 2 commits into
Conversation
The load retry reopened the video whenever mpv had not reported a duration within 5 seconds, even while the original load was still in progress. Loads that legitimately take longer than that, such as a server-side transcode that needs a few seconds to produce its first segment or a server reached over a high-latency connection, were aborted and restarted every 5 seconds until the one minute retry window ran out, so playback only started after more than a minute. Only reopen when mpv is idle, i.e. when the previous load actually failed or ended. A load that is still running is left alone; if it hangs, mpv's network-timeout ends it, the player goes idle and the retry picks it up as before.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
LibMPV.loadVideore-opens the video when mpv hasn't reported a duration within 5 seconds, and keeps doing so for up to a minute. It does this even when the first load is still in progress, so every load that needs more than 5 seconds gets aborted and started over.This PR makes the retry check whether mpv is idle (
idle-active) before re-opening:network-timeout(60 s), after which the player is idle and the retry takes over as before.The one minute limit is unchanged, and so is the behaviour for streams that fail to open.
Issue Being Fixed
Starting a transcoded stream can take more than a minute with the libMPV player. For HLS, mpv only reports a duration once the first segment has arrived. When the server has to start a transcode first, that segment alone often takes a few seconds, and with a reverse proxy in front of the server or a server on another continent the playlist requests add a few more. Once the total goes past 5 seconds, every attempt is cancelled shortly before it would have succeeded. Playback only starts after the retry window closes and the last attempt is allowed to finish.
On the server side this looks like the master playlist being requested again every ~5 seconds, with the first segment requested and dropped each time, for about a minute.
Screenshots / Recordings
None, but here is how I tested it. I ran the libMPV wrapper in a Linux desktop build against a local HLS server that holds the first segment back for 8 seconds, then counted the requests:
I also checked that media_kit returns
"yes"foridle-activebefore anything is loaded, and"no"during the slow load. With mpv on its own,idle-activebecomes true right after a failed load (HTTP 404), which is the case that still gets retried.Tested On
Checklist