mpvnet-player / mpv.net

🎞 mpv.net is a media player for Windows with a modern GUI.
GNU General Public License v2.0
3.45k stars 162 forks source link

Shortcut to quickly toggle background (alpha) #691

Closed mezhgano closed 3 months ago

mezhgano commented 3 months ago

Describe the problem When watching video with alpha-channel, i need a way to toggle between transparent (checkerboard) and opaque (black color) background. Is there a way to do so?

To Reproduce

  1. Open video file with alpha-channel.
  2. See transparent background (checkerboard).
  3. Wish to change background to black color quickly.
  4. Doesn't find a handy way to do so...

Expected behavior Player has a default keyboard shortcut to toggle transparent background when video has alpha. Or player has ability to set a keyboard binding to do the same as above.

Additional context I'm on latest version (7.1.1.0)

Sneakpeakcss commented 3 months ago

I can't find any video file samples that actually display tiles for transparency, but this should work:

a no-osd cycle-values background tiles color

Also, from what i remember, mpv.net doesn't create input.conf by default anymore, so you'll have to make one manually in C:\Users\%username%\AppData\Roaming\mpv.net and paste that there.

Same thing for toggling colors:

b no-osd cycle-values background-color "1/0/0/1" "0/1/0/1" "0/0/1/1" "1/0/0/0"

https://mpv.io/manual/master/#options-background

You'll have to use the 0.0-1.0 format for R/G/B/A values, because mpv.net has some issues when its parsing input.conf bindings that contain #, and overwrites every default key rather than appending.

mezhgano commented 3 months ago

Thanks for attention and help.

I already had default input.conf created, have add two new binds at the end of the file, as you mentioned.

Unfortunately this have zero effect, nothing happens then pressing a or b, also have to notice that default actions for this shortcuts also stop working (cycle aspect ratio for a and cycle border for b), so i assume new bindings is taken into account but for some reason do nothing in my case...

Uploaded a video file with the alpha channel on which I tested (17 mb): https://mega.nz/file/kk0wCCaS#mgdB0qttrvKcJY5PWZJ0-ARhS5KcSA7xLAIU8SgpoAE

Maybe it only works with videos being hardware decoded? Hmmm, i should search another video with alpha to try...

Sneakpeakcss commented 3 months ago

https://github.com/mpvnet-player/mpv.net/assets/77424331/a9f4a18c-7ff5-45a2-8ea1-12e84e5d11d3

Works fine with both hwdec enabled/disabled, so that's not it. You could try using keys that aren't assigned to anything and see if those will work, and additionally check if console doesn't show any issues. On my side i've overwritten my whole input.conf and replaced it with only:

a no-osd cycle-values background tiles color
b no-osd cycle-values background-color "1/0/0/1" "0/1/0/1" "0/0/1/1" "1/0/0/0"

and that works fine, so i'm not exactly sure what might be wrong.

mezhgano commented 3 months ago

Oh, i should have checked the console from the beginning. Strange, but it says options color and tiles are invalid...

Screenshot 2024-06-27 18-43-31 Dirt_Charge_01 mov_-_mpv net

Sneakpeakcss commented 3 months ago

Before mpv 0.38.0, this option used to accept a color value specifying the background color. This is now done by the --background-color option. Use that instead.

I forgot that the mpv.net you get from this repository uses a bit older libmpv-2.dll, and apparently there were changes to the above commands.

You can either get yourself the newest mpv-dev-x86-64 release, and replace that file in mpv.net directory, or use the old commands:

a no-osd cycle-values alpha blend-tiles blend
b no-osd cycle-values background "1/0/0/1" "0/1/0/1" "0/0/1/1" "0/0/0/0"
mezhgano commented 3 months ago

Thanks a lot, it works now. I will use old commands and just wait for new release keeping in mind that you say.