mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
fix(cli): the render header names the quality preset and CRF it encodes with (#7697)
The settings line printed the encoder tier, so the default render said "30fps · standard · …" while it encoded the looks preset at CRF 16, and -q delivery said "high". A long-form render that came out at ~40 Mbps read as "standard quality" in its own log. The line now prints the --quality name as asked for and the CRF or bitrate in effect: "looks (CRF 16)" by default, "looks (CRF 20)" with --crf 20, "looks (10M)" with --video-bitrate 10M, "draft", "delivery". Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
08e11cb563
commit
2f31cc14b1
@@ -131,6 +131,7 @@ export interface RenderPlan {
|
||||
renderTarget: string;
|
||||
fps: Fps;
|
||||
quality: RenderQuality;
|
||||
qualityPreset: keyof typeof QUALITY_ALIASES;
|
||||
authoringSkill?: string;
|
||||
invalidAuthoringSkill?: string;
|
||||
/** Which resolution step provided authoringSkill: an explicit --skill flag, or the project's own config. */
|
||||
@@ -638,6 +639,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren
|
||||
renderTarget,
|
||||
fps,
|
||||
quality,
|
||||
qualityPreset: qualityRaw as keyof typeof QUALITY_ALIASES,
|
||||
authoringSkill,
|
||||
invalidAuthoringSkill,
|
||||
authoringSkillSource,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { createRenderPlan, type RenderCommandArgs } from "./plan.js";
|
||||
import { presentRenderPlan } from "./present.js";
|
||||
|
||||
describe("presentRenderPlan", () => {
|
||||
let projectDir: string;
|
||||
let printed: string[];
|
||||
|
||||
beforeEach(() => {
|
||||
projectDir = mkdtempSync(join(tmpdir(), "hf-render-present-"));
|
||||
writeFileSync(
|
||||
join(projectDir, "index.html"),
|
||||
'<main data-composition-id="main" data-width="1920" data-height="1080" data-fps="30"></main>',
|
||||
);
|
||||
printed = [];
|
||||
vi.spyOn(console, "log").mockImplementation((line?: unknown) => {
|
||||
printed.push(String(line ?? ""));
|
||||
});
|
||||
vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
rmSync(projectDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
async function settingsLine(args: Omit<RenderCommandArgs, "dir">): Promise<string | undefined> {
|
||||
await presentRenderPlan(createRenderPlan({ dir: projectDir, workers: "2", ...args }));
|
||||
return printed.find((line) => line.includes("2 workers"));
|
||||
}
|
||||
|
||||
it.each([
|
||||
[{}, "looks (CRF 16)"],
|
||||
[{ quality: "draft" }, "draft"],
|
||||
[{ quality: "standard" }, "standard"],
|
||||
[{ quality: "delivery" }, "delivery"],
|
||||
[{ crf: "20" }, "looks (CRF 20)"],
|
||||
[{ "video-bitrate": "10M" }, "looks (10M)"],
|
||||
])("names the quality it encodes with for %o", async (args, label) => {
|
||||
expect(await settingsLine(args)).toContain(`30fps · ${label} · 2 workers`);
|
||||
});
|
||||
});
|
||||
@@ -37,7 +37,7 @@ function presentRenderSummary(plan: RenderPlan): void {
|
||||
c.accent("\u25C6") + " Rendering " + c.accent(nameLabel) + c.dim(" \u2192 " + plan.outputPath),
|
||||
);
|
||||
console.log(
|
||||
c.dim(` ${fpsToFfmpegArg(plan.fps)}fps \u00B7 ${plan.quality} \u00B7 ${workerLabel}`),
|
||||
c.dim(` ${fpsToFfmpegArg(plan.fps)}fps \u00B7 ${qualityLabel(plan)} \u00B7 ${workerLabel}`),
|
||||
);
|
||||
if (plan.outputResolution) {
|
||||
console.log(c.dim(" Output resolution: " + plan.outputResolution));
|
||||
@@ -50,6 +50,12 @@ function presentRenderSummary(plan: RenderPlan): void {
|
||||
console.log("");
|
||||
}
|
||||
|
||||
function qualityLabel(plan: Pick<RenderPlan, "qualityPreset" | "crf" | "videoBitrate">): string {
|
||||
if (plan.crf !== undefined) return `${plan.qualityPreset} (CRF ${plan.crf})`;
|
||||
if (plan.videoBitrate) return `${plan.qualityPreset} (${plan.videoBitrate})`;
|
||||
return plan.qualityPreset;
|
||||
}
|
||||
|
||||
/** The GPU line's accelerated modes, or undefined when neither is. */
|
||||
function formatGpuModes(plan: RenderPlan): string | undefined {
|
||||
const modes: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user