rocksdanister / lively

Free and open-source software that allows users to set animated desktop wallpapers and screensavers powered by WinUI 3.
https://rocksdanister.com/lively
GNU General Public License v3.0
14.93k stars 1.05k forks source link

Implement video scaler change during runtime via customise menu #2194

Closed rocksdanister closed 5 months ago

rocksdanister commented 5 months ago

Current Mpv scaler settings are as follows which is intend to resemble MediaPlayerElement.Stretch property:

WallpaperScaler.none: "video-unscaled"="yes"
WallpaperScaler.fill: "keepaspect"="no"
WallpaperScaler.uniform: "keepaspect"="yes"
WallpaperScaler.uniformFill: "panscan"="1.0"

The scaler setting is currently set globally for all wallpapers, it is better to move this setting to per wallpaper to better fit scenarios with varying monitor and video sizes.

Implementation

This will be implemented using LivelyProperties:

image

The problem I am facing is there is no option to unset properties in mpv, so switching between various setting is causing problem due to conflicts.

Another issue is since LivelyProperties copy is not updated, the new setting will not appear unless user clicks Restore default.

Documentation

--video-unscaled: Disable scaling of the video. If the window is larger than the video, black bars are added. Otherwise, the video is cropped, unless the option is set to downscale-big, in which case the video is fit to window. The video still can be influenced by the other --video-... options. This option disables the effect of --panscan.

Note that the scaler algorithm may still be used, even if the video isn't scaled. For example, this can influence chroma conversion. The video will also still be scaled in one dimension if the source uses non-square pixels (e.g. anamorphic widescreen DVDs).

This option is disabled if --keepaspect=no is used.

--panscan: Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9 video to make it fit a 4:3 display without black bands). The range controls how much of the image is cropped. May not work with all video output drivers.

This option has no effect if --video-unscaled option is used.

--keepaspect: no will always stretch the video to window size, and will disable the window manager hints that force the window aspect ratio. (Ignored in fullscreen mode.)

https://mpv.io/manual/master/#options-video-unscaled https://mpv.io/manual/master/#options-panscan https://mpv.io/manual/master/#options-keepaspect

rocksdanister commented 5 months ago

This combination seems to work:

  switch (scaler)
  {
      case WallpaperScaler.none:
          SendMessage(GetMpvCommand("set_property", "keepaspect", "yes"));
          SendMessage(GetMpvCommand("set_property", "video-unscaled", "yes"));
          break;
      case WallpaperScaler.fill:
          SendMessage(GetMpvCommand("set_property", "video-unscaled", "no"));
          SendMessage(GetMpvCommand("set_property", "keepaspect", "no"));
          break;
      case WallpaperScaler.uniform:
          SendMessage(GetMpvCommand("set_property", "panscan", "0.0"));
          SendMessage(GetMpvCommand("set_property", "video-unscaled", "no"));
          SendMessage(GetMpvCommand("set_property", "keepaspect", "yes"));
          break;
      case WallpaperScaler.uniformFill:
          SendMessage(GetMpvCommand("set_property", "video-unscaled", "no"));
          SendMessage(GetMpvCommand("set_property", "keepaspect", "yes"));
          SendMessage(GetMpvCommand("set_property", "panscan", "1.0"));
          break;
  }