ferreum / mpv-skipsilence

Increase playback speed during silence - a revolution in attention-deficit induction technology.

Home Page:https://codeberg.org/ferreum/mpv-skipsilence/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

don't know how to pass a message to the script

markifi opened this issue · comments

i'm trying to automatically enable skipsilence but only when playback speed is already above 1.9x
in mpv.conf:
[speed-over-190-percent-skipsilence] profile-cond=speed >= 1.9 profile-restore=copy script-message-to skipsilence enable
but when i try to pass that message it doesn't enable skipsilence.

trying the same manually
2024-06-17_01-35

2024-06-17_01-35_1

Profiles can only set options, so there's no way to send a script message with such an (ini-style) option. script-message-to has to be run as a command, like with a binding, the console, or other lua scripts. It's also not possible to combine that with the profile-restore mechanism, as that only knows about options.

mpv-skipsilence also allows enabling the script by setting a script-opts:

[auto-fast-skipsilence]
profile-cond=speed >= 1.9
# profile-restore=copy # works, except it restores all other script-opts too, like skipsilence's threshold volume
script-opts-append=skipsilence-enabled=yes

That still doesn't work so well with profile-restore, because the profile cannot keep track of separate script-opts options, so it restores everything in script-opts to the previous state, which will have unwanted side effects if you set anything else.

Without profile-restore it also only enables the script once, because that's how profiles without restore work.

Enabling and disabling

One way I know how to run commands in a profile is in profile-cond itself. Since it's a lua expression it can be utilized to run any command with mp.commandv. Here's a way that works:

[speed-over-190-percent-skipsilence]
profile-cond=false, mp.commandv("change-list", "script-opts", "append", "skipsilence-enabled=" .. (speed >= 1.9 and "yes" or "no"))

The first false is evaluated by the auto profile script, so it's never applied and keeps running for every speed update. It then updates the script option skipsilence-enabled every time.

Beware that this can cause problems: If there's an error during filter creation, it might cause the script to be toggled very frequently. It also prevents using skipsilence at lower speeds, because as soon as speed is below 1.9x it forces the script to be disabled again.

Enabling only

This may be a bit safer:

[speed-over-190-percent-skipsilence]
profile-cond=speed >= 1.9 and mp.commandv("script-message-to", "skipsilence", "enable")
profile-restore=copy

You could also add "no-osd" after "enable" to suppress the OSD message.

thank you very much for the detailed explanation. i like the dangerous option which also auto disables under 1.9