#########
# Cache #
#########
demuxer-max-bytes=1GiB
demuxer-max-back-bytes=200MiB

###########
# GPU API #
###########
gpu-api=vulkan  # Preferred on all systems now

##########
# Player #
##########
hr-seek-framedrop=no
no-resume-playback
# border=no  # Recommended for ModernX OSC, but not on macOS where title bar fades and has superiour native controls
msg-color=yes
msg-module=yes

###########
# General #
###########
cursor-autohide=100  # Cursor hide in ms

###############
# Screenshots #
###############
screenshot-template="%X{.}/Screens/Screenshot-%F-T%wH.%wM.%wS.%wT-F%{estimated-frame-number}"  # make this relative to home dir, does this have to have backslashes on windows?
screenshot-format=png
screenshot-png-compression=4  # 0 to 10, 0 is no compression
screenshot-tag-colorspace=yes
screenshot-high-bit-depth=yes  # Same bit depth as source

###########
# OSC/OSD #
###########
osc=no						# 'no' required for MordernX OSC  # not actually needed?
osd-bar=yes  # Do not remove/comment if mpv_thumbnail_script_client_osc.lua is being used.
osd-font='Inter Tight Medium'  # Set a font for OSC
osd-font-size=30  # Set a font size
osd-color='#CCFFFFFF'  # ARGB format
osd-border-color='#DD322640'  # ARGB format
osd-bar-align-y=-1  # progress bar y alignment (-1 top, 0 centered, 1 bottom)
osd-border-size=2  # size for osd text and progress bar
osd-bar-h=1  # height of osd bar as a fractional percentage of your screen height
osd-bar-w=60  # width of " " "

########
# Subs #
########
blend-subtitles=no
sub-ass-use-video-data=all  # backward compat for vsfilter fansubs
sub-ass-scale-with-window=yes  # keep signs etc scaled with the window
sub-auto=fuzzy  # external subs don't have to match the file name exactly to autoload
sub-file-paths-append=ass
sub-file-paths-append=srt
sub-file-paths-append=sub
sub-file-paths-append=subs
sub-file-paths-append=subtitles
demuxer-mkv-subtitle-preroll=yes  # try to correctly show embedded subs when seeking
embeddedfonts=yes  # use embedded fonts for SSA/ASS subs
sub-fix-timing=no  # do not try to fix gaps (which might make it worse in some cases). Enable if there are scenebleeds.

#################
# Subs - Forced #
#################
sub-font=Open Sans SemiBold
sub-font-size=46
sub-blur=0.3
sub-border-color=0.0/0.0/0.0/0.8
sub-border-size=3.2
sub-color=0.9/0.9/0.9/1.0
sub-margin-x=100
sub-margin-y=50
sub-shadow-color=0.0/0.0/0.0/0.25
sub-shadow-offset=0

#########
# Audio #
#########
ao=coreaudio  # macOS only?
audio-stream-silence  # fix audio popping on random seek
audio-file-auto=fuzzy  # external audio doesn't has to match the file name exactly to autoload
audio-pitch-correction=yes  # automatically insert scaletempo when playing with higher speed

#############
# Languages #
#############
alang=jpn,jp,eng,en,enUS,en-US,de,ger  # Audio language priority
slang=eng,en,und,de,ger,jp,jap  # Subtitle language priority

##################
# Video Profiles #
##################
# TODO: Find a balance that doesn't lag so much
profile=high-quality  # mpv --show-profile=gpu-hq
hwdec=auto-copy  # enable hardware decoding, defaults to 'no'  # TODO: test
vo=gpu-next
gpu-context=macvk  # macOS
# gpu-context=winvk  # Windows
# gpu-context=x11vk  # Linux X11
# gpu-context=waylandvk  # Linux Wayland

# dither
dither-depth=auto

# luma upscaling
scale=ewa_lanczos4sharpest  # automatically enables anti-ringing

# luma downscaling
dscale=catmull_rom
linear-downscaling=no

# chroma upscaling and downscaling
cscale=lanczos
sigmoid-upscaling=yes

# debanding
deband=yes
deband-iterations=4
deband-threshold=20
deband-range=16
deband-grain=4

# Antiring - actually required with lanczos upscaling?
scale-antiring=0.7
dscale-antiring=0.7
cscale-antiring=0.7

# Interpolation
# TODO: Issue with delayed/mistimed frames and variable refresh rate on MBP, works OK on fixed rate external screen
# TODO: make this variable
# video-sync=display-resample
# interpolation=yes
tscale=sphinx
tscale-blur=0.6991556596428412
tscale-radius=1.05
tscale-clamp=0.0

# SDR
tone-mapping=hable
hdr-compute-peak=yes
target-prim=apple  # set to auto otherwise, since it only applies when ICC colour profile not known

############
# Playback #
############
deinterlace=no # global reset of deinterlacing to off

[default]
# apply all luma and chroma upscaling and downscaling settings
# apply motion interpolation

############################
# Protocol Specific Config #
############################

[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