8000 Keybindings for `seek exact` are silently overridden to `seek keyframes` · Issue #3710 · iina/iina · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Keybindings for seek exact are silently overridden to seek keyframes #3710

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

Closed
svobs opened this issue May 2, 2022 · 11 comments · Fixed by #4739
Closed

Keybindings for seek exact are silently overridden to seek keyframes #3710

svobs opened this issue May 2, 2022 · 11 comments 8000 · Fixed by #4739

Comments

@svobs
Copy link
Contributor
svobs commented May 2, 2022

I was playing with building IINA myself, and was tailing the MPV log, and discovered some issues with seek keybindings.

In IINA's Key Bindings config, I've got the L key bound to "seek 10 exact", and the J key bound to "seek -10 exact". But looking at the commands MPV is logging:

tail -f /Users/msvoboda/Library/Logs/com.colliderli.iina/2022-05-02-12-49-20_TLOoov/mpv.log | grep -A 1 'Run command: seek'
[ 100.964][d][cplayer] Run command: seek, flags=64, args=["-5.000000", "relative", "unused"]
[ 100.964][v][mkv] queuing seek to 15.854000
--
[ 115.514][d][cplayer] Run command: seek, flags=64, args=["5.000000", "relative", "unused"]
[ 115.514][v][mkv] queuing seek to 15.427000
--
[ 117.548][d][cplayer] Run command: seek, flags=64, args=["5.000000", "relative", "unused"]
[ 117.548][v][mkv] queuing seek to 25.854000
--
[ 119.141][d][cplayer] Run command: seek, flags=64, args=["5.000000", "relative", "unused"]
[ 119.141][v][mkv] queuing seek to 36.281000

I noticed that to some extent this is a feature: I see "Step Forward 10s" and "Step Backward 10s" with my key bindings listed in the Playback menu. But the MPV logs were not lying, and I managed to trace part of the problem to hard-coded values in MainMenuActions.swift:

  @objc func menuStep(_ sender: NSMenuItem) {
    if sender.tag == 0 { // -> 5s
      player.seek(relativeSecond: 5, option: .relative)
    } else if sender.tag == 1 { // <- 5s
      player.seek(relativeSecond: -5, option: .relative)
    }
  }

In addition, there appear to be several menu localizations which have the 5s value hard-coded. For example, MainMenu.strings (it):

/* Class = "NSMenuItem"; title = "Step Forward 5s"; ObjectID = "6yE-op-DTS"; */
"6yE-op-DTS.title" = "Avanti 5s";

I did some further testing and discovered that this override is enabled for any value I choose between 5s and 10s, and between -5s and -10s. If I set it outside of that range (e.g. "seek 15 exact", there is no override and MPV receives exactly what I specified. I haven't yet been able to find the place in the code where this override logic resides, but it needs to be changed to include the step amount and the seek option in order to honor the user's wishes.

Having the "relative" option hard-coded has doubtlessly led to user confusion, because what MPV ends up actually seeking seems to vary enormously based on the file and location inside it and can end up appearing random (the above log snippit is a good example).

This may be the underlying problem for issues #3110, #3321, #3440, #3534.
EDIT: also issues #2963, #3918, #4766.

System and IINA version:

  • macOS 12.3.1
  • IINA 1.2.0
  • also confirmed with April 28 build (d0c32125df2269621f0b6a85dabe36120a6d3f3b)
@svobs svobs changed the title Keybindings for seek are silently overwritten to 5sec relative Keybindings for seek are silently overridden to 5sec relative May 2, 2022
@low-batt
Copy link
Contributor
low-batt commented May 2, 2022

Did not reproduce for me?

Could you post the offending key binding configuration file? In Preferences / Key Bindings there is a Reveal config file in Finder button that will open the directory containing the file.

I tried the following:

  • Opened Preferences / Key Bindings
  • Duplicated the IINA Default key set
  • Added L set to seek 10 exact
  • Pressing ⇧L caused IINA to seek forward by 10s

Checking the mpv log shows:

[  13.137][d][cplayer] Run command: seek, flags=73, args=[target="10.000000", flags="exact", legacy="unused"]

Possibly this is related to issue #3692. The fix for that is in PR #3693 which is waiting to be reviewed and merged.

The hardcoding of the menu items to 5s is correct. What should happen is that if the command assigned to the key that is bound to the menu item changes, the key should not be bound as a shortcut to the menu item.

I am unsure as to whether this is the problem in issue #3692 or not. If you post the offending configuration I will give it a try and see what is going on.

@svobs
Copy link
Contributor Author
svobs commented May 2, 2022

MattMPV.conf.txt
Here's my config file (had to add the .txt extension to get past Github's filetype complaints). Let me know if you can reproduce!

@low-batt
Copy link
Contributor
low-batt commented May 2, 2022

