Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 3,605 Bytes
5fb05e6 5dfc565 5fb05e6 5dfc565 5fb05e6 7bea24d 5dfc565 5fb05e6 5dfc565 e4e0e54 5fb05e6 e4e0e54 5fb05e6 b2bd451 5fb05e6 c08a992 5fb05e6 57adb5c 5fb05e6 ccd48b8 5fb05e6 9571f2e 5dfc565 5fb05e6 b2bd451 5fb05e6 e4e0e54 5fb05e6 |
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import { v4 as uuidv4 } from "uuid"
// convert a request (which might be invalid)
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> => {
// we don't want people to input their own ID or we might have trouble,
// such as people attempting to use a non-UUID, a file path (to hack us), etc
const id = uuidv4()
const shot: VideoShot = {
id,
sequenceId: sequence.id,
ownerId: sequence.ownerId,
shotPrompt: `${maybeShotMeta.shotPrompt || ""}`,
// background, weather, lights, time of the day, etc
environmentPrompt: `${maybeShotMeta.environmentPrompt || ""}`,
// camera parameters, angle, type of shot etc
photographyPrompt: `${maybeShotMeta.photographyPrompt || ""}`,
// dynamic elements of the scene, movement etc
actionPrompt: `${maybeShotMeta.actionPrompt || ""}`,
// describe the background audio (crowd, birds, wind, sea etc..)
backgroundAudioPrompt: `${maybeShotMeta.backgroundAudioPrompt || ""}`,
// describe the foreground audio (cars revving, footsteps, objects breaking, explosion etc)
foregroundAudioPrompt: `${maybeShotMeta.foregroundAudioPrompt || maybeShotMeta.shotPrompt || ""}`,
// describe the main actor visible in the shot (optional)
actorPrompt: `${maybeShotMeta.actorPrompt || ""}`,
// describe the main actor voice (man, woman, old, young, amused, annoyed.. etc)
actorVoicePrompt: `${maybeShotMeta.actorVoicePrompt || ""}`,
// describe the main actor dialogue line
actorDialoguePrompt: `${maybeShotMeta.actorDialoguePrompt || ""}`,
// a video sequence SHOULD NOT HAVE a consistent seed, to avoid weird geometry similarities
seed: getValidNumber(maybeShotMeta.seed, 0, 4294967295, generateSeed()),
// a video sequence SHOULD HAVE a consistent grain
noise: sequence.noise,
noiseAmount: sequence.noiseAmount,
// a video sequence CAN HAVE inconsistent scene duration, like in any real movie
durationMs: getValidNumber(maybeShotMeta.durationMs, 0, 6000, 3000),
// a video sequence CAN HAVE inconsistent iteration steps
steps: getValidNumber(maybeShotMeta.steps || sequence.steps, 10, 50, 45),
// a video sequence MUST HAVE consistent frames per second
fps: getValidNumber(sequence.fps, 8, 60, 30),
// a video sequence MUST HAVE a consistent resolution
resolution: sequence.resolution,
// a video sequence CAN HAVE intro transitions for each shot
introTransition: 'fade',
introDurationMs: 500,
// for internal use
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,
// - generate with Zeroscope
// - upscale with Zeroscope XL
// - interpolate with FILE
// - generate audio background
// - generate audio foreground
// - add audio to video
// - post-processing
nbTotalSteps: 5,
progressPercent: 0,
createdAt: new Date().toISOString(),
completedAt: '',
completed: false,
error: '',
}
return shot
} |