Mpv: Shader on/off command

Created on 3 Apr 2020  ·  2Comments  ·  Source: mpv-player/mpv

There is any way with MPV to activate and deactivate the shader with one button?
I have another MPV player without shaders, but it is annoying to switch player all the times.
I mainly use 2 shaders, Anime4K and Ravu.

I'm doing a lua script for that, but without result. I don't understand how to detect the function for the shader.

function shader_toggle(shader_status)

    if shader_status == "shader-ON" then
        mp.set_property_number("glsl-shaders", 1)       
    else
        mp.set_property_number("glsl-shaders", 0)               
    end 

    mp.osd_message("Shader: " .. shader_status)

end

mp.add_key_binding(nil, "Shared_Toggle", shader_toggle)

With this on the input.conf

Alt+UP script-message Shared_Toggle "shader-ON"
Alt+DOWN script-message Shared_Toggle "shader-OFF"

I want this feature for 2 reasons:

  • Sometime the shader is not good for the content, and the video is better without it.
  • It would be nice to see the difference of the video with and without the shader, instantly.
question

Most helpful comment

I'm using lines like this in input.conf:

CTRL+2 change-list glsl-shaders toggle "~/.mpv/shaders/ravu-r3-rgb.hook"

This allows to switch a shader on and off.
As for your script, you can use the property glsl-shaders to check which shaders are active.

All 2 comments

I'm using lines like this in input.conf:

CTRL+2 change-list glsl-shaders toggle "~/.mpv/shaders/ravu-r3-rgb.hook"

This allows to switch a shader on and off.
As for your script, you can use the property glsl-shaders to check which shaders are active.

Thank you Argon! I didn't know it was possible with a single line in the input.conf, my script is totally useless now XD

Was this page helpful?
0 / 5 - 0 ratings

Related issues

532910 picture 532910  ·  3Comments

sant527 picture sant527  ·  4Comments

jcowgill picture jcowgill  ·  3Comments

422658476 picture 422658476  ·  3Comments

beew picture beew  ·  3Comments