| | import { v4 as uuidv4 } from "uuid" |
| |
|
| | |
| |
|
| | import { VideoSequence, VideoShot, VideoShotMeta } from "../types.mts" |
| | import { generateSeed } from "./generateSeed.mts" |
| | import { getValidNumber } from "./getValidNumber.mts" |
| | import { shotFormatVersion } from "../config.mts" |
| |
|
| | export const parseShotRequest = async (sequence: VideoSequence, maybeShotMeta: Partial<VideoShotMeta>): Promise<VideoShot> => { |
| | |
| | |
| | const id = uuidv4() |
| |
|
| | const shot: VideoShot = { |
| | id, |
| | sequenceId: sequence.id, |
| | ownerId: sequence.ownerId, |
| |
|
| | shotPrompt: `${maybeShotMeta.shotPrompt || ""}`, |
| |
|
| | |
| | environmentPrompt: `${maybeShotMeta.environmentPrompt || ""}`, |
| |
|
| | |
| | photographyPrompt: `${maybeShotMeta.photographyPrompt || ""}`, |
| |
|
| | |
| | actionPrompt: `${maybeShotMeta.actionPrompt || ""}`, |
| |
|
| | |
| | backgroundAudioPrompt: `${maybeShotMeta.backgroundAudioPrompt || ""}`, |
| |
|
| | |
| | foregroundAudioPrompt: `${maybeShotMeta.foregroundAudioPrompt || maybeShotMeta.shotPrompt || ""}`, |
| |
|
| | |
| | actorPrompt: `${maybeShotMeta.actorPrompt || ""}`, |
| |
|
| | |
| | actorVoicePrompt: `${maybeShotMeta.actorVoicePrompt || ""}`, |
| |
|
| | |
| | actorDialoguePrompt: `${maybeShotMeta.actorDialoguePrompt || ""}`, |
| |
|
| | |
| | seed: getValidNumber(maybeShotMeta.seed, 0, 2147483647, generateSeed()), |
| |
|
| | |
| | noise: sequence.noise, |
| | noiseAmount: sequence.noiseAmount, |
| |
|
| | |
| | durationMs: getValidNumber(maybeShotMeta.durationMs, 0, 6000, 3000), |
| | |
| | |
| | steps: getValidNumber(maybeShotMeta.steps || sequence.steps, 10, 50, 45), |
| |
|
| | |
| | fps: getValidNumber(sequence.fps, 8, 60, 30), |
| |
|
| | |
| | resolution: sequence.resolution, |
| |
|
| | |
| | introTransition: 'fade', |
| | introDurationMs: 500, |
| |
|
| | |
| |
|
| | version: shotFormatVersion, |
| | fileName: `${sequence.ownerId}_${sequence.id}_${id}.mp4`, |
| | hasGeneratedPreview: false, |
| | hasGeneratedVideo: false, |
| | hasUpscaledVideo: false, |
| | hasGeneratedBackgroundAudio: false, |
| | hasGeneratedForegroundAudio: false, |
| | hasGeneratedActor: false, |
| | hasInterpolatedVideo: false, |
| | hasAddedAudio: false, |
| | hasPostProcessedVideo: false, |
| | nbCompletedSteps: 0, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | nbTotalSteps: 5, |
| | progressPercent: 0, |
| | createdAt: new Date().toISOString(), |
| | completedAt: '', |
| | completed: false, |
| | error: '', |
| | } |
| |
|
| | return shot |
| | } |