r/mpv • • 21d ago

User Scripts & Shaders [Release] mpv-http-range-cache v2.0.0 — Fully Async aiohttp + Parallel Multi-Connection HTTP Disk Cache for mpv

I built mpv-http-range-cache, a persistent HTTP 206 byte-range disk cache & cross-URL watch_later resume proxy for mpv, and just shipped v2.0.0 — an end-to-end non-blocking async pipeline from main.lua down to socket streaming and disk storage.

Why I built it

By default, mpv's demuxer cache lives in RAM and disappears as soon as you close the player or evict older chunks. Watching long or high-bitrate HTTP streams meant re-downloading previously watched parts on re-opens, rewinds, or when CDN signed links expired.

What's New in v2.0.0

  • Fully Async aiohttp Proxy & Pooled Connections (proxy.py): Persistent aiohttp.ClientSession with DNS caching and keep-alive pooling.
  • Parallel Multi-Connection Sliding-Window Downloads: Splits uncached Range gaps across 4 concurrent connections (2 MB parts by default, configurable) with zero-duplicate cold-start probe handoff.
  • Zero-Blocking Disk & Lua Paths: Cache chunk I/O, atomic metadata saves, 64 KB SHA-256 content dedup checks, LRU eviction, and watch_later sync run off the event loop via asyncio.to_thread, while main.lua uses mp.command_native_async everywhere (including detached end-file resume persistence).
  • Sparse Files + Cross-URL Resume: NTFS/POSIX sparse files (FSCTL_SET_SPARSE), clean per-video subfolders (Movie.mkv/cache.data), proxy/VPN header forwarding (http-proxy, tls-verify), and content-based deduplication so rotating links reuse both your cached bytes and save-position-on-quit timestamp.

Links

6 Upvotes

1 comment sorted by

4

u/Arbeitsloeffel 21d ago

Yes, these are definitely words.