#############
# Video #
#############

# Hardware decoding
vo=gpu
hwdec=vaapi
hwdec-codecs=all

{%@@ if wayland @@%}
gpu-context=wayland
{%@@ endif @@%}

#############
# Audio #
#############
pulse-buffer=50 # using a large buffer causes seeking issues
audio-pitch-correction=yes # automatically insert scaletempo when playing with higher speed
replaygain=track

#############
# misc #
#############

# Start ipc server
input-ipc-server=/tmp/mpvsocket

# set youtube-dl max res
{%@@ if profile == "Moria" @@%}
ytdl-format=bestvideo[height<=2160]+bestaudio/best[height<=2160]
{%@@ else @@%}
ytdl-format=bestvideo[height<=1080]+bestaudio/best[height<=1080]
{%@@ endif @@%}

# continue watching
save-position-on-quit

#############
# Languages #
#############
slang=eng,en,enUS,en-US,fi,fiFI,fi-FI           # automatically select these subtitles (decreasing priority)
alang=eng,en,enUS,en-US,fi,fiFI,fi-FI      		# automatically select these audio tracks (decreasing priority)
ytdl-raw-options=sub-lang="en,eng,enUS,en-US,fi,fiFI,fi-FI"

#############
# Subtitles #
#############
no-sub 											# subtitles off on startup
demuxer-mkv-subtitle-preroll                    # try to correctly show embedded subs when seeking
sub-auto=fuzzy                                  # external subs don't have to match the file name exactly to autoload
sub-file-paths=ass:srt:sub:subs:subtitles       # search for external subs in the listed subdirectories
embeddedfonts=yes                               # use embedded fonts for SSA/ASS subs
sub-ass-force-style=Kerning=yes                 # allows you to override style parameters of ASS scripts

# the following options only apply to subtitles without own styling (i.e. not ASS but e.g. SRT)
sub-font="Overpass"
sub-font-size=45
sub-color="#FFFFFFFF"
sub-border-color="#FF262626"
sub-border-size=3.2
sub-shadow-offset=1
sub-shadow-color="#33000000"
sub-spacing=0.5

# OSD customizations
osd-font="Lucida Console"
osd-font-size=30
osd-color="#ffffffff"                   # ARGB format
osd-border-color="#ff151515"            # ARGB format
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-shadow-offset=1                     # pixel width for osd text and progress bar
osd-bar-w=60                            # width of " " "
osd-shadow-color="#11000000"
osd-fractions

# Protocol specific configuration
[protocol.https]
cache=yes
user-agent='Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0'

[protocol.http]
cache=yes
user-agent='Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0'

# Some settings for gifs
[extension.gif]
cache=no
no-pause
loop-file=yes

[extension.gifv]
cache=no
no-pause
loop-file=yes

# Profiles for different qualities
[360p]
ytdl-format="bestvideo[height<=360]+bestaudio/best[height<=360]"
[480p]
ytdl-format="bestvideo[height<=480]+bestaudio/best[height<=480]"
[720p]
ytdl-format="bestvideo[height<=720]+bestaudio/best[height<=720]"
[4k]
ytdl-format="bestvideo[height<=2160]+bestaudio/best[height<=2160]"
[best]
ytdl-format="bestvideo+bestaudio"

script-opts-append=ytdl_hook-ytdl_path=yt-dlp
