Add image subtitle lookahead prefetch
Image subtitle rendering now prefetches upcoming subtitle-frame buckets ahead of the current playback position to reduce visible lag when a new bitmap subtitle event starts. The shared player overlay keeps rendering behaviour unchanged for the current frame, while best-effort background requests warm the server frame cache for near-future timestamps. Lookahead defaults to 5 seconds and is bounded to 15 seconds maximum, with 0.5-second prefetch steps to keep memory and request volume predictable. The setting is wired through both authenticated and share playback paths so they stay in sync with identical behaviour. This keeps image subtitle memory usage controlled while improving subtitle responsiveness at event boundaries.
@@ -160,7 +160,7 @@
160
160
## public/shared-video-player.js
161
161
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
162
162
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
163
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, and disables the track after the first hard failure.
163
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, prefetches lookahead subtitle frames (default 5 seconds, bounded to 15 seconds max) to reduce event-boundary lag, and disables the track after the first hard failure.
164
164
- configureVideoJsBuffering(videojs, opts) - Applies the long forward-buffer settings used for file playback when VHS exposes those knobs.
165
165
- ensureVideoPlaybackUi(player, durationSeconds) - Forces file streams into VOD UI mode, normalises the reported duration, stops live-tracker state, and hides the live badge when present.
166
166
@@ -160,7 +160,7 @@160
## public/shared-video-player.js
160
## public/shared-video-player.js
161
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
161
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
162
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
162
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
163
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, and disables the track after the first hard failure.
163
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, prefetches lookahead subtitle frames (default 5 seconds, bounded to 15 seconds max) to reduce event-boundary lag, and disables the track after the first hard failure.
164
- configureVideoJsBuffering(videojs, opts) - Applies the long forward-buffer settings used for file playback when VHS exposes those knobs.
164
- configureVideoJsBuffering(videojs, opts) - Applies the long forward-buffer settings used for file playback when VHS exposes those knobs.
165
- ensureVideoPlaybackUi(player, durationSeconds) - Forces file streams into VOD UI mode, normalises the reported duration, stops live-tracker state, and hides the live badge when present.
165
- ensureVideoPlaybackUi(player, durationSeconds) - Forces file streams into VOD UI mode, normalises the reported duration, stops live-tracker state, and hides the live badge when present.
166
166
@@ -108,6 +108,7 @@ const FOLDER_GROUP_OPTIONS = [
108
108
];
109
109
const VIDEO_FORWARD_BUFFER_SECONDS = 60 * 60;
110
110
const VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED = false;
111
const IMAGE_SUBTITLE_LOOKAHEAD_SECONDS = 5;
111
112
let videoJsLoaderPromise = null;
112
113
let threePreviewModulesPromise = null;
113
114
@@ -401,6 +402,7 @@ function bindImageSubtitleOverlay (player, videojs, prefs, session, item)
401
402
402
403
return shared.bindImageSubtitleOverlay(player, videojs, prefs, session, {
403
404
savePrefs: saveUserVideoPrefs,
405
lookaheadSeconds: IMAGE_SUBTITLE_LOOKAHEAD_SECONDS,
404
406
buildFrameRequest: ({ currentTime, streamIndex, session: activeSession }) => ({
405
407
url: `/api/files/video-stream-subtitle-frame?filePath=${encodeURIComponent(item.path)}&streamIndex=${streamIndex}&timeSeconds=${encodeURIComponent(String(currentTime))}&videoWidth=${encodeURIComponent(String(activeSession.videoWidth || ''))}&videoHeight=${encodeURIComponent(String(activeSession.videoHeight || ''))}`,
406
408
headers: buildAuthHeaders(),
@@ -108,6 +108,7 @@ const FOLDER_GROUP_OPTIONS = [108
];108
];109
const VIDEO_FORWARD_BUFFER_SECONDS = 60 * 60;109
const VIDEO_FORWARD_BUFFER_SECONDS = 60 * 60;110
const VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED = false;110
const VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED = false;111
const IMAGE_SUBTITLE_LOOKAHEAD_SECONDS = 5;111
let videoJsLoaderPromise = null;112
let videoJsLoaderPromise = null;112
let threePreviewModulesPromise = null;113
let threePreviewModulesPromise = null;113
114
@@ -401,6 +402,7 @@ function bindImageSubtitleOverlay (player, videojs, prefs, session, item)401
402
402
return shared.bindImageSubtitleOverlay(player, videojs, prefs, session, {403
return shared.bindImageSubtitleOverlay(player, videojs, prefs, session, {403
savePrefs: saveUserVideoPrefs,404
savePrefs: saveUserVideoPrefs,405
lookaheadSeconds: IMAGE_SUBTITLE_LOOKAHEAD_SECONDS,404
buildFrameRequest: ({ currentTime, streamIndex, session: activeSession }) => ({406
buildFrameRequest: ({ currentTime, streamIndex, session: activeSession }) => ({405
url: `/api/files/video-stream-subtitle-frame?filePath=${encodeURIComponent(item.path)}&streamIndex=${streamIndex}&timeSeconds=${encodeURIComponent(String(currentTime))}&videoWidth=${encodeURIComponent(String(activeSession.videoWidth || ''))}&videoHeight=${encodeURIComponent(String(activeSession.videoHeight || ''))}`,407
url: `/api/files/video-stream-subtitle-frame?filePath=${encodeURIComponent(item.path)}&streamIndex=${streamIndex}&timeSeconds=${encodeURIComponent(String(currentTime))}&videoWidth=${encodeURIComponent(String(activeSession.videoWidth || ''))}&videoHeight=${encodeURIComponent(String(activeSession.videoHeight || ''))}`,406
headers: buildAuthHeaders(),408
headers: buildAuthHeaders(),