mpv icon indicating copy to clipboard operation
mpv copied to clipboard

add option to load or don't load scripts with profile-condition

Open geextahslex opened this issue 1 year ago • 14 comments
trafficstars

Expected behavior of the wanted feature

Hi, I would like to have control over if and which scripts are loaded. Handle scripts like shaders, don't load all of them automatically at startup but let the user choose which one you need with a profile-condition, like you can do with glsl shaders. For example I don't need thumbnails for local files and vice versa, I don't need autocrop on youtube videos etc. Loading scripts with mp.command isn't reliable as often the scripts don't work at all or as expected, when they are in a different location than the default one. The way it is now it's all or nothing.

Thank you :)

Alternative behavior of the wanted feature

No response

Log File

No response

Sample Files

No response

geextahslex avatar Jul 02 '24 15:07 geextahslex

this is already possible with --load-scripts=no then explicitly load scripts with --scripts=foo.lua:bar.lua:...

Please read the manual

llyyr avatar Jul 02 '24 15:07 llyyr

Okay I tried this and the script isn't loading

load-scripts=no
script=cycle-denoise.lua

geextahslex avatar Jul 02 '24 15:07 geextahslex

--script doesn't work at runtime. This can be done with

profile-cond=foo
input-commands=load-script C:\foo\bar.lua

But this will load a new instance of the script each time the profile condition becomes truthy. So it is better to modify the script. For autocrop.lua you can just disable it with script-opts-append=autocrop-auto=no.

guidocella avatar Jul 02 '24 15:07 guidocella

I am looking for a universal solution for all scripts, not only for autocrop.

This also doesn't work input-commands=load-script C:\Program Files (x86)\MPV\portable_config\scripts\cycle-denoise.lua

geextahslex avatar Jul 02 '24 15:07 geextahslex

You need to quote paths with spaces.

guidocella avatar Jul 02 '24 16:07 guidocella

Sorry I don't know what you mean by "quote paths with spaces". You mean like this? input-commands=load-script "C:\Program Files (x86)\MPV\portable_config\scripts\cycle-denoise.lua"

geextahslex avatar Jul 02 '24 16:07 geextahslex

Use single quotes to avoid escaping \.

guidocella avatar Jul 02 '24 16:07 guidocella

like this? This still doesn't work ^^' input-commands=load-script 'C:\Program Files (x86)\MPV\portable_config\scripts\cycle-denoise.lua'

geextahslex avatar Jul 02 '24 16:07 geextahslex

Yes, that should work. Check the console log.

guidocella avatar Jul 02 '24 16:07 guidocella

Here: input

geextahslex avatar Jul 02 '24 16:07 geextahslex

Update mpv.

guidocella avatar Jul 02 '24 16:07 guidocella

This will load the script once:

[foo]
profile-cond=cond and not p['user-data/foo-loaded']
input-commands=load-script foo.lua; no-osd set user-data/foo-loaded 1

guidocella avatar Jul 02 '24 16:07 guidocella

Does someone know why autocrop isn't working here? Profile is active, I can see the hue change.

[OSC2]
profile-cond=width / height >=1.77 and width / height <2 and get("video-params/primaries") == "bt.2020" 
profile-restore=copy
hue=50
input-commands=load-script 'C:\Program Files (x86)\MPV\gucio\autocrop.lua'

no error message and profile is applied autocrop

geextahslex avatar Jul 02 '24 20:07 geextahslex

The inverse behaviour (scripts to disable rather to enable) seems to make more sense, as some scripts misbehave or cannot be loaded at runtime.

zkvsky avatar Jun 08 '25 13:06 zkvsky