# mpv configuration file

ontop
osd-fractions
msg-color
#save-position-on-quit

vo=gpu-next
gpu-api=vulkan

jack-port="ardour:Default/audio_in (1|2)"

dither-depth=auto
linear-downscaling
sigmoid-upscaling
correct-downscaling
scale=ewa_lanczos
dscale=mitchell
cscale=sinc
cscale-window=blackman
cscale-radius=3

# deband
deband=no
deband-iterations=2
deband-threshold=32
deband-range=18
deband-grain=24

deinterlace=no

msg-module

ytdl-format=((bestvideo[vcodec^=av01][height>=720]/bestvideo[vcodec^=vp9]/bestvideo)[height<=?1080])+(bestaudio[ext=opus]/bestaudio)/bestvideo+bestaudio/best
ytdl-raw-options=no-cache-dir=
x11-bypass-compositor=yes
fullscreen=yes
#video-sync=display-resample
#opengl-early-flush=yes

#interpolation
#tscale=oversample
#scale=lanczos

#icc-profile-auto

prefetch-playlist=yes

# Shaders
# if only my computer wasn't a potato
# glsl-shader=~~home/shaders/FSRCNNX_x2_16-0-4-1.glsl
# glsl-shader=~~home/shaders/KrigBilateral.glsl

reset-on-next-file=deband


###############
# Screenshots #
###############

screenshot-format=webp
screenshot-template="%{?demuxer-via-network==yes:${media-title}%{!demuxer-via-network==yes:${filename/no-ext} (%P) %n"
screenshot-directory="~/Pictures/mpv"
screenshot-jpeg-quality=95
screenshot-webp-quality=95
screenshot-png-compression=9


#########
# Cache #
#########

cache=yes
demuxer-max-bytes=2500MiB
demuxer-max-back-bytes=800MiB
demuxer-readahead-secs=20


#############
# OSD / OSC #
#############

osd-level=1                             # enable osd and display --osd-status-msg on interaction
osd-duration=2500                       # hide the osd after x ms
osd-msg3="${!speed==1.00:[x${speed}] }${playback-time}${?seekable==yes: / ${duration} [${playtime-remaining} (${percent-pos}%)]} ${!estimated-frame-number==0:(${estimated-frame-number}) }[${=demuxer-cache-duration}]${?frame-drop-count:${!frame-drop-count==0: Dropped: ${frame-drop-count}}}\n${?chapter-metadata/title:Chapter: ${chapter-metadata/title}}"

osd-font='Sans Serif'
osd-font-size=32
osd-color='#CCFFFFFF'                   # ARGB format
osd-border-color='#DD322640'            # ARGB format
#osd-shadow-offset=1                    # pixel width for osd text and progress bar
osd-bar-align-y=0                       # progress bar y alignment (-1 top, 0 centered, 1 bottom)
osd-border-size=2                       # size for osd text and progress bar
osd-bar-h=2                             # height of osd bar as a fractional percentage of your screen height
osd-bar-w=60                            # width of " " "

########
# Subs #
########

sub-auto=fuzzy
demuxer-mkv-subtitle-preroll  # try to correctly show embedded subs when seeking
demuxer-mkv-subtitle-preroll-secs=15
embeddedfonts=yes
sub-ass-vsfilter-blur-compat=no
sub-ass-vsfilter-aspect-compat=no
sub-fix-timing=no  # note: applies to ass subs when sub-ass-override != no
sub-gray=yes
sub-gauss=0.7
#blend-subtitles=yes  # useful when using an icc profile to match the colors of the video (or interpolation but...)

sub-ass-override=yes
sub-ass-force-style=Kerning=yes


# the following options only apply to subtitles without own styling (i.e. not ASS but e.g. SRT)
sub-font="Gandhi Sans"
sub-font-size=50
sub-color="#FFFFFFFF"
sub-border-color="#FF262626"
sub-border-size=2.4
sub-shadow-offset=1
sub-shadow-color="#33000000"

#############
# Languages #
#############

