user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"

glsl-shaders=""
scale=spline36                  # Fast, high-quality fallback
dither=fruit                    # Lightweight dithering

# Window & interface
ontop=no
border=no
no-border
autofit=69%                     # Reasonable default size

# Audio (macOS-specific)
volume=75
ao=coreaudio                    # Native macOS audio
audio-buffer=1.5                # More headroom for transient underruns
audio-wait-open=0.3             # Give CoreAudio a little setup time

# Subtitle defaults
sub-font="Manrope ExtraLight"
sub-font-size=45
sub-auto=fuzzy
slang=en,eng
subs-with-matching-audio=no
sub-fix-timing=yes
sub-ass-override=scale
sub-gauss=1.0
sub-gray=yes
sub-pos=90

# Networking & streaming
ytdl-format=bestvideo+bestaudio/best
ytdl-raw-options=sub-langs=en.*,write-auto-subs=
ytdl-raw-options-append=extractor-args=youtubepot-bgutilhttp:base_url=http://tubearchivist:4416
# Stats & UI colors (Catppuccin Macchiato)
background-color='#24273a'
osd-back-color='#181926'
osd-border-color='#181926'
osd-color='#cad3f5'
osd-shadow-color='#24273a'
script-opts-append=stats-border_color=30201e
script-opts-append=stats-font_color=f5d3ca
script-opts-append=stats-plot_bg_border_color=f8bdb7
script-opts-append=stats-plot_bg_color=30201e
script-opts-append=stats-plot_color=f8bdb7

##################
# Video/Graphics #
##################

vo=gpu-next
hwdec=videotoolbox              # macOS hardware decoding
hwdec-codecs=all
gpu-api=vulkan
gpu-context=macvk               # macOS-specific Vulkan context

# Vulkan optimizations (prevents crashes and memory leaks)
vulkan-queue-count=1            # FIXED: Prevents buffer overflow
vulkan-async-compute=no         # FIXED: Improves stability
vulkan-async-transfer=no        # FIXED: Reduces memory pressure
vulkan-swap-mode=fifo           # Most compatible presentation mode
fbo-format=rgba8                # FIXED: Memory-safe format

# Video filtering & quality
vd-lavc-film-grain=cpu          # FIXED: GPU grain not supported on macOS
vd-lavc-threads=0
vd-lavc-dr=yes                  # Keep frames on GPU
video-sync=audio                # Prioritize stable audio over display resample

# Scaling & interpolation
scale=spline36
dscale=mitchell
cscale=spline36
tscale=oversample
interpolation=no
interpolation-threshold=0.5
sigmoid-upscaling=yes
temporal-dither=no

# Stable default dithering
dither=fruit
dither-depth=auto
error-diffusion=sierra-lite

# Antiring
scale-antiring=0.5
dscale-antiring=0.5
cscale-antiring=0.5

# Post-processing
deband=no
deband-iterations=2
deband-threshold=24
deband-range=16
deband-grain=4

##################
# Screenshot     #
##################

screenshot-format=webp
screenshot-webp-lossless=yes
screenshot-high-bit-depth=yes
screenshot-sw=no
screenshot-directory="/Volumes/sudacode/pictures/mpv"
screenshot-template="%f-%wH.%wM.%wS.%wT-#%#00n"

##################
# Session        #
##################

save-position-on-quit
watch-later-dir="~~/.watch-later"
resume-playback=yes
save-watch-history
watch-history-path="~~/state/watch_history.jsonl"
input-ipc-server=/tmp/mpvsocket

##################
# Caching        #
##################

cache=yes
demuxer-max-bytes=512MiB
demuxer-max-back-bytes=64MiB
cache-pause=yes
cache-pause-wait=1
cache-secs=30
demuxer-readahead-secs=20

msg-level=subs2srs,animecards,mpvacious=error


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

# Base high-quality preset (inherits above settings)
[base]
profile=gpu-hq

# Anime profile (ArtCNN is memory-heavy, use cautiously)
[anime]
profile-desc="Anime upscaling with ArtCNN"
# Manually enable with --profile=anime; auto ArtCNN can cause underruns on macOS.
# profile-cond=filename:match("mkv$") and height <= 1080
glsl-shaders="~~/shaders/ArtCNN_C4F16.glsl"  # Use F16 variant (lighter)
scale=ewa_lanczossharp
deband=yes

# Movies profile (no shaders, HDR support)
[movies]
profile-desc="Movies and TV shows"
profile-cond=width >= 1920 and filename:match("mkv$|mp4$")
glsl-shaders=""
scale=ewa_lanczos
target-peak=800
# hdr-tone-mapping=bt.2390

[hdr]
profile-desc=HDR content
profile-cond=get("video-params/gamma", "") == "pq" or get("video-params/gamma", "") == "hlg"
profile-restore=copy
tone-mapping-param=0.5
tone-mapping-max-boost=2.0
allow-delayed-peak-detect=yes
# For SDR content on HDR display (or vice versa)
icc-profile-auto=yes

[sdr]
profile-desc=SDR content
profile-cond=get("video-params/gamma", "") ~= "pq" and get("video-params/gamma", "") ~= "hlg"
profile-restore=copy
# put SDR-only tweaks here
deband=no
target-colorspace-hint=auto


# SVP compatibility profile
[svp]
interpolation=no
input-ipc-server=/tmp/mpvsocket
hr-seek-framedrop=no
resume-playback=no

# Idle profile
[Idle]
profile-cond=p["idle-active"]
profile-restore=copy-equal
title=' '
keepaspect=no

# Japanese immersion profile
[subminer]
cookies=yes
cookies-file=~/Documents/youtube-cookies.txt
ytdl-raw-options=mark-watched=
ytdl-raw-options-append=write-auto-subs=
ytdl-raw-options-append=sub-langs=ja.*|en|ja-en
ytdl-raw-options-append=cookies=~/Documents/youtube-cookies.txt
ytdl-format=bestvideo+bestaudio/best
sub-auto=fuzzy
alang=ja,jp,jpn,japanese,en,eng,english,English,enUS,en-US
slang=ja,jp,jpn,japanese,en,eng,english,English,enUS,en-US
vlang=ja,jpn
subs-with-matching-audio=yes
sub-font="Hiragino Sans, M PLUS 1 Medium, Noto Sans CJK JP"
sub-font-size=46
glsl-shaders="~~/shaders/ArtCNN_C4F16.glsl"
scale=spline36
dither=fruit
deband=no
input-ipc-server=/tmp/subminer-socket

# Anime subtitles profile
[anime-subs]
profile-cond=p["slang"] == "ja" or p["slang"] == "ja.hi"
sub-font="Hiragino Sans, M PLUS 1 Medium, Noto Sans CJK JP"
sub-bold=no
sub-font-size=46
sub-color=1.0/1.0/1.0/0.98
sub-border-color=0.0/0.0/0.0/0.80
sub-border-size=1.3
sub-shadow-color=0.0/0.0/0.0/0.35
sub-shadow-offset=2
sub-back-color=0.0/0.0/0.0/0.12
sub-margin-x=24
sub-margin-y=18
sub-italic=no
sub-ass-override=strip
sub-line-spacing=0.3
sub-hinting=light
