mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.08k stars 2.88k forks source link

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

Open geextahslex opened 3 months ago

geextahslex commented 3 months ago

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

llyyr commented 3 months ago

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

Please read the manual

geextahslex commented 3 months ago

Okay I tried this and the script isn't loading

load-scripts=no
script=cycle-denoise.lua
guidocella commented 3 months ago

--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.

geextahslex commented 3 months ago

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

guidocella commented 3 months ago

You need to quote paths with spaces.

geextahslex commented 3 months ago

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"

guidocella commented 3 months ago

Use single quotes to avoid escaping \.

geextahslex commented 3 months ago

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

guidocella commented 3 months ago

Yes, that should work. Check the console log.

geextahslex commented 3 months ago

Here: input

guidocella commented 3 months ago

Update mpv.

guidocella commented 3 months ago

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
geextahslex commented 3 months ago

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