Spaces:
Sleeping
Sleeping
File size: 2,569 Bytes
6cda6d8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /**
* The single render-boundary decision for a workflow job.
*
* Cloud jobs keep the byte-for-byte existing video/image path. Browser jobs stop here:
* the worker prepares the portable source/narration payload and never invokes the
* native Manim/FFmpeg path. Keeping this decision in one place prevents render-target
* checks from spreading through the individual steps.
*/
import type { GenerationResult } from './analysis-step'
import type { OutputMode, PromptOverrides, RenderTarget, VideoConfig } from '../../../../types'
import type { RenderResult } from './render-step-types'
import { renderImages } from './render-images'
import { renderVideo } from './render-video'
import { prepareBrowserRenderResult } from '../../../browser/browser-render-payload'
export interface RenderOutputArgs {
jobId: string
concept: string
quality: string
outputMode: OutputMode
renderTarget?: RenderTarget
codeResult: GenerationResult
timings: Record<string, number>
customApiConfig?: unknown
videoConfig?: VideoConfig
promptOverrides?: PromptOverrides
onStageUpdate?: () => Promise<void>
clientId?: string
workspaceDirectory?: string
renderCacheKey?: string
workspaceOutputDirectory?: string
sceneName?: string
}
export async function renderOutput(args: RenderOutputArgs): Promise<RenderResult> {
const renderTarget = args.renderTarget ?? 'cloud'
if (renderTarget === 'browser') {
return prepareBrowserRenderResult({
jobId: args.jobId,
concept: args.concept,
quality: args.quality,
outputMode: args.outputMode,
renderTarget,
codeResult: args.codeResult,
sceneName: args.sceneName,
videoConfig: args.videoConfig,
renderCacheKey: args.renderCacheKey,
})
}
return args.outputMode === 'image'
? renderImages(
args.jobId,
args.concept,
args.quality,
args.codeResult,
args.timings,
args.videoConfig,
args.customApiConfig,
args.promptOverrides,
args.onStageUpdate,
args.clientId,
args.workspaceDirectory,
args.renderCacheKey,
args.workspaceOutputDirectory
)
: renderVideo(
args.jobId,
args.concept,
args.quality,
args.codeResult,
args.timings,
args.customApiConfig,
args.videoConfig,
args.promptOverrides,
args.onStageUpdate,
args.clientId,
args.workspaceDirectory,
args.renderCacheKey,
args.workspaceOutputDirectory,
args.sceneName
)
}
|