Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/producer/src/services/renderOrchestrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe("executeDiskCaptureWithAdaptiveRetry — transient Target-closed single

const writeAllFrames = (framesDir: string, totalFrames: number): void => {
for (let i = 0; i < totalFrames; i++) {
writeFileSync(join(framesDir, formatCaptureFrameName(i, "jpg")), "x");
writeFileSync(join(framesDir, formatCaptureFrameName(i, "jpg")), "captured-frame");
}
};

Expand Down Expand Up @@ -1432,7 +1432,10 @@ describe("adaptive missing-frame retry helpers", () => {
it("finds contiguous missing frame ranges from captured disk frames", () => {
const framesDir = makeFramesDir();
for (const frameIndex of [0, 1, 4]) {
writeFileSync(join(framesDir, `frame_${String(frameIndex).padStart(6, "0")}.jpg`), "x");
writeFileSync(
join(framesDir, `frame_${String(frameIndex).padStart(6, "0")}.jpg`),
"captured-frame",
);
}

expect(findMissingFrameRanges(6, framesDir, "jpg")).toEqual([
Expand All @@ -1441,6 +1444,18 @@ describe("adaptive missing-frame retry helpers", () => {
]);
});

it("retries a worker placeholder instead of accepting a truncated sequence", () => {
const framesDir = makeFramesDir();
for (let frameIndex = 0; frameIndex < 4; frameIndex++) {
writeFileSync(
join(framesDir, `frame_${String(frameIndex).padStart(6, "0")}.jpg`),
frameIndex === 2 ? "x" : "captured-frame",
);
}

expect(findMissingFrameRanges(4, framesDir, "jpg")).toEqual([{ startFrame: 2, endFrame: 3 }]);
});

it("builds retry batches that cap active workers per attempt", () => {
const batches = buildMissingFrameRetryBatches(
[
Expand Down
7 changes: 6 additions & 1 deletion packages/producer/src/services/renderOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ export function findMissingFrameRanges(

for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
const framePath = join(framesDir, formatCaptureFrameName(frameIndex, frameExt));
const missing = !existsSync(framePath);
// A capture worker can leave a zero/one-byte placeholder behind when it
// exits between creating the destination and writing the image. FFmpeg's
// image2 demuxer treats that as end-of-sequence but still exits 0, which
// used to let a truncated video be reported as successful. Real JPEG and
// PNG captures are necessarily larger than their 8-byte file signatures.
const missing = !existsSync(framePath) || statSync(framePath).size <= 8;
if (missing && rangeStart === null) {
rangeStart = frameIndex;
} else if (!missing && rangeStart !== null) {
Expand Down
Loading