Adds periodic cleanup of temporary HLS stream output directories whenever no viewers are active, alongside startup cleanup. This prevents stale segment folders from lingering after crashes or interrupted sessions and improves long-run streaming stability and memory/disk hygiene.
Adds an admin-only Debug menu action in the top bar with a live dashboard for signed-in users, root usage, active stream footprint, and subtitle cache usage per video. The payload now includes videos that still have cached data even when nobody is watching. This helps monitor stream cleanup behaviour and detect lingering cache/segment data during sequential playback sessions.
- Subtitle event cache TTL now refreshes on every access, preventing
the entire subtitle track being re-parsed every 5 minutes during
active playback. Previously, watching a film with PGS subtitles for
longer than 5 minutes would silently re-decode all subtitle frames
from scratch, causing periodic CPU spikes and visible lag.
- clearCachesForFile now deletes the corresponding .sup file from disk
when it evicts an event cache entry, instead of only clearing the
in-memory cache. Without this, one .sup file was left on disk
permanently for every unique video+subtitle-stream combination ever
watched.
- purgeSubtitleCacheDir is called once at server startup to remove any
.sup files left over from a previous run, so the on-disk footprint is
always bounded to the current session.
- clearCachesForFile now maintains separate key lists for the event and
frame caches instead of one shared list, making the intent clear and
avoiding redundant no-op lookups.
- Removed dead code clearImageSubtitleCachesForSession from
video-stream.js (defined but never called).
- Updated image-subtitles tests to match the actual render scale (0.75)
and added coverage for purgeSubtitleCacheDir and the guarantee that
subtitle caches are cleared when a session's last stream is closed.
Previously, the server rendered image subtitles but threw away all positioning
metadata, sending only the PNG buffer. The client had no way to know the
actual frame dimensions or position within the rendered canvas, so it relied
on CSS max-height constraints (which didn't scale properly for downscaled frames).
Now the server:
1. Preserves positioning metadata (left, top, width, height, canvasWidth, canvasHeight)
2. Returns frame data as an object with both the PNG buffer and metadata
3. Sends headers with the placement information
The client:
1. Reads X-Subtitle-Frame-* headers from the response
2. Calculates percentage-based positioning: (frameLeft / canvasWidth) * 100%
3. Calculates percentage-based sizing: (frameWidth / canvasWidth) * 100%
4. Applies these values to properly position and scale the image
This allows downscaled subtitle frames (rendered at 0.5 scale) to:
- Display at correct size relative to the canvas they were rendered for
- Scale properly in both normal and fullscreen modes
- Maintain proper aspect ratio and positioning
Fixes the subtitle display issue where downscaled frames appeared too small
and fell off screen edges in fullscreen mode.
Server renders image subtitles at 0.5 scale to reduce memory usage.
The previous max-height of 50% was too restrictive for the downscaled
frames to display at a readable size.
Increased max-height constraint from 50% to 70% to allow downscaled
subtitle images to upscale sufficiently while maintaining reasonable
bounds. This ensures subtitles remain visible in all playback modes
(normal and fullscreen) without dominating the screen.
The previous fix removed max-height constraints entirely to allow upscaling
of downscaled subtitle frames (rendered at 0.5 scale). However, this caused
subtitles to become excessively large, filling up to 100% of the overlay
height and falling off screen edges.
Revised approach: keep max-width and max-height constraints but increase
max-height from 35% to 50% of the overlay container. This allows server-side
downscaled frames (0.5 scale) to upscale sufficiently for visibility while
maintaining reasonable bounds that prevent overflow in both normal and
fullscreen modes.