slang=enm,en,eng,fr,fra,fre   # automatically select these subtitles (decreasing priority)
alang=ja,jp,jpn,en,eng,fr,fra,fre  # automatically select these
                                   # audio tracks (decreasing priority)

#########
# Audio #
#########

volume-max=200
audio-pitch-correction=yes  # automatically insert scaletempo
                            # when playing with higher speed


############
# Profiles #
############

[bad_source]
glsl-shaders-remove=~~home/shaders/noise_static_luma.hook.glsl  # might get applied several times otherwise
glsl-shader=~~home/shaders/noise_static_luma.hook.glsl
deband=yes

[subsplz]
profile-cond=(string.match(get("filename", ""), "SubsPlease")~=nil)
profile-restore=copy
# PlayResY=360
sub-ass-force-style=FontName=Gandhi Sans,Default.FontSize=25,Top.FontSize=25,MarginL=40,MarginR=40,Default.MarginV=18,Top.MarginV=18,Outline=1.2,Shadow=0.5,Bold=1,Kerning=yes

[erai]
profile-cond=(string.match(get("filename", ""), "Erai-Raws")~=nil)
profile-restore=copy
# PlayResY=720
sub-ass-force-style=FontName=Gandhi Sans,FontSize=50,MarginL=80,MarginR=80,MarginV=36,Outline=2.4,Shadow=1.0,Bold=1,Kerning=yes


[hs_etc]
profile-desc="hs and co"
profile-restore=copy
profile-cond=(string.match(get("filename", ""), "HorribleSubs")~=nil) or (string.match(get("filename", ""), "Erai-raws")~=nil) or (string.match(get("filename", ""), "SubsPlease")~=nil)
profile=bad_source

[yt]
profile-desc="youtube and other trash"
profile-cond=(string.match(get("path", ""), "^https://youtu.be")~=nil) or (string.match(get("path", ""), "^https://.*youtube.com")~=nil) or (string.match(get("path", ""), "bilibili.com")~=nil)
rebase-start-time=no
# save-position-on-quit=yes

[yuyuko]
profile-desc="yuyuko"
profile-cond=(string.match(get("path", ""), "yuyuko.butaishoujo.moe")~=nil) or (string.match(get("path", ""), "fubuki.aidoru.agency")~=nil)
profile-restore=copy
screenshot-template="%F (%P) %n"

[vs]
profile-desc="png screenshots with vs"
profile-restore=copy
profile-cond=p.filename=="-"  # most likely playing with vapoursynth
screenshot-format=png
screenshot-directory="~/Pictures/vs"
screenshot-template="%ts"
scale=nearest
cscale=nearest
dscale=nearest

[syncplay]
rebase-start-time=no
x11-name=syncplay-mpv
resume-playback=no

[high_fps]
profile-desc="high fps videos get a bilinear scaler and no deband"
profile-cond=p.estimated_vf_fps>26
profile-restore=copy
deband=no
scale=bilinear
cscale=bilinear
dscale=bilinear

[save_seekable]
profile-desc="save position when quitting seekable file"
profile-cond=seekable
save-position-on-quit=yes

[save_not_seekable]
profile-desc="don't save position when quitting non seekable file"
profile-cond=not seekable
save-position-on-quit=no

[downmix]
profile-desc="downmixing profile"
profile-cond=p["audio-params/channel-count"] > 2
ad-lavc-downmix=no
af=lavfi="pan=stereo|FL=0.5*FC+0.707*FL+0.707*BL+0.5*LFE|FR=0.5*FC+0.707*FR+0.707*BR+0.5*LFE"

[mpv_queue]
fullscreen=no
keep-open=yes
idle=yes
terminal=no
force-window=immediate

###################################
# Protocol Specific Configuration #
###################################

[extension_gif]
profile-desc="gif profile"
profile-cond=string.match(string.lower(get("path", "")), "gif$")~=nil
cache=no
no-pause
loop-file=yes

# [extension_webm]
# profile-desc="gif profile"
# profile-cond=string.match(string.lower(get("path", "")), "webm$")~=nil
# loop-file=yes
