Files
hyperframes/packages/engine/src/services/inPageEncodeEligibility.ts
T
Miguel Ángel 0bcd816d5b feat(engine): a chunk-fed encoder and the rule for which films may use it, off by default (#7029)
* feat(engine): a chunk-fed encoder and the rule for which films may use it, off by default

* test(engine): end the chunk encoder's ffprobe call with --
2026-11-02 17:53:57 +00:00

33 lines
1.1 KiB
TypeScript

export interface InPageEncodeInput {
enabled: boolean;
captureMode: "drawelement" | "screenshot" | "beginframe";
format: string;
codec: string;
hdr: boolean;
transparent: boolean;
workers: number;
hls: boolean;
videoLayer: boolean;
encoderSupported: boolean;
}
export type InPageEncodeDecision = { eligible: true } | { eligible: false; reason: string };
export function resolveInPageEncode(input: InPageEncodeInput): InPageEncodeDecision {
const blocker = (
[
[!input.enabled, "disabled"],
[input.captureMode !== "drawelement", "capture is not drawElement"],
[input.format !== "mp4", "output is not mp4"],
[input.codec !== "h264", "codec is not h264"],
[input.hdr, "hdr"],
[input.transparent, "transparent"],
[input.workers !== 1, "parallel workers"],
[input.hls, "hls"],
[input.videoLayer, "video layer passthrough"],
[!input.encoderSupported, "page encoder unsupported"],
] as const
).find(([blocked]) => blocked);
return blocker ? { eligible: false, reason: blocker[1] } : { eligible: true };
}