Skip to content

Commit 014e061

Browse files
jrusso1020claude
andcommitted
fix(engine): move the extraction cache to v7 so v6 VFR frames are not reused
v6 entries for VFR sources hold frames sampled by packet duration, which FFmpeg 8 freezes and FFmpeg 5.1 lags. The key is unchanged by the fix, so a warm cache served them after the upgrade. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 0f2d587 commit 014e061

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎packages/engine/src/services/extractionCache.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ function seedPartialDir(entry: { dir: string; keyHash: string }, frameContent: s
6767
}
6868

6969
describe("extractionCache constants", () => {
70-
it("exposes the v6 schema prefix", () => {
71-
expect(SCHEMA_PREFIX).toBe("hfcache-v6-");
70+
it("exposes the v7 schema prefix", () => {
71+
expect(SCHEMA_PREFIX).toBe("hfcache-v7-");
7272
});
7373

7474
it("exposes the frame filename prefix shared with the extractor", () => {
@@ -286,6 +286,19 @@ describe("lookupCacheEntry / markCacheEntryComplete", () => {
286286
expect(lookup.entry.dir).toBe(join(tmpRoot, `${SCHEMA_PREFIX}${keyHash.slice(0, 16)}`));
287287
});
288288

289+
it("does not reuse a complete v6 entry, whose VFR frames were sampled by packet duration", () => {
290+
const input = base(sourceFile);
291+
const keyHash = computeCacheKey(input);
292+
const staleV6Dir = join(tmpRoot, `hfcache-v6-${keyHash.slice(0, 16)}`);
293+
mkdirSync(staleV6Dir, { recursive: true });
294+
writeFileSync(join(staleV6Dir, "frame_00001.jpg"), "old", "utf-8");
295+
writeFileSync(join(staleV6Dir, COMPLETE_SENTINEL), "", "utf-8");
296+
297+
const lookup = lookupCacheEntry(tmpRoot, input);
298+
expect(lookup.hit).toBe(false);
299+
expect(lookup.entry.dir).toBe(join(tmpRoot, `${SCHEMA_PREFIX}${keyHash.slice(0, 16)}`));
300+
});
301+
289302
it("misses on an empty cache root", () => {
290303
const lookup = lookupCacheEntry(tmpRoot, base(sourceFile));
291304
expect(lookup.hit).toBe(false);

‎packages/engine/src/services/extractionCache.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const GC_MARKER = ".hf-last-gc";
6262
* Current schema version. Bump it whenever extraction writes different frames for the same key,
6363
* or warm entries keep serving the old frames across a deploy. Each bump's commit says why.
6464
*/
65-
export const SCHEMA_PREFIX = "hfcache-v6-";
65+
export const SCHEMA_PREFIX = "hfcache-v7-";
6666

6767
/** Truncated hex chars of SHA-256 used for the entry directory name. */
6868
const KEY_HEX_CHARS = 16;

0 commit comments

Comments
 (0)