mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(producer): a render no longer ends early on a frame it cannot read Frame-sequence encodes pass -xerror so an unreadable frame fails the encode at that frame with the OS error, instead of ffmpeg ending the video there and exiting 0. macOS keeps render scratch in the system temp folder, as Windows does, so a synced project folder never sees the captured frames. * fix(producer): a render refuses to publish a video smaller than it asked for The final output check compares the encoded width and height with the requested size. A non-native --resolution with HDR footage is refused before calibration launches Chrome, and the refusal names --sdr or the project size. * fix(engine): a frame read failure reports the OS error on every platform ffmpeg prints the unreadable file and the OS reason on separate lines; on Windows the file line comes first, so reporting only the first match dropped the reason. * test(engine): stream start offset fixture cleanup gets the 30 s budget Its afterAll removed the fixture media within vitest's 10 s default and timed out on a Windows runner after all 16 tests passed. Real-ffmpeg fixture cleanup gets 30 s everywhere else (#5368).
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { getFfmpegBinary } from "../utils/ffmpegBinaries.js";
|
|
import { encodeFramesChunkedConcat, encodeFramesFromDir } from "./chunkEncoder.js";
|
|
import type { EncoderOptions } from "./chunkEncoder.types.js";
|
|
|
|
const HAS_FFMPEG = spawnSync(getFfmpegBinary(), ["-version"], { encoding: "utf-8" }).status === 0;
|
|
|
|
const options: EncoderOptions = {
|
|
fps: { num: 25, den: 1 },
|
|
width: 32,
|
|
height: 32,
|
|
codec: "h264",
|
|
preset: "ultrafast",
|
|
quality: 30,
|
|
};
|
|
|
|
describe.skipIf(!HAS_FFMPEG)("frame-sequence encode with an unreadable frame", () => {
|
|
let framesDir: string;
|
|
|
|
// A directory under a frame's name: ffmpeg sees it in the sequence but cannot read it, for any user.
|
|
function writeFrames(count: number, unreadable: number): void {
|
|
const result = spawnSync(getFfmpegBinary(), [
|
|
"-v",
|
|
"error",
|
|
"-f",
|
|
"lavfi",
|
|
"-i",
|
|
"testsrc2=size=32x32:rate=25",
|
|
"-frames:v",
|
|
String(count),
|
|
"-start_number",
|
|
"0",
|
|
join(framesDir, "frame_%06d.jpg"),
|
|
]);
|
|
expect(result.status).toBe(0);
|
|
const name = `frame_${String(unreadable).padStart(6, "0")}.jpg`;
|
|
rmSync(join(framesDir, name));
|
|
mkdirSync(join(framesDir, name));
|
|
}
|
|
|
|
beforeEach(() => {
|
|
framesDir = mkdtempSync(join(tmpdir(), "hf-unreadable-frame-"));
|
|
});
|
|
|
|
afterEach(() => {
|
|
rmSync(framesDir, { recursive: true, force: true });
|
|
});
|
|
|
|
it("fails at that frame instead of encoding a shorter video", async () => {
|
|
writeFrames(20, 10);
|
|
|
|
const result = await encodeFramesFromDir(
|
|
framesDir,
|
|
"frame_%06d.jpg",
|
|
join(framesDir, "out", "video.mp4"),
|
|
options,
|
|
);
|
|
|
|
expect(result.success).toBe(false);
|
|
expect(result.error).toContain("frame_000010.jpg");
|
|
expect(result.error).toMatch(/Error during demuxing: \S/);
|
|
});
|
|
|
|
it("fails a chunked encode at that frame too", async () => {
|
|
writeFrames(40, 15);
|
|
|
|
const result = await encodeFramesChunkedConcat(
|
|
framesDir,
|
|
"frame_%06d.jpg",
|
|
join(framesDir, "out", "video.mp4"),
|
|
options,
|
|
30,
|
|
);
|
|
|
|
expect(result.success).toBe(false);
|
|
expect(result.error).toContain("frame_000015.jpg");
|
|
expect(result.error).toMatch(/Error during demuxing: \S/);
|
|
});
|
|
});
|