Log in

View Full Version : Video player Shaders guide (MPC-HC, mpc-BE, mpv)


Pages : 1 [2] 3 4

butterw2
3rd November 2020, 20:53
shader support in MPC video renderer (MPC-vr)
- newer open-source directshow renderer (uses dx11 by default on Win8+) vs default dx9 only EVR-CP
- good performance.
- x64 and x86 versions
- good integration with mpc-hc/be, but requires additional download + system install of .ax directshow filter (as admin).
- built-in shaders up/down scalers (catmull-rom, lanczos3, jinc2m, etc) for luma/chroma can be used instead of the video processor.
- built in HDR to SDR conversion.
- surface: 8, 10bit integer or 16 bit floating point.

You will need to restart the player for the following changes to be taken into account:
- Set the renderer in mpc > options > output.
- configure in : mpc > Play > Filters > mpc video renderer
-dx11 mode (requires shaders written with dx11 syntax, currently only supports post-resize user shaders !!!) or dx9

Pixel-shader support:
- User shaders are post-resize only.
- Shaders do not apply to the black borders in fullscreen mode, which can be beneficial (vs EVR-CP).
- dx11 compute shaders not supported.
- Modified shaders are only taken into account when you close/reopen mpc-hc !!!

butterw2
21st November 2020, 20:22
# Comic-book/Toon realtime Shaders

Transform the input video for a comic book style look. This typically involves reducing the color palette and/or enhancing edges. Black and white ink techniques such as hatching can be used.

More details and some screenshots in this thread: https://forum.doom9.org/showthread.php?p=1928755#post1928755

.hlsl (tested in mpc-hc/be) and mpv .hook will be made available at bShaders/Effects.
- bStipple.hlsl: works quite well for 720p, 480p video input (use pre-resize).

butterw2
24th November 2020, 15:34
# mpv shader hotkeys

Mpv comes with a number of predefined keyboard shortcuts. (https://github.com/mpv-player/mpv/blob/master/etc/input.conf) You can add new shorcuts and individually override pre-existing ones by creating an input.conf file.

./portable_config/input.conf :

# Display the list of active shaders:
CTRL+0 show-text "Shaders: ${glsl-shaders:}"

# Switch to a new shader chain:
CTRL+9 change-list glsl-shaders set "NoChroma.hook"

# Associate a hotkey to a shader, so it can be toggled on/off:
CTRL+1 change-list glsl-shaders toggle "./shaders/gSmooth.hook"

# Clear all Shaders (there are 2 ways to do it, with slightly different results):
CTRL+DEL change-list glsl-shaders set "" #glsl-shaders will be a table containing an empty string, same as --glsl-shaders=""
CTRL+p change-list glsl-shaders clr all; show-text "Shaders Cleared" #glsl-shaders will be an empty table, same as --glsl-shaders-clr


Switching or Disabling shaders through a hotkey can be done without restarting the player and also works in paused mode.
EDIT:! When shaders are cleared, the previous shader chain is lost (it can't be re-enabled, it has to be re-created). To avoid this the external script shaders-switch.js can be used: https://github.com/mpv-player/mpv/issues/8512 and bound to CTRL-P.
! To force modified shaders to recompile, you have to restart-mpv (https://forum.doom9.org/showthread.php?p=1994854#post1994854).

butterw2
27th November 2020, 13:39
#Shaders Folder, Paths and extensions

In mpv
- shaders can use any paths or file extension (.hook is typically used).
- because shaders can be specified at the command line:
---avoid spaces in filepaths.
---keep paths short
examples using a relative path from the program directory:
bw.hook
"shaders/shade.hook"



In Mpc-hc
mpc-hc uses ./Shaders for dx9 shaders.
The Select Shaders... Interface, (https://raw.githubusercontent.com/butterw/bShaders/master/img/mpc-hc_Select_Shaders_Menu.png) (O) Options... > Playback > Shaders shows .hlsl files in ./Shaders and its subdirs.
If you have a lot of shaders, it is useful to move the less frequently used ones to subdirs. An empty shader named
z------------------------------------------------------------------------------------.hlsl can be used as a separator.

The interface also allows to load and save Shader presets.

butterw2
4th December 2020, 20:29
# mpv Auto-Profiles
The following is an example of an automatic profile in mpv.conf based on video file properties.

The profile is triggered when profile-cond (a lua expression based on file properties) is true.
ex: profile-cond=width>=1280

in mpv.conf:

#mpv auto-profile example
[filename_wsz]
profile-desc= 4/3>>16/9 fullscreen PnS if _wsz in filename
profile-cond= string.match(filename, "_wsz")~=nil
video-zoom=0.42
fs=yes
profile-restore=copy

When a filename containing the string "_wsz" is opened, the file is automatically displayed in fullscreen with the required Pan&Scan to remove the hardcoded black bars.
Nice.:cool:

EDIT: it's also possible to create and use a custom .wsz extension associated with mpv. In which case it's even simpler:

[extension.wsz]
profile-desc= 4/3>>16/9 PnS for files with .wsz extension
video-zoom=0.42

chros
5th December 2020, 07:58
I used an auto-profile script (I think) when I played with it, but it was pretty finicky to set up more than 10 profiles based on fps, resolution, hdr, etc. But it worked in the end.
But big question is how to auto change the refresh rate of the display, displays in profiles, etc.

butterw2
5th December 2020, 14:25
Profiles are a great concept: switch between different configurations using a single configuration file.
https://mpv.io/manual/stable/#profiles

Auto-Profiles on the other hand is not something I plan to use much. You have to be careful about which profile conditions are potentially triggered for any given video.

Regarding your monitor issues: it's probably worth keeping an eye on the progress of external lua scripts and the related workaround discussions for any current limitations.

butterw2
8th December 2020, 19:08
# New Shader features in current Nightly build of Mpc-hc
mpc-hc dev 1.9.8.65 (Dec 5 2020) https://github.com/clsid2/mpc-hc/releases

New menu entry (and shortcuts) to enable/disable shaders:
- Right-click > Shaders > Enable Pre-Resize Shaders (CTRL-P)
- Right-click > Shaders > Enable Post-Resize Shaders (CTRL-ALT-P)
The menu entry is greyed out if no shaders are present in the corresponding chain.
Disabling shaders is effective immediately even if the player is paused.

The settings' state is stored in mpc.ini:
PostSizeShadersEnabled=1
PreSizeShadersEnabled=1

Multi-pass Shaders (2P):
If a shader is named xxx_pass1.hlsl, with xxx_pass2.hlsl, etc. also present in the shaders directory, the shader will appear in the Shader-list as xxx (nP), where n is the total number of passes.
The shaders' first and subsequent passes are now loaded and removed together in a single step in the "Select Shaders..." interface.

Blur Shaders added (use pre-resize for more effective blur)
- Smoothing filter: Gaussian Blur 3x3.hlsl
- Gaussian Blur (2P), separable 7x7 Gaussian Blur, different sigma values can be selected.
Use multiple instances to achieve a stronger blur.

Finally, hardware linear sampling doesn't work in mpc-hc/be, it uses nearest neighbor sampling instead (test (https://github.com/butterw/bShaders/blob/master/test_linearSampling/bSmooth_test.hlsl), not sure why).

butterw2
26th December 2020, 11:33
# Custom hotkeys, Seeking, Chapters, Playlist

Customizing hotkeys and mouse actions in mpc-hc/be: Options (O) > Player > Keys
Some of the commands are only accessible through hotkeys.
Non-default hotkey values are stored in windows registry or mpc.ini under [Commands2], the list isn't in human readable form however.
mpc-hc v1.9.8:
- Added support for using Ctrl/Alt/Shift modifiers for mouse actions
- Duplicate hotkeys are now highlighted in red (only the first action gets executed)

Default Hotkeys for seeking (Jump):
mpc-hc (O) > Player > Keys > enter: jump
- Jump (medium): Left/Right arrow
- Jump (large): Ctrl + up/down mouse Wheel
- Jump (small): none
- Jump (keyframe): Shift + Left/Right arrow. Seek to previous/next keyframe
- Jump to beginning: Home
- Stop ■: .
- Frame-step |▶: Ctrl + Left/Right arrow

O > Tweaks > set Jump distances (small, medium, large. Default values in ms: 1000, 5000, 20000)


Chapter and Playlist Navigation, mpc Menu > Navigate
by default plays files in the same folder sorted by filename, without looping.
- Next ▶▶|: Page Down. Next chapter if applicable, otherwise Next file
- Next File: CTRL + Page Down

O > Tweaks > Show Chapter Marks in seek bar
O > Player (History) > Remember Last Playlist (you can reopen last opened file by pressing play after launching mpc-hc)


vs. Mpv:
mpv has different defaults but can be made to operate similarly to mpc using a custom input.conf hotkey configuration file.
Ex: mpv default seeking is by keyframe, to implement mpc Jump large(20s): Ctrl+WHEEL_UP osd-msg seek 20 exact
remaining differences:
- next chapter and playlist-next have independent hotkeys
- mpv doesn't display a black screen on Stop

Playlists in mpv allow seamless video playback
play folder (and subfolders !) sorted by filename: mpv b:\videos
play from a plain-text playlist file: mpv --playlist=play.txt

Default playlist hotkeys (override in input.conf):
< playlist-prev # skip to previous file
> playlist-next # skip to next file
ENTER playlist-next # multiple hotkeys for the same command are possible in mpv

butterw2
29th December 2020, 10:12
# Screenshots

mpc-hc/be Source screenshot (Alt+I) Save Image...
...set the output parameters (stored in .ini/registry): jpg (ex: 96% JpegQuality) or .png (lossless), the output directory (SnapshotPath)
To take Output Screenshot (resized, with shaders and subtitles):
in fullscreen: Win+PrnScr (Win10 Screenshot, saved in Pictures\Screenshots)
Screenshot of window (to clipboard): Alt+PrnScr
...to get only the video frame, first Set View>Preset...>Minimal (1)
...(3) returns to Normal View
mpc-be (Shift+F5): Save Displayed Image (auto), ! this feature is not available in mpc-hc

Given that Directshow doesn't guarantee frame accurate seeking, it is preferable to select a keyframe for repeatable screenshots:
-Shift+Left/Right: Prev/Next keyframe
-Ctrl-G: Go to time/frame

---
mpv
start time, paused > mpv --start=01:00:47.102 --pause

Output screenshot (Ctrl-s)
-s: output screenshot, but with same resolution as the source file
(mpv manual) "by default: Files named mpv-shotNNNN.jpg will be saved in the working directory, using the first available number - no files will be overwritten."

The default screenshot settings can be set in mpv.conf, ex:
screenshot-format=png
screenshot-jpeg-quality=96

butterw2
9th January 2021, 10:54
# Comparison of video player features (Win10)

- mpc-hc/be are Windows Directshow based players whereas mpv and vlc are cross-platform players.
- All are open-source, are actively developed and come with all the required codecs for playing audio/video files (with support for hardware acceleration).
- All have portable versions and an optional installer.
- All have configurable hotkeys (incl. mouse).
- the default build for vlc on windows is still 32bit (a 64bit build with the same features is of course available).
- mpv doesn't have a GUI by default (beyond its window and libass based OSD). It uses configuration files and hotkeys (and optionally a console output). Every option can also be set from command-line. For those who do want a GUI, some mpv-based players are available.
- mpv.net offers a fully user-customizable right-click menu.
- A context menu can be added to mpv v0.37 with mpv-menu-plugin
- base mpv doesn't support single-instance mode !!! mpv.net does.
- mpv is built on top of ffmpeg and can use ffmpeg filters on its input. I needed --hwdec= d3d11va-copy or dxva2-copy for this to work.
- mpc-hc/be and mpv can open .avs scripts. If the script has an error, Mpv displays the Avisynth exception in the console.
- mpc-hc doesn't do HDR2SDR tonemapping by default.
- vlc doesn't support user pixel shaders with it's default dx11 video output. It does have built-in video filters (ex: FilmGrain) configurable through a multi-tab GUI.
- mpv has the most complete user shader support: YUV pre-scale and RGB, a working hardware linear sampling mode, embedded textures and compute shaders. vo=gpu-next adds shader parameters.
- mpc-hc and mpv have shader presets (multiple user configurable shader chains).
- mpc-hc shaders auto-update when their source file is modified. In mpv, you need to restart the player (but this can be done with a hotkey)
- vlc has built-in audio filters (equalizer, compressor, etc.) with sliders.

pirlouy
9th January 2021, 13:49
Eheh, dangerous to compare features between players. It would need a specific thread, and there would be blood in this thread. :p
Some will say players are missing in your list. Some will say it is biased.

One example: For me, mpv (the player I use) has a GUI: In OSD, there's not only seekbar, but some useful buttons like cycling subtitles/audio. But indeed, no contextual or main menu. You have to bind commands in a file with hotkeys.

Sometimes, features are specific to someone. For example, in madVR, screen resolution can be changed according to fps, whereas it's not possible in mpv. So I launch some files with MPC then close and open them with mpv.

But anyway, now that you made your comparison, I'm curious, what's your preferred player ?

stax76
9th January 2021, 15:40
There are GUI frontends like mpv.net and GUI scripts like uosc.

https://github.com/stax76/mpv.net

https://github.com/darsain/uosc

https://github.com/mpv-player/mpv/wiki/Applications-using-mpv

butterw2
9th January 2021, 16:36
As pirlouy points out a full feature comparison of every available player would be quite the ambitious undertaking, and beyond the scope of this shader thread.
If there are any mistakes in my post I'm certainly happy to correct them. But I will only comment on the players and the limited feature set I use.
There are a number of decent players available and I would simply recommend using at least two and selecting the one best suited for each task.

#the mpv GUI
From the mpv manual: "mpv has no official GUI, other than the OSC (ON SCREEN CONTROLLER), which is not a full GUI and is not meant to be."
For those who don't want a GUI, mpv is certainly a good candidate (the OSC can be disabled with --no-osc). For those who expect a GUI, there are multiple frontend options to choose from (such as mpv.net) and also some OSC.lua replacements (ex: https://github.com/maoiscat/mpv-osc-morden maybe with --no-border).
And contrary to mpv, mpv.net has a config GUI and does support by default: single instance mode, play files in folder, and Stop ■ (well at least it doesn't quit like with base mpv...).

butterw2
10th January 2021, 12:58
Regarding the mpv seekbar (osc.lua): IMO the default should be to match the standard of web (html5) video players and just provide a few configuration options.
Web video players can achieve a simple uncluttered interface, which isn't typically available in desktop video players. One of the issues is that the latter have a lot more available features.
Yet providing the option for a simple beautiful interface should be a focus for modern video player development.


# Menu options
One thing I would like to see in video player UI is configurable menu options, in particular for the right-click menu. This pop-up menu can be very useful in fullscreen mode to launch commands without the need for keyboard hotkeys.

- html5 players don't use menus, but they typically do have a settings button.
- base mpv has no menus or settings interface.
- mpv.net has a right-click menu and a settings interface. !!! config file changes do require a restart of the player.
- mpc-hc/be has a window menu by default, and offers 2 different options for the pop-up menu (configured through the O > Keys interface).
The mpc-hc/be menu displays the associated hotkey next to the commands and is generally well-thought out, but it is also very cluttered and this is true also of 2 different variants of the right-click menu (all the same commands, organised differently). An option for greatly cut down right-click menu would be appreciated. It should ideally be user-customizable, just like hotkeys are configurable.

pirlouy
10th January 2021, 13:37
mpv is so fast when you launch a video it is enjoyable and you prefer not to have a GUI.

It takes time to create the file with all shortcuts (input.conf), but once done, you realize you use little functions/buttons and keyboard/mouse shortcuts are enough.
But I'm aware it's only for advanced people, and mpv.net is a good choice for those coming from classic players with lots of options (like MPC).

butterw2
27th January 2021, 16:44
# Video Player installation

What a video player installer does on Windows:
0) Copies files to the chosen application folder
1) Creates a shortcut
2) [Registry] associates itself with filetype extensions (opened by double-click)
3) [Registry] changes filetype icons
4) [Registry] changes contextual menus: folder playlist-options, per filetype Open With
5) [Registry] Sets-up default settings
6) Creates an uninstaller !

This seemingly convenient automatic one-click solution has its pitfalls.

Custom manual portable installs are preferable in many cases.

Some info/advice:
- Install to folders were you and the program will have write permission (also for shaders subfolder). ! This isn't the case for c:\Program Files by default.
- a simpler/shorter path is preferable. Spaces can be troublesome for command-line.
- Changing your default video and audio players is OK, but changing per filetype associations can be troublesome (in particular icons per filetype).
- Use portable install for your non-default players, this allows using many different video player versions.
- Each portable install should be in its own folder. To test a development build, it's typically enough to copy the exe to an existing install folder (rename the .exe to switch between versions).
- Why register every possible audio, video extension that ever existed ?
- SendTo contextual menu is easy to configure (find sendTo folder location by running shell:sendTo, then copy/delete shortcuts in folder).
- ! Avoid changing installation paths
- Using Registry all player versions will use the same settings.
- Saving settings to .ini rather than registry makes it easier to backup, compare, modify, substitute (ex: reset to default) configurations
- You can replace the default shortcut icon for a player easily (but not the application window icon which would require hacking the exe).
- Shortcut properties can be edited to specify startup options or startup folder
- The default icon used for filetypes associated with a program can be changed in the registry.

butterw2
7th February 2021, 18:29
# Color mapping with Shaders
input pixel (typ. RGB) >>color transformation, out=f(in) >> RGB output pixel

