mpv
mpv copied to clipboard
player: add ability to speed up based on delay
Added the following command-line options: --rt-catchup: enables the new feature --rt-catchup-multiplier: (double) sets a constant speed multiplier --rt-catchup-max-delay: (double) sets the maximum delay before speedup
If --rt-catchup is enabled, when the player falls a number of seconds exceeding the value given by --rt-catchup-max-delay, playback speed is multiplied by the sum of 1 and the square of the product of the value given by --rt-catchup-multiplier and the current delay in excess of the delay given by --rt-catchup-max-delay in seconds.
The speed multiplier is applied in addition to the playback speed multiplier set by the user.
This feature is introduced to help prevent falling behind real-time sources such as live streams.
This is a cool feature! Sadly I can't get it to work properly. As soon as I pause a stream (from e.g. streamlink) and then resume it to test this out, the player just goes completely bonkers with --rt-catchup --rt-catchup-multiplier=1.1 --rt-catchup-max-delay=1.1
~~Thanks for the feedback. I need to take another look at the implementation. If you use a value of 1.0 for both options, does it have the same problem?~~
I've changed the implementation to hopefully address the problem you most likely encountered. Could you try again with the current revision?
@CounterPillow have you been able to test the changes?
Just tried it again with both a twitch livestream through streamlink, and a youtube livestream directly passed to mpv, and both had issues when I paused them for a few seconds and resumed. The time remaining was at -0.9, but it was clearly behind, and it just started dropping frames like crazy.
Thanks for the feedback. In my testing, I used a streaming server which essentially appends to a mpegts file which is served to clients piece by piece. It looks like youtube and twitch streams get downloaded in larger chunks which I need to handle better.
@CounterPillow I've corrected the feature such that I was able to play a youtube livestream without the interruptions you described using options --rt-catchup --rt-catchup-multiplier=0.1 --rt-catchup-max-delay=5.0. I didn't test a twitch livestream, but I imagine the fix applies there as well.
This works now, except it seemingly restricts the speed property even when not using rt-catchup. Try e.g. increasing the speed in a local video with ] past 1.1, it just keeps it at 1.1 seemingly.
Also the catchup with twitch through livestreamer seems to happen basically instantly, I'd expect it to just multiply the speed by 1.1 to catch up but it seems to basically increase it exponentially until it catches up.
Thanks for working on this in either case, and sorry that I'm finding all of these problems.
@CounterPillow Okay, I've made sure the speed is only changed when the flag is on. As for the catch-up speed, I've changed the multiplier to grow quadratically with the delay. You should be able to get a smooth playback by making the multiplier small enough.