diff --git a/config/mpv/input.conf b/config/mpv/input.conf index 4a8b2613..86b15504 100644 --- a/config/mpv/input.conf +++ b/config/mpv/input.conf @@ -1,5 +1,8 @@ CTRL+i vf toggle format=yuv420p,vapoursynth=~~/motioninterpolation.vpy:4:4 -CTRL+1 no-osd change-list glsl-shaders set "~~/shaders/FSRCNNX_x2_8-0-4-1.glsl"; show-text "Enabled Luma Upscaling" -CTRL+2 no-osd change-list glsl-shaders set "~~/shaders/SSimDownscaler.glsl"; show-text "Enabled Luma Downscaling" -CTRL+3 no-osd change-list glsl-shaders set "~~/shaders/KrigBilateral.glsl"; show-text "Enabled Chroma Up/Downscaling" -CTRL+0 no-osd change-list glsl-shaders clr ""; show-text "Disabled GLSL Shaders" + +CTRL+0 change-list glsl-shaders clr "" +CTRL+1 show-text "Shaders: ${glsl-shaders}" +CTRL+2 change-list glsl-shaders set "~~/shaders/FSR.glsl" +CTRL+3 change-list glsl-shaders set "~~/shaders/FSRCNNX_x2_8-0-4-1.glsl" +CTRL+4 change-list glsl-shaders set "~~/shaders/SSimDownscaler.glsl" +CTRL+5 change-list glsl-shaders set "~~/shaders/KrigBilateral.glsl" diff --git a/config/mpv/mpv.conf b/config/mpv/mpv.conf index 4f1568e1..401cf153 100644 --- a/config/mpv/mpv.conf +++ b/config/mpv/mpv.conf @@ -1,99 +1,246 @@ -# Uses GPU-accelerated video output by default. -vo=gpu -# Can cause performance problems with some GPU drivers and GPUs. -profile=gpu-hq +# MPV - mpv.conf +# classicjazz - 2022-07-02 -# ===== REMOVE THE ABOVE FOUR LINES AND RESAVE IF YOU ENCOUNTER PLAYBACK ISSUES AFTER ===== +# Details about configuring MPV for high quality video are covered here: https://freetime.mikeconnelly.com/archives/5371 +# The latest version of this file is located here: https://github.com/classicjazz/mpv-config -# Source: https://github.com/hl2guide/better-mpv-config +# All MPV options are covered here: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst +# All of my upscaling calculations assume a native 4K resolution display +# Additionally, my target displays all support HDR, so tone-mapping for SDR is not necessary -# External Sources: -# * https://raw.githubusercontent.com/classicjazz/mpv-config/master/mpv.conf +# I am slowly incorporating changes anticipating using vo=gpu-next in the future +# https://github.com/mpv-player/mpv/wiki/GPU-Next-vs-GPU -# Enables best HW decoder; turn off for software decoding -hwdec=auto +# This config file assumes that you are using a version of MPV that supports Conditional Profiles (i.e. auto-profiles.lau is no longer required). Tested with mpv v0.34.1 -border=yes # keep the window title bar +########### +# General # +########### + +# Default profile +# vo=libmpv # used for MacOS +# macos-force-dedicated-gpu=yes # comment this out for any OS other than MacOS +profile=gpu-hq # used for any other OS on modern hardware +# profile=gpu-next # for future use + +# Selected API: select either Vulkan (preferred) or OpenGL +# Note: MacOS devices are currently limited to OpenGL v4.1 (which is deprecated). For iOS/tvOS/MacOS devices, Metal v2 would be preferred but there is not currently a Metal backend. In the future, a workaround may be to use mpv + libplacebo + MoltenVK + +# OpenGL settings +# gpu-api=opengl + +# Vulkan settings +gpu-api=vulkan +vulkan-async-compute=yes +vulkan-async-transfer=yes +vulkan-queue-count=1 +vd-lavc-dr=yes + +hwdec=auto # enable best HW decoder; turn off for software decoding +reset-on-next-file=audio-delay,mute,pause,speed,sub-delay,video-aspect-override,video-pan-x,video-pan-y,video-rotate,video-zoom,volume + + +###### +# UI # +###### + +# border=no # hide the window title bar +# macos-title-bar-material=dark msg-color=yes # color log messages on terminal -term-osd-bar=yes # displays a progress bar on the terminal -cursor-autohide=1000 # autohides the cursor after 1s +term-osd-bar=yes # display a progress bar on the terminal +# no-hidpi-window-scale # used on 5K iMac to prevent scaling by OSX +force-window=immediate +cursor-autohide=1000 # autohide the curser after 1s +# geometry=3840x2160 # force 4k resolution output from on Macs, rather than using MacOS upscaling +# fullscreen = yes # start in fullscreen mode by default loop-file=yes -# Sets a custom font -osd-font='Iosevka' -# osd-font-size=55 -# osd-scale=0.5 -# Doesn't save the seekbar position on exit -save-position-on-quit=no +############ +# Playback # +############ -# Uses a large seekable RAM cache even for local input. -cache=yes -# cache-secs=300 -# Uses extra large RAM cache (needs cache=yes to make it useful). -demuxer-max-bytes=1800M -demuxer-max-back-bytes=1200M +deinterlace=no # global reset of deinterlacing to off -# Sets the profile restore method to "copy if equal" -profile-restore=copy-equal -# ===== Audio ===== +############## +# Colorspace # +############## -# Sets volume to 60%. -volume=60 - -# Normalizes audio -af-add='dynaudnorm=g=5:f=250:r=0.9:p=0.5' - -# ===== Color Space ===== +# see https://github.com/mpv-player/mpv/wiki/Video-output---shader-stage-diagram +target-prim=auto +# target-prim=bt.709 # target Rec.709 for SDR TVs +# target-prim=bt.2020 # target Rec.2020 (wide color gamut) for HDR TVs target-trc=auto gamma-auto -vf=format=colorlevels=full:colormatrix=auto +# vf=format=colorlevels=full:colormatrix=auto +vf=format=yuv420p,vapoursynth=~~/motioninterpolation.vpy:4:4 # Interpolate by default video-output-levels=full -# ===== Dithering ===== + +########## +# Dither # +########## + dither-depth=auto temporal-dither=yes +# dither=error-diffusion # preferable... mpv will fallback on fruit if compute shaders are not supported dither=fruit -# ===== Debanding ===== +############# +# Debanding # +############# + deband=yes # enabled by default deband-iterations=4 # deband steps deband-threshold=48 # deband strength deband-range=16 # deband range deband-grain=48 # dynamic grain: set to "0" if using the static grain shader -# ===== Subtitles ===== + +############# +# Subtitles # +############# + blend-subtitles=yes -# ===== Motion Interpolation ===== -# override-display-fps=60 + +######################### +# Motion Interpolation # +######################### + +override-display-fps=60 # video-sync=display-resample # interpolation=yes # tscale=oversample # smoothmotion -# ===== Anti-Ringing ===== + +################ +# Anti-Ringing # +################ + scale-antiring=0.7 # luma upscale deringing dscale-antiring=0.7 # luma downscale deringing cscale-antiring=0.7 # chroma upscale deringing -# ===== Upscaling & Processing ===== -# NOTE: glsl-shaders is a list of files -glsl-shaders-clr # Clear shaders +############################################################# +# Upscaling & Processing Based on Source Video's Resolution # +############################################################# + +# Chroma subsampling means that chroma information is encoded at lower resolution than luma +# In MPV, chroma is upscaled to luma resolution (video size) and then the converted RGB is upscaled to target resolution (screen size) +# For detailed analysis of upscaler/downscaler quality, see https://artoriuz.github.io/blog/mpv_upscaling.html + +# fbo-format=rgba16f # use with gpu-api=opengl +fbo-format=rgba16hf # use with gpu-api=vulkan +# fbo-format is not not supported in gpu-next profile + +# NOTE: I don't know why but these shaders don't make any noticable difference to me (am I blind?)... +# glsl-shaders-clr # luma upscaling # note: any FSRCNNX above FSRCNNX_x2_8-0-4-1 is not worth the additional computional overhead -glsl-shaders="~~/shaders/FSRCNNX_x2_8-0-4-1.glsl" # Set shaders list to one shader -scale=ewa_lanczos +# glsl-shaders-append="~~/shaders/FSRCNNX_x2_8-0-4-1.glsl" +# scale=ewa_lanczos # luma downscaling # note: ssimdownscaler is tuned for mitchell and downscaling=no -glsl-shaders-append="~~/shaders/SSimDownscaler.glsl" # Add shader to the list -dscale=mitchell -linear-downscaling=no +# glsl-shaders-append="~~/shaders/SSimDownscaler.glsl" +# dscale=mitchell +# linear-downscaling=no # chroma upscaling and downscaling -glsl-shaders-append="~~/shaders/KrigBilateral.glsl" -cscale=mitchell -sigmoid-upscaling=yes +# glsl-shaders-append="~~/shaders/KrigBilateral.glsl" +# cscale=mitchell # ignored with gpu-next +# sigmoid-upscaling=yes +# NOTE: FSR makes a clearly visible difference so use that +glsl-shaders-append="~~/shaders/FSR.glsl" + +############ +# Profiles # +############ + +# [4k60] # 2160p @ 60fps (3840x2160 UHDTV) +# profile-desc=4k60 +# profile-cond=((width ==3840 and height ==2160) and p["estimated-vf-fps"]>=31) +# # deband=yes # necessary to avoid blue screen with KrigBilateral.glsl +# deband=no # turn off debanding because presume wide color gamut +# interpolation=no # turn off interpolation because presume 60fps +# # UHD videos are already 4K so no luma upscaling is needed +# # UHD videos are YUV420 so chroma upscaling is still needed +# glsl-shaders-clr +# # glsl-shaders="~/.config/mpv/shaders/KrigBilateral.glsl" # enable if your hardware can support it +# interpolation=no # no motion interpolation required because 60fps is hardware ceiling +# # no deinterlacer required because progressive +# +# [4k30] # 2160p @ 24-30fps (3840x2160 UHDTV) +# profile-cond=((width ==3840 and height ==2160) and p["estimated-vf-fps"]<31) +# # deband=yes # necessary to avoid blue screen with KrigBilateral.glsl +# deband=no # turn off debanding because presume wide color gamut +# # UHD videos are already 4K so no luma upscaling is needed +# # UHD videos are YUV420 so chroma upscaling is still needed +# glsl-shaders-clr +# # glsl-shaders="~/.config/mpv/shaders/KrigBilateral.glsl" # enable if your hardware can support it +# # apply motion interpolation +# # no deinterlacer required because progressive +# +# [full-hd60] # 1080p @ 60fps (progressive ATSC) +# profile-desc=full-hd60 +# profile-cond=((width ==1920 and height ==1080) and not p["video-frame-info/interlaced"] and p["estimated-vf-fps"]>=31) +# # apply all luma and chroma upscaling and downscaling settings +# interpolation=no # no motion interpolation required because 60fps is hardware ceiling +# # no deinterlacer required because progressive +# +# [full-hd30] # 1080p @ 24-30fps (NextGen TV/ATSC 3.0, progressive Blu-ray) +# profile-desc=full-hd30 +# profile-cond=((width ==1920 and height ==1080) and not p["video-frame-info/interlaced"] and p["estimated-vf-fps"]<31) +# # apply all luma and chroma upscaling and downscaling settings +# # apply motion interpolation +# # no deinterlacer required because progressive +# +# [full-hd-interlaced] # 1080i @ 24-30fps (HDTV, interlaced Blu-rays) +# profile-desc=full-hd-interlaced +# profile-cond=((width ==1920 and height ==1080) and p["video-frame-info/interlaced"] and p["estimated-vf-fps"]<31) +# # apply all luma and chroma upscaling and downscaling settings +# # apply motion interpolation +# vf=bwdif # apply FFMPEG's bwdif deinterlacer +# +# [hd] # 720p @ 60 fps (HDTV, Blu-ray - progressive) +# profile-desc=hd +# profile-cond=(width ==1280 and height ==720) +# # apply all luma and chroma upscaling and downscaling settings +# interpolation=no # no motion interpolation required because 60fps is hardware ceiling +# # no deinterlacer required because progressive +# +# [sdtv-ntsc] # 640x480, 704x480, 720x480 @ 30fps (NTSC DVD - interlaced) +# profile-desc=sdtv-ntsc +# profile-cond=((width ==640 and height ==480) or (width ==704 and height ==480) or (width ==720 and height ==480)) +# # apply all luma and chroma upscaling and downscaling settings +# # apply motion interpolation +# vf=bwdif # apply FFMPEG's bwdif deinterlacer +# +# [sdtv-pal] # 352x576, 480x576, 544x576, 720x576 @ 30fps (PAL broadcast or DVD - interlaced) +# profile-desc=sdtv-pal +# profile-cond=((width ==352 and height ==576) or (width ==480 and height ==576) or (width ==544 and height ==576) or (width ==720 and height ==576)) +# # apply all luma and chroma upscaling and downscaling settings +# # apply motion interpolation +# vf=bwdif # apply FFMPEG's bwdif deinterlacer +# +# [default] +# +# +# ################################### +# # Protocol Specific Configuration # +# ################################### +# +# [protocol.http] +# hls-bitrate=max # use max quality for HLS streams +# cache=yes +# no-cache-pause # don't pause when the cache runs low +# +# [protocol.https] +# profile=protocol.http +# +# [protocol.ytdl] +# profile=protocol.http diff --git a/config/mpv/mpv.conf_v1 b/config/mpv/mpv.conf_v1 new file mode 100644 index 00000000..4b524cb3 --- /dev/null +++ b/config/mpv/mpv.conf_v1 @@ -0,0 +1,91 @@ +# Sources: https://github.com/hl2guide/better-mpv-config +# https://raw.githubusercontent.com/classicjazz/mpv-config/master/mpv.conf + +# Uses GPU-accelerated video output by default. +vo=gpu +# Can cause performance problems with some GPU drivers and GPUs. +profile=gpu-hq +# Enables best HW decoder; turn off for software decoding +hwdec=auto + +# UI +border=yes # keep the window title bar +msg-color=yes # color log messages on terminal +term-osd-bar=yes # displays a progress bar on the terminal +cursor-autohide=1000 # autohides the cursor after 1s +loop-file=yes +osd-font='Iosevka' +# osd-font-size=55 +# osd-scale=0.5 +save-position-on-quit=no + +# Uses a large seekable RAM cache even for local input. +cache=yes +# cache-secs=300 +# Uses extra large RAM cache (needs cache=yes to make it useful). +demuxer-max-bytes=1800M +demuxer-max-back-bytes=1200M + +# Sets the profile restore method to "copy if equal" +profile-restore=copy-equal + +# ===== Audio ===== + +# Sets volume to 60%. +volume=60 + +# Normalizes audio +af-add='dynaudnorm=g=5:f=250:r=0.9:p=0.5' + +# ===== Color Space ===== +target-trc=auto +gamma-auto +vf=format=colorlevels=full:colormatrix=auto +video-output-levels=full + +# ===== Dithering ===== +dither-depth=auto +temporal-dither=yes +dither=fruit + +# ===== Debanding ===== +deband=yes # enabled by default +deband-iterations=4 # deband steps +deband-threshold=48 # deband strength +deband-range=16 # deband range +deband-grain=48 # dynamic grain: set to "0" if using the static grain shader + +# ===== Subtitles ===== +blend-subtitles=yes + +# ===== Motion Interpolation ===== +# override-display-fps=60 +# video-sync=display-resample +# interpolation=yes +# tscale=oversample # smoothmotion + +# ===== Anti-Ringing ===== +scale-antiring=0.7 # luma upscale deringing +dscale-antiring=0.7 # luma downscale deringing +cscale-antiring=0.7 # chroma upscale deringing + +# ===== Upscaling & Processing ===== +# NOTE: glsl-shaders is a list of files +glsl-shaders-clr # Clear shaders + +# luma upscaling +# note: any FSRCNNX above FSRCNNX_x2_8-0-4-1 is not worth the additional computional overhead +# glsl-shaders="~~/shaders/FSRCNNX_x2_8-0-4-1.glsl" # Set shaders list to one shader +scale=ewa_lanczos + +# luma downscaling +# note: ssimdownscaler is tuned for mitchell and downscaling=no +# glsl-shaders-append="~~/shaders/SSimDownscaler.glsl" # Add shader to the list +dscale=mitchell +linear-downscaling=no + +# chroma upscaling and downscaling +# glsl-shaders-append="~~/shaders/KrigBilateral.glsl" +cscale=mitchell +sigmoid-upscaling=yes + diff --git a/config/mpv/shaders/filmgrain.hook b/config/mpv/shaders/filmgrain.hook deleted file mode 100644 index 2f84ec2d..00000000 --- a/config/mpv/shaders/filmgrain.hook +++ /dev/null @@ -1,40 +0,0 @@ -//!HOOK LUMA -//!BIND HOOKED -//!DESC gaussian film grain - -#define INTENSITY 0.05 - -float permute(float x) -{ - x = (34.0 * x + 1.0) * x; - return fract(x * 1.0/289.0) * 289.0; -} - -float rand(inout float state) -{ - state = permute(state); - return fract(state * 1.0/41.0); -} - -vec4 hook() -{ - vec3 m = vec3(HOOKED_pos, random) + vec3(1.0); - float state = permute(permute(m.x) + m.y) + m.z; - - const float a0 = 0.151015505647689; - const float a1 = -0.5303572634357367; - const float a2 = 1.365020122861334; - const float b0 = 0.132089632343748; - const float b1 = -0.7607324991323768; - - float p = 0.95 * rand(state) + 0.025; - float q = p - 0.5; - float r = q * q; - - float grain = q * (a2 + (a1 * r + a0) / (r*r + b1*r + b0)); - grain *= 0.255121822830526; // normalize to [-1,1) - - vec4 color = HOOKED_tex(HOOKED_pos); - color.rgb += vec3(INTENSITY * grain); - return color; -}