- Color Controls for basic adjustments (Brightness, Contrast, Hue, Saturation), Gamma.
- Color Filters: Saturated rgb, Nightvision, Color Temperature, Tint, etc.
- Color to Black&White transformation (using a custom LumaCoef)
- Luma/Chroma Contrast curve without clipping (ex: SweetFx.Curves)
- ToneMapping

mpv additionally allows embedded textures in shaders, which can be used for fast LUT (Look-Up Table) transformations
ex: CLut(Vivid, Old Photo) or gr.Lut (Sepia), simple 1D LUT with linear interpolation: 256 rgba values hex-encoded
Applying the LUT requires just 1 texture tap for gr.LUT, and 3 texture taps for CLUT
EDIT: A better approach for Color Luts is to use 3D textures with 3D linear interpolation (also supported by mpv shaders)
In this case applying a CLut requires just 1 instruction (with one 3D-interpolated texture tap).
- ! texture format must be supported by the gpu driver, which can be an issue cross-platform for floating point formats (vs lightweight rgba8 texture format which is simple to encode and widely supported)
- Luts come in different formats and sizes (typ. from 4^3=64 to 64^3 colors). Filesize reaches 2MB for a clut-64, so using clut-36 for shaders would be more reasonable. clut-4 might be usable in some cases.
Many awesome free luts are available on the internet, the main issue is the required format conversion !

To change the color-look of a video, a pack of 10 to 15 distinctive shaders would cover most use cases:
- Technicolor
- Vintage KODACHROME (1936-1962) https://frankglencairn.wordpress.com/2014/01/15/everything-looks-better-on-kodachrome-k-tone-lut/
- Old Film
- Sepia
- black&white Agfa 200X
- black&white Rollei (high-contrast)
- etc.

butterw2
9th February 2021, 00:56
# Main formats used for CLuts (Color Look-Up Table)
- Haldclut a square .png ex: level8, 512x512x24bit (or 48bit), 64^3 RGB colors.
- RGB lookup .png, (8x8 cube slices of 64x64 colors) 512x512x24bit
- .cube RGB floating point values (in text format).
- png cluts are used in photo-editing applications (ImageMagick and GMIC plugin use haldclut, XnViewMP>Film Simulation uses haldclut or RGB lookup).
- Adobe .cube format is used more in video-editing applications. One advantage seems to be that it can use values outside of the range [0, 1], but the filesize of .cube quickly becomes large with size.
- ImageMagick and GMIC can convert .cube to the Haldclut of corresponding level via command-line.
In a graphics program, the identity clut image can be used as input to capture/save the transformation clut.
When this clut is applied to an input image, the output should then match the result of the transformation. A 64x64x64 clut was enough to achieve transparency. Filesize was 200KB for png haldclut, 1MB for uncompressed rgb32, and 7MB for .cube !

ffmpeg supports haldclut and .cube (and other text-based formats) cluts.
ffplay -vf "movie=KODACHROME.png, [in] haldclut" video.mp4

Mpv can play cube format (input is converted to rgb24): ! use a relative path with / for the lut file
mpv --vf=lut3d=clut.cube video.mp4

However, this is quite cpu intensive at higher resolutions/framerates, so a shader based approach would be preferable (see previous post).

EDIT: With vo=gpu-next you can directly apply a .cube lut without having to create a shader embedding the clut:
> mpv --vo=gpu-next --target-lut=lut/clut.cube video.mp4

stax76
9th February 2021, 01:21
# Video Player installation

