-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Seeking 5 seconds keybinds do not actually seek 5 seconds #4766
Comments
This default behavior is expected and very confusing to users. It can be changed. First some background… By default the keys ← and → are bound to From the seek command section of the mpv manual:
This means What this has to do with is the way videos are usually encoded. The common formats put a priority on reducing the size of the video file for normal forward playback. The video compression techniques used make it harder to seek to a random point in the video. One of the compression techniques is to use a keyframe which contains a full picture of the video frame and then follow it by delta frames that only describe the differences from the keyframe. The IBM tutorial Keyframes, InterFrame & Video Compression is a good introduction to video compression. The quick way to seek is to find a keyframe close to the requested position and display that. That is what To seek to an exact spot in the video requires the player to find a keyframe and then decode frames until reaching the exact spot in the video. How long that takes depends upon the interval between keyframes and where the requested position happens to land. Unfortunately changing the key binding to use an exact seek at this time will not work due to the open IINA issue #3710. The fix for that issue was just merged and will be included in the next release of IINA. Once that is fixed you can bind a key to Making the situation worse, the recently upgraded versions of the mpv and FFmpeg libraries contain regressions that cause seeking by keyframes to sometimes malfunction. Last I checked those problems have not been fixed. There is another way to enable exact seeks. From the
To enable exact seeks using
With today's more powerful Macs exact seeking is pretty fast. Where you might see a slowdown is if you like to seek by holding down a key. |
Thank you very much for explaining this in a way that I was easily able to understand. Seeing as this is intended, there's no point in keeping this open. |
Reopening because I think we should change this. |
Are you thinking an IINA setting that is tied to
With Currently seeking behavior is exposed on the
Where I believe this setting is only applied when using the mouse scroll wheel to seek. |
I think seeking by 5 seconds should do exactly that, rather than something tied to keyframes. Users should not have to understand how this works under the hood. |
Based on past issues we also have users that really want fast seeking. We could change the ← and → key bindings to |
Absolutely agree. Many users seem to expect exact seeks by default and don't want to hear about the complexities of the keyframe problem or the correct mpv syntax. Would also be amazing if |
My understanding is that keyframe interval is not guaranteed to be fixed though, if the encoder chooses it can vary (e.g. for not-changing sections you will have fewer keyframes in a given duration of time). Moreover unless demux cache is enabled I think you won't even know beforehand if the region you are seeking into contains a close-enough keyframe or not. |
The case .auto:
// for each file , try use exact and record interval first
if !triedUsingExactSeekForCurrentFile {
mpv.recordedSeekTimeListener = { [unowned self] interval in
// if seek time < 0.05, then can use exact
self.useExactSeekForCurrentFile = interval < 0.05
}
mpv.needRecordSeekTime = true
triedUsingExactSeekForCurrentFile = true
} If I am understanding this code correctly it is a heuristic that bases its decision on the time taken by a single exact seek. The trouble with this is that the time taken for an exact seek depends upon where the position to seek to lands in relation to keyframes. If the position happens to land right on a keyframe then it is just as fast as a keyframe seek. This could happen with a video that has a large keyframe interval. And of course this heuristic may come up with a different answer the next time the video is played. |
I'm no video expert by any means, and admittedly I was just throwing out half-baked ideas to stimulate discussion. Any strategy might have to differ completely for some encodings, and might have to resort to fuzzy logic and/or collect data as it goes along in order to make a "best guess" about the which choice to make. But I made that suggestion under the impression that (if not 100% deterministically) certain assumptions could be made about whether a video has a roughly constant keyframe interval based on its codec type or info in its headers. I have seen that most videos I've played seem to have a pretty constant interval, but I realize I might have leaped a bit there? Also, I wasn't suggesting trying to guess exactly where each keyframe was in relation to each seek; just the interval itself. The goal would be such that, if the user requested a 5 second seek, they might be fine with up to 9 seconds of seek, but they wouldn't want to jump 20-30 seconds for some very keyframe-sparse video.
Yeah I thought that could be improved too. It would be better to at least sample a few seeks and average them together before making a firm conclusion. Or making a firmer conclusion based on the relative size of the delay, or some combination of collected stats. |
As mentioned by @krackers and discussed here, variable keyframe intervals is used by some codecs. Other codecs use a fixed interval. However in my opinion we should not put any work into an improved heuristic. Even a semi-reliable heuristic would still be confusing to users. We should focus on the point of view of the user as expressed by @saagarjha. They expect a seek of X seconds to seek X seconds. I'm still thinking we need to effectively expose the |
I agree that using exact seeks should be the default and that should be the near-term focus. Did not mean to distract from that. |
We definitely can consider improving the heuristic, we just need to first figure out exactly how we are switching to using |
Do you have links to people who have asked for fast seeks in the past? Curious what their thoughts were. |
It is about performance when scrubbing. Scrubbing through a 4k AV1 video (no hardware decode) on my MacBookPro18,2 with the M1 Max chip by holding down the → key is fairly fast and responsive. If I enable exact seeking by setting There have been two changes that slowed down seeking and resulted in users complaining about seeking speed. One was a change to stop running the display link while playback was paused. The time to restart the display link was enough of a slow up to generate complaints. The other had to do with time to stop and start AirPods. Issues #3422 and #4153 are examples of such issues. There is also issue #4215. That has to do with scrubbing backwards using exact seeks. To speed up that requires tuning |
I found that even changing it to "seek 5 exact" is of no avail |
That is expected to work, but does not due to the problem discussed in issue #3710. A fix for #3710 has been merged to the development version of IINA and will be included in the next release of IINA. As a workaround, follow the instructions at the bottom of this comment from above to set |
This might honestly be the weirdest issue I've ever come across, but if you try to use the right and/or left arrow keys to seek 5 seconds, they don't actually seek 5 seconds. Sometimes they seek 5, but sometimes they seek like 7 or 8, and I've even had up to 12 once.
System and IINA version:
MacBook Air M1
Expected behavior:
It should go back exactly 5 seconds.
Actual behavior:
Crash report:
mpv log:
Steps to reproduce:
Try and find a video and press the right or left arrow keys to go forward or back by 5 secs. It won't go back by exactly 5 secs.
How often does this happen?
A lot of the time.
The text was updated successfully, but these errors were encountered: