mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 22:20:14 +00:00
refactor(producer): unify render requests
This commit is contained in:
@@ -49,6 +49,7 @@ import {
|
||||
isAspectAgnosticResolutionAlias,
|
||||
type CanvasResolution,
|
||||
} from "@hyperframes/core";
|
||||
import { createRenderRequest, renderConfigFromRequest } from "./renderRequest.js";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Types
|
||||
@@ -221,22 +222,26 @@ function parseRenderOverrides(body: Record<string, unknown>): {
|
||||
* the sync (`render`) and streaming (`render-stream`) handlers so the field
|
||||
* set — including `variables` and `outputResolution` — stays in one place.
|
||||
*/
|
||||
function buildRenderJobConfig(input: RenderInput, log: ProducerLogger) {
|
||||
return {
|
||||
fps: input.fps,
|
||||
quality: input.quality,
|
||||
format: input.format,
|
||||
workers: input.workers,
|
||||
useGpu: input.useGpu,
|
||||
debug: input.debug,
|
||||
strictness: input.strictness,
|
||||
entryFile: input.entryFile,
|
||||
variables: input.variables,
|
||||
outputResolution: input.outputResolution,
|
||||
outputResolutionAspectAgnostic: input.outputResolutionAspectAgnostic,
|
||||
videoFrameFormat: input.videoFrameFormat,
|
||||
logger: log,
|
||||
};
|
||||
function buildRenderJobConfig(input: RenderInput, outputPath: string, log: ProducerLogger) {
|
||||
const request = createRenderRequest({
|
||||
projectDir: input.projectDir,
|
||||
outputPath,
|
||||
options: {
|
||||
fps: input.fps,
|
||||
quality: input.quality,
|
||||
format: input.format ?? "mp4",
|
||||
workers: input.workers,
|
||||
useGpu: input.useGpu,
|
||||
debug: input.debug,
|
||||
strictness: input.strictness,
|
||||
entryFile: input.entryFile,
|
||||
variables: input.variables,
|
||||
outputResolution: input.outputResolution,
|
||||
outputResolutionAspectAgnostic: input.outputResolutionAspectAgnostic,
|
||||
videoFrameFormat: input.videoFrameFormat,
|
||||
},
|
||||
});
|
||||
return renderConfigFromRequest(request, { logger: log });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -642,7 +647,7 @@ export function createRenderHandlers(options: HandlerOptions = {}): RenderHandle
|
||||
quality: input.quality,
|
||||
});
|
||||
|
||||
const job = createRenderJob(buildRenderJobConfig(input, log));
|
||||
const job = createRenderJob(buildRenderJobConfig(input, absoluteOutputPath, log));
|
||||
|
||||
try {
|
||||
await executeRenderJob(
|
||||
@@ -718,7 +723,7 @@ export function createRenderHandlers(options: HandlerOptions = {}): RenderHandle
|
||||
|
||||
log.info("render-stream started", { requestId, projectDir: input.projectDir });
|
||||
|
||||
const job = createRenderJob(buildRenderJobConfig(input, log));
|
||||
const job = createRenderJob(buildRenderJobConfig(input, absoluteOutputPath, log));
|
||||
const abortController = new AbortController();
|
||||
const onRequestAbort = () =>
|
||||
abortController.abort(new RenderCancelledError("request_aborted"));
|
||||
|
||||
Reference in New Issue
Block a user