What a video player installer does on Windows:
0) Copies files to the chosen application folder
1) Creates a shortcut
2) [Registry] associates itself with filetype extensions (opened by double-click)
3) [Registry] changes filetype icons
4) [Registry] changes contextual menus: folder playlist-options, per filetype Open With
5) [Registry] Sets-up default settings
6) Creates an uninstaller !

This seemingly convenient automatic one-click solution has its pitfalls.

Custom manual portable installs are preferable in many cases.

Some info/advice:
- Install to folders were you and the program will have write permission (also for shaders subfolder). ! This isn't the case for c:\Program Files by default.
- a simpler/shorter path is preferable. Spaces can be troublesome for command-line.
- Changing your default video and audio players is OK, but changing per filetype associations can be troublesome (in particular icons per filetype).
- Use portable install for your non-default players, this allows using many different video player versions.
- Each portable install should be in its own folder. To test a development build, it's typically enough to copy the exe to an existing install folder (rename the .exe to switch between versions).
- Why register every possible audio, video extension that ever existed ?
- SendTo contextual menu is easy to configure (find sendTo folder location by running shell:sendTo, then copy/delete shortcuts in folder).
- ! Avoid changing installation paths
- Using Registry all player versions will use the same settings.
- Saving settings to .ini rather than registry makes it easier to backup, compare, modify, substitute (ex: reset to default) configurations
- You can replace the default shortcut icon for a player easily (but not the application window icon which would require hacking the exe).
- Shortcut properties can be edited to specify startup options or startup folder
- The default icon used for filetypes associated with a program can be changed in the registry.

Just personal taste, not everything true.

butterw2
9th February 2021, 09:32
Few things are ever true (and probably not for everyone). What are you disagreeing with specifically ?

stax76
9th February 2021, 13:37
Install to folders were you and the program will have write permission (also for shaders subfolder). ! This isn't the case for c:\Program Files by default.

If you move a folder into 'c:\Program Files', you still have full write access in the folder, and it's sub folders.

Saving settings to .ini rather than registry makes it easier to backup, compare, modify, substitute (ex: reset to default) configurations

For a mpv user using reg.exe instead of robocopy.exe isn't harder.

butterw2
9th February 2021, 15:10
I use base mpv, which makes very limited (if any) use of registry.
There is an optional install .bat registry script, which can be trimmed down significantly to just make it available as a media player/Open With and change the default icon.
Also provided is a manual program update .bat script.
Mpv uses configuration files mpv.conf and input.conf in the portable_config subfolder and doesn't save it's settings. Backing up a mpv configuration would consist in making a backup of ./portable_config and shaders.

Hacking registry is probably less of a hazard than it used to be, but for non-expert windows users remains more complex IMO than comparing/switching a single complete settings file.

stax76
9th February 2021, 15:39
May I ask why you choose base mpv over mpv.net?

butterw2
9th February 2021, 17:51
I typically launch mpv from command-line and it works very well for this use on Windows/Linux. Mpc is my main windows GUI player.

For me, an mpv GUI would have to provide 100% of base mpv + some genuinely useful additions:
- A text editor like notepad++ can handle .conf files very well (all you need to know is which parameter/values to use).
- the default OSC in mpv isn't great
- hotkeys are preferable vs cluttered menus IMO. Maybe the pop-up menu could be made user configurable (in a config file) ?
- Support in mpv.net for recent files, single-instance, files in folder, command-list are certainly of interest vs base mpv.

stax76
9th February 2021, 18:29
Maybe the pop-up menu could be made user configurable (in a config file) ?

You mean the context menu? That is defined in input.conf, all this is well documented.

butterw2
9th February 2021, 19:55
https://github.com/stax76/mpv.net
Customizable context menu defined in the same file as the key bindings (input.conf)
That's a great feature which is not currently available in mpc.