Reproduced. Also reproduced with the fix for issue #3692.

Thanks for posting the file. I need to take a close look into what is going on. Caught me super busy. Need to clear a couple of things off my plate. Should be able to dig into this one later this week.

@svobs
Copy link
Contributor Author
svobs commented May 3, 2022

I've been doing some more digging, and I think I might be able to fix it. It looks like it will mostly involve unwinding some tangled up code in MenuController.swift.

Mind if I take a crack at it? Seems like you've got plenty on your plate already and I've love to contribute. And it might be easier just to show a diff than even try to explain it.

@low-batt
Copy link
Contributor
low-batt commented May 3, 2022

Mind if I take a crack at it?

I don't mind at all. It is yours to fix. Thanks for stepping up! Let us know if you get too busy and need to drop it.

I'm pretty sure my earlier comments on this one were wrong. I've not spent much time in this area of the code.

@sanchezelton
Copy link

@svobs
Do you have the same behavior when playing a MP4 vs a MKV? Seek was limited to 1sec back with an MKV I had, no matter what value I specified for seek.

@svobs
Copy link
Contributor Author
svobs commented May 3, 2022

@svobs Do you have the same behavior when playing a MP4 vs a MKV? Seek was limited to 1sec back with an MKV I had, no matter what value I specified for seek.

@sanchezelton I tried with a few MKVs I've got, but generally I found that the seek step was longer than requested, not shorter. This makes sense because from what I understand about the MPV engine, its default "keyframes" mode first jumps the video by the requested amount and then starts seeking forward more until it finds the nearest keyframe. And in general for more highly compressed files, the farther apart keyframes are.

What you're describing sounds more like #3692 - if you have the same key binding listed twice, it might be that one of them is getting ignored. If you can post your binding config file, I can take a look (In IINA > Preferences > Key Bindings there is a "Reveal config file in Finder" button that will open the directory containing the file).

@svobs svobs mentioned this issue May 3, 2022
@svobs
Copy link
Contributor Author
svobs commented May 4, 2022

In addition to now using the exact seek step specified , the fix adds support for users specifying "exact" (which ends up being sent to MPV as "relative+exact"), and "keyframes" (which is sent to MPV as "relative", which is fine because "keyframes" is implied). This is due to having to map to IINA's internal enums, which don't support all the possible flags such as "relative-percent" (does anyone even use that?). More work is needed in this area in order to add more support for all of MPV's possible values.

@lhc70000
Copy link
Member
lhc70000 commented May 7, 2022

In addition, there appear to be several menu localizations which have the 5s value hard-coded. For example, MainMenu.strings (it):

I just want to add that most strings in MainMenu.strings are placeholders, the actual key is here:

"menu.seek_forward" = "Step Forward %.0fs";

@low-batt low-batt linked a pull request Oct 17, 2022 that will close this issue
2 tasks
@svobs svobs changed the title Keybindings for seek are silently overridden to 5sec relative Keybindings for seek are silently overridden to 5sec keyframe Feb 18, 2023
@svobs svobs changed the title Keybindings for seek are silently overridden to 5sec keyframe Keybindings for seek exact are silently overridden to seek keyframes Feb 18, 2023
low-batt added a commit that referenced this issue Jan 1, 2024
This commit will:
- Change MenuController.sameKeyAction to detect the exact flag and pass
  it on as extra data
- Change MainMenuActionHandler.menuStep to pass the extra data to
  PlayerCore.seek if present

The main author of these changes is Matt Svoboda. I merely addressed
some review comments.

Co-authored-by: Matt Svoboda <matt.svoboda@gmail.com>
@low-batt low-batt removed a link to a pull request Jan 1, 2024
2 tasks
@low-batt low-batt linked a pull request Jan 1, 2024 that will close this issue
2 tasks
uiryuu pushed a commit that referenced this issue Jan 2, 2024
This commit will:
- Change MenuController.sameKeyAction to detect the exact flag and pass
  it on as extra data
- Change MainMenuActionHandler.menuStep to pass the extra data to
  PlayerCore.seek if present

The main author of these changes is Matt Svoboda. I merely addressed
some review comments.

Co-authored-by: Matt Svoboda <matt.svoboda@gmail.com>
@low-batt
Copy link
Contributor
low-batt commented Jan 2, 2024

The fix for this issue has been merged into the IINA develop branch. GitHub automatically closed the linked issue in reaction to the merge. I am reopening this issue until the fix is available in an official release of IINA so that users intending to report this problem can easily locate this existing report. Once the fix for this issue has been included in an official release this issue will be closed.

@low-batt
Copy link
Contributor
low-batt commented Jun 9, 2024

This was fixed in IINA 1.3.5.

@low-batt low-batt closed this as completed Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0