perf(subsync): cache retried local embedded tracks across runs

- Add cacheEmbeddedSubtitleTrack to store non-empty individually extracted
  embedded tracks in the single-pass cache for local media
- Picker no longer skips embedded extraction just because a combined pass
  ran, so omitted and zero-event tracks get retried and evaluated
- Later auto-sync runs and picker opens reuse cached retries without
  spawning ffmpeg again
This commit is contained in:
sudacode committed 2026-11-27 17:07:15 -08:00
1 parent 69fae42110
commit ac693be359
4 files changed
+419 -4

No files matched your search

+10 -4
View File
@@ -32,6 +32,7 @@ import {
type SampledAudioWindow,
} from '../../subsync/alass-align';
import {
cacheEmbeddedSubtitleTrack,
extractAudioSpeechSpans,
extractSampledAudioWindows,
extractSinglePassRipMedia,
@@ -861,6 +862,14 @@ async function discoverAndEvaluateSubtitleCandidates(
options.fetchImpl,
);
const parsed = readAndParseSubtitleFile(extraction.path);
if (
isEmbedded &&
!isRemoteMediaPath(context.videoPath) &&
typeof track['ff-index'] === 'number' &&
parsed.events.length > 0
) {
cacheEmbeddedSubtitleTrack(context.videoPath, track['ff-index'], parsed);
}
results.push(evaluateParsedCandidate(baseMeta, parsed));
} catch {
results.push(evaluateParsedCandidate(baseMeta, null));
@@ -1661,10 +1670,7 @@ export async function openSubsyncManualPicker(
sampledAudioWindows: prepared.sampledAudioWindows,
preExtractedEmbedded: prepared.preExtractedEmbedded,
// Never stream a remote video over HTTP or full-read a local MKV during sampled fast-path just to populate the picker.
skipEmbeddedExtraction:
isRemote ||
prepared.sampledAudioWindows !== null ||
prepared.preExtractedEmbedded !== null,
skipEmbeddedExtraction: isRemote || prepared.sampledAudioWindows !== null,
fetchImpl: deps.fetchImpl,
},
);