I could re-use my existing mpv.conf.
From a quick test of the 24/12/2020 beta, something seemed off with portrait mode video in windowed mode (window doesn't adjust to video dimensions ?)
mpvnet --version didn't return the expected info.

stax76
9th February 2021, 20:42
From a quick test of the 24/12/2020 beta, something seemed off with portrait mode video in windowed mode (window doesn't adjust to video dimensions ?)

There is a mpv.net specific window feature called:

minimum-aspect-ratio

<float> Minimum aspect ratio, if the AR is smaller than the defined value then the window AR is set to 16/9.
This avoids a square window for Music with cover art. Default: 1.2 (mpv.net specific setting)

Press c to show the config editor, enter mini in the search field, define 0.5 for minimum-aspect-ratio. This setting can be found in Screen section of the config editor, it is mpv.net specific, so is persisted not in mpv.conf but in mpvnet.conf.

butterw2
11th February 2021, 01:52
mpvnet.conf:
minimum-aspect-ratio = 0.5 #resize the window when the input is portrait-mode AR.
As a suggestion, why not list all the mpvnet-specific config parameter with their defaults in this file ?

--
I also got multiple popup errors when opening mpvnet (I had syntax errors in mpv.conf): I probably shouldn't get more than one of these, and the message does seem a little cryptic.
Uppercase char detected: R
mpv properties using the command line and the mpv.conf config file are required to be lowercase.

I also got these when launching from command-line: it would probably be better to just print the error and continue in this case. If I type garbage in mpv.conf, base mpv provides much clearer and more precise error info.

--
Next I'm going to copy my input.conf and maybe try to customize (meaning trim down) the context menu.

butterw2
20th February 2021, 17:46
#mpv built-in scalers

mpv has a number of built-in scalers (they can be listed with mpv --scale=help), which can be specified via command-line or mpv.conf:
--scale=catmull_rom #spline16
--cscale=bilinear
--dscale=mitchell

The scaler is used when the output resolution on screen is different from the source resolution.
- scale is used for upscaling, and also downscaling (if dscale isn't specified)
- dscale is used for downscaling
- cscale is used for chroma upsampling.

How often is scaling used ?
- cscale is almost always used (chroma upsampling) but the scaler choice is not critical.
- downscaling isn't all that common and most scalers will provide an OK result.
Upscaling is the most critical as this is a common use case (ex: upscaling 720p to view on a 1080p screen), and a sharp output is typically desired.

These settings should be OK for integrated gpus: (first: make sure --hwdec is enabled and working for the supported codecs)
Bilinear (was the default) is the fastest but doesn't give great results,
fairly lightweight: mitchell (B=1/3., C=1/3.) is smooth, catmull_rom (mitchell-netvrali with B=0, C=0.5) and spline16 are quite sharp.

gpu-hq profile used spline36 for scale, cscale and mitchell for dscale. lanczos can be used instead of spline36 if desired.
spline36 / catmull_rom / mitchell runs on a recent igpu such as intel uhd730 without issues.

Possibly overkill:
- spline64
- ewa_lanczos and ewa_lanczossharp. They use significantly more resources.
The sharpest scalers can be detrimental depending on the source, you may need to use a scale-antiring value (available in gpu-next).

! EDIT: new defaults in mpv v0.37
now (2023-11): lanczos/lanczos (implicit) / hermite (bicubic with b=0, c=0).
dither-depth=auto
hdr-compute-peak=auto
correct-downscaling=yes
linear-downscaling=yes
sigmoid-upscaling=yes
Weaker machines (ex: old laptop with integrated graphics) should use --profile=fast. Scaling is then done with bilinear by default, but this can be overriden with the scale setting.
Also try --vo=gpu-next rather than the default --vo=gpu as the new renderer has some significant performance optimizations.

Mpv doesn't have the fastest scalers (ex: performance of 1080p video upscaled to 1440p compares defavorably to other players), but by default the result is very decent.
To avoid wasting ressources on chroma, you can explicitly set cscale (ex: catmull-rom or even bilinear).
If you are using a sharp downscaler (ex: catmull-rom or lanczos), you can set --no-linear-downscaling to limit ringing.

It is possible to define hotkeys in input.conf to switch between scalers at runtime, ex:
F8 cycle-values scale bilinear mitchell catmull_rom lanczos
or to set new scalers, ex:
F9 set scale spline36 ; set dscale catmull_rom ; set cscale catmull_rom

A .jpg image file or a paused video frame can be used as input for testing. The difference are visible (especially on elements such as text) but not that huge with typical (1.5x ratio) upscaling. This applies to general purpose videos, Anime may have specific requirements.

butterw2
25th February 2021, 13:14
#Change settings/properties in mpv https://mpv.io/manual/master/#properties

1) Initial settings (determined by: program defaults < mpv.conf < command-line options incl. profile)
2) Runtime changes (via hotkey/command): current settings, disable/restore settings (via script)
3) Show settings
4) quit-watch-later: partial save of per file settings

Motivation for changing settings at runtime:
- tweak settings based on the video being displayed
- improve performance on some files (ex: on integrated graphics)
- try out effects
Runtime settings do not persist beyond the current session.

How to change settings at runtime ?
- with input.conf custom hotkey/commands or scripts
- Multiple [profiles] can be defined in mpv.conf (startup profile can be specified via command-line option).
- (Almost all ?) settings can be changed at runtime without restarting mpv through hotkey/commands (ex: switch profiles, or change a video filter/or glsl shader setting).
- Partial per file settings persistence is possible via watch-later folder: some pre-defined settings (the list is user-customizable) can be written to disk and will then be used by default the next time the same file is played.

Display pipeline: video.mp4 (ex: 720p, yuv420) > --vf (ex: hqnd3d) > color controls (ex: --saturation) > LUMA, CHROMA (ex: noChroma.hook) > cscale > rgb: MAIN (ex: clut shader kodachrome-9.hk;bw.hook) > scale > OUTPUT (ex: Filmgrain.hk) > rgba display (ex: 1080p)

