import { generateSeed, getValidNumber } from "@aitube/clap" import { newRender, getRender } from "@/app/api/providers/videochain/renderWithVideoChain" import { sleep } from "@/lib/utils/sleep" import { getNegativePrompt, getPositivePrompt } from "@/app/api/utils/imagePrompts" export async function generateVideo({ prompt, // negativePrompt, width, height, seed, }: { prompt: string // negativePrompt?: string width?: number height?: number seed?: number }): Promise { // we want to keep it vertical width = getValidNumber(width, 256, 8192, 288) height = getValidNumber(height, 256, 8192, 512) // console.log("calling await newRender") prompt = getPositivePrompt(prompt) const negativePrompt = getNegativePrompt() let render = await newRender({ prompt, negativePrompt, nbFrames: 80, nbFPS: 24, nbSteps: 4, width, height, turbo: true, shouldRenewCache: true, seed: seed || generateSeed() }) let attempts = 10 while (attempts-- > 0) { if (render.status === "completed") { return render.assetUrl } if (render.status === "error") { console.error(render.error) throw new Error(`failed to generate the video file ${render.error}`) } await sleep(2000) // minimum wait time // console.log("asking getRender") render = await getRender(render.renderId) } throw new Error(`failed to generate the video file`) }