Changing/displaying mpv settings at runtime with input.conf (custom hotkey/commands):
- toggle individual filters/shaders in the chain, ex: F1 change-list glsl-shaders toggle "noChroma.hk"
- set values, ex: CTRL+DEL change-list glsl-shaders set "",
- cycle between chosen values, ex: F8 cycle-values scale bilinear mitchell catmull_rom lanczos
- commands can be added via external script functions
...Scripts (lua or javascript or c-plugin) in ./scripts folder are autoloaded by default
...stats.lua and osc.lua are built-in scripts. They can be configured in ./script-opts
- Save/restore current settings (with an external script), ex: CTRL+p script-message switch-shaders (https://github.com/butterw/bShaders/tree/master/mpv/settings/scripts)
- Display current settings (show-text on OSD or print-text to the terminal, or display in the window title bar or the terminal status line)

butterw2
28th February 2021, 19:23
#Custom contextual menu in mpvnet

In mpv.net, input.conf defines the key and mouse bindings and the context menu, so it's easy to create a custom contextual menu.
The menu gives access to the recent file list, the chapters list and the open file dialog. The default menu felt a bit cluttered, so I wanted to create a more minimalistic one.
Original menu (https://files.videohelp.com/u/295418/mpvnet_default-menu.png) / my version (https://files.videohelp.com/u/295418/mpvnet_menu.jpg)

https://files.videohelp.com/u/295418/mpvnet_command-palette.png
Mpvnet has a searchable command palette component listing all available commands. This allows to keep a large number of commands available.
Unlike in mpv, runtime commands do not have to be associated to hotkeys (they can still be launched through the menu or the command-palette).

butterw2
8th March 2021, 20:00
#hqdn3d fast spatio-temporal denoiser

Most shader implementations have the limitation that only the current frame is available as input. This means temporal algorithms cannot be implemented.
This obviously isn't a problem when adapting algorithms which originate from image processing, however temporal issues do often have a big impact on the result achieved with video input (vs a fixed image).
To limit this problem, it makes sense to clean the source of temporal fluctuations as much as possible. While spatio-temporal denoising should be applied prior to encoding or to an extent by the codec itself (with modern codecs), there is frequently a benefit to apply further spatio-temporal source denoising before further processing is applied by shaders.

hqdn3d (hq mplayer spatio-temporal denoise) is a low cost cpu spatio-temporal denoiser. It is widely available, including in ffmpeg and as a result can be used in mpv.
hqdn3d(2) is equivalent to hqdn3d(ls=2, cs=1.5, lt=3, ct=2.25), the default is ls=4.0
I would recommend switching it on with lower setting on sources which require it. It runs well on 720p videos even on an old cpu.
add the following to input.conf, and turn it on with hotkey h:
h vf toggle "hqdn3d=2"

It should be noted that while temporal methods are great to remove temporal noise on backgrounds, they are not applicable to sources with fast motion.

stax76
9th March 2021, 10:48
minimum-aspect-ratio = 0.5 #resize the window when the input is portrait-mode AR.
As a suggestion, why not list all the mpvnet-specific config parameter with their defaults in this file ?

You can find mpv.net specific options in the conf editor using the search feature searching for 'mpv.net', but I also added now all mpv.net specific options to the mpv.net manual:

mpv.net specific options (https://github.com/stax76/mpv.net/blob/master/Manual.md#mpvnet-specific-options)

I also got multiple popup errors when opening mpvnet (I had syntax errors in mpv.conf): I probably shouldn't get more than one of these, and the message does seem a little cryptic.
Uppercase char detected: R
mpv properties using the command line and the mpv.conf config file are required to be lowercase.

I also got these when launching from command-line: it would probably be better to just print the error and continue in this case. If I type garbage in mpv.conf, base mpv provides much clearer and more precise error info.

I agree the mpv message on the command line is sufficient, next build has this message box warning removed.

Next I'm going to copy my input.conf and maybe try to customize (meaning trim down) the context menu.

I'm using mostly the defaults, OK it was created by me. 🙂

Thank you for the feedback.

butterw2
9th March 2021, 13:29
You can find mpv.net specific options in the conf editor using the search feature searching for 'mpv.net', but I also added now all mpv.net specific options to the mpv.net manual:

mpv.net specific options (https://github.com/stax76/mpv.net/blob/master/Manual.md#mpvnet-specific-options)

I've downloaded 5.4.8.7 Beta (2021-03-09) from dropbox, but the link was hard to find: the mpv.net manual is where to look.

mpvnet has a number of Window Limitations vs regular mpv.
some window properties are ignored, ex: --title which I use to display information in mpv. But also window-scale, etc.

--video-file-extensions=<string>
please provide example values, including how to disable picture files in auto-load-folder
mpvnet.conf:
image-file-extensions = jpg png
image-file-extensions = #disables image files
#image-file-extensions = #go back to default (all ext)

stax76
9th March 2021, 18:16
Download can be found on the front page:

https://github.com/stax76/mpv.net#table-of-contents

Not sure what else I could do.

There is an implementation for window-scale in mpv.net, but it works differently on purpose because I found the mpv behavior useless, what's the point of scaling based on the native video size? I'm not getting it but can try to implement it if people care.

--title might be something that is easy to implement.

I can try fixing both.

please provide example values, including how to disable picture files in auto-load-folder

image-file-extensions = nothing

image-file-extensions = jpg bmp

The file extensions can be separated by space, comma and semicolon.

butterw2
9th March 2021, 19:38
There is an implementation for window-scale in mpv.net, but it works differently on purpose because I found the mpv behavior useless, what's the point of scaling based on the native video size? I'm not getting it but can try to implement it if people care.


window-scale: if you have an old 4/3 360p video it may look quite ugly when scaled fullscreen.
This is the same as mpc-hc: View > zoom which has 3 main values: 50%, 100% and 200%.
100% zoom turns off scaling.
200% zoom should still look OK and is integer ratio scaling.
It's a useful feature on some files, not something meant to be used by default.

stax76
10th March 2021, 13:30
Providing a direct link to the beta (in the 1st or last post) of your forum thread would help.

I like to keep my first posts as simple as possible.

There is a new hotfix online:

- The mpv window-scale property works now exactly like in mpv.
- Implementation for the mpv title property.

https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L144

Btw. I noticed the mpv implementation of window-scale is buggy, which supports my claim that it's useless in the first place. I start mpv passing a video file to play, I set window-scale 1.0, nothing happens, very useful feature.

I try not to lament, but every second request on my issue tracker is window related, 9 out of 10 window requests are strange, I've already wasted a ridiculous amount of time working on these requests.

butterw2
10th March 2021, 15:27
I like to keep my first posts as simple as possible.

There is a new hotfix online:

- The mpv window-scale property works now exactly like in mpv.
- Implementation for the mpv title property.

https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L144

Btw. I noticed the mpv implementation of window-scale is buggy, which supports my claim that it's useless in the first place. I start mpv passing a video file to play, I set window-scale 1.0, nothing happens, very useful feature.


In mpv, window-scale isn't a useful as a startup option as it gets overriden, but I do find it useful at runtime (for low-res or extra high-res videos).
I use this in my mpv.conf (1x size window, unless the video is wider than 1280):
# window will not have a width larger than 1280pixels:
autofit-larger=1280

Window and frame size isn't all that simple:
mpc-hc for instance has many different ways to specify the window size, aspect-ratio, crop, zoom behavior... and some of these parameters are not exclusive.


The mpvnet version of window-scale is now identified differently from the mpv original, which is less confusing.

EDIT: window-scale seems to work as expected in latest hotfix mpvnet.exe

stax76
11th March 2021, 19:25
I want to improve the command palette, if you show the command palette in VS Code or Windows Terminal with Ctrl+Shift+P you see a command palette that looks much nicer than the one in mpv.net. It's going to be difficult to code, and might need migrating to .NET 5 and give up Win 7 and old Windows 10 versions, hopefully not. It's too much work to build a dedicated playlist dialog, but I can re-use the command palette infrastructure as playlist UI.

This title issue turned out to be fairly complex, I can try to get it, but need a small break first anyway, staxrip maintenance caused some stress lately.

If this thread is about shaders, better post in the other mpv thread.

butterw2
12th March 2021, 10:10
It's going to be difficult to code, and might need migrating to .NET 5 and give up Win 7 and old Windows 10 versions, hopefully not.

I run an old Win10 version, so I wouldn't be able to use it.

One of the issues with user shaders is that passing parameters to individual shaders in the chain isn't simple (the player needs to set uniforms/registers). The workaround in mpv has been to create multiple versions of each shader with different sets of parameter values. While this works, its also hard to use.
One of the benefits of having a GUI is allowing user runtime configuration of shaders (ex: turn on and increase the strength of filmgrain, because the source requires it).
The command palette interface is easy to use and allows having many commands available without a cluttered GUI.

ericgl
22nd April 2021, 10:44
Hello,
Is there a shader that can fix the colors of DolbyVision movies?
I don't have any monitors or TVs that support DolbyVision HDR.
The colors are off - Everything looks green and red.
I was hoping there's a shader that can fix that...

Upon further investigation, it seems that DolbyVision content without the EL component displays wrong/shifted colors.
In the following screenshot, you can see that this DolbyVision content only has the BL+RPU components:

https://i.ibb.co/WW8LKB0/Missing-EL-wrong-colors.png (https://ibb.co/99K7Yyh)

A user called "Doofussy2" found this issue and reported it on github: https://github.com/mpv-player/mpv/issues/7326

butterw2
22nd April 2021, 12:29
Try mpc-be which has some built-in HDRtoSDR shaders.
HDR10 and HLG should work with a recent version, but I don't know about HDR10+: You can ask the devs about this in the mpc-be thread.

Dolby vision comes up in encoding topics also.

Aleksoid1978
22nd April 2021, 13:20
There is no software player that support pure DolbyVision, except Windows 10 "Movie and TV".

ericgl
22nd April 2021, 14:06
Try mpc-be which has some built-in HDRtoSDR shaders.
HDR10 and HLG should work with a recent version, but I don't know about HDR10+: You can ask the devs about this in the mpc-be thread.

Dolby vision comes up in encoding topics also.

If you look at the screenshot, I am using MPC-BE.

@Aleksoid,
OK, I will check DolbyVision content with the "Movie and TV" app on Win10. Thanks!

Dragonkris
9th June 2021, 10:56
Hey does anyone know if there is a .hlsl shaders code for Transpose & Anti-Transpose (Flip Video) like in VLC player?

butterw2
9th June 2021, 13:34
It's often called rotate (90°) and yes most video players have this feature.

It's not typically done with user pixel shaders though, as they can't change the size/AR of the frame.

Dragonkris
11th June 2021, 01:27
Hmm so from what I’m getting at is the Pns Rotations for Y & Z were removed from MPC-BE, is there anyway to add them back in?

butterw2
11th June 2021, 10:04
A Mirror operation is trivial to achieve with shaders. The difficulty with rotate is caused by the necessary resizing of the frame (assuming W!=H).
I would expect a rotate feature to be available in a video players, but there might be bugs/limitations. You can ask your question in the mpc-be thread.
The main use case for rotate is to correct for videos captured with a tilted camera/phone (ex: mp4 rotation flag).

Acba
21st October 2021, 23:52
I would like some existing mpc-hc shaders, like "luma sharpen" or "lcd angle correction", to have effect just in the left half of a video, when the video is displayed in full screen.

Is there a way to add some lines to the beginning of the shader code so that it only acts in the left/right/top/bottom half of my screen?