Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,147 Bytes
ccd48b8 |
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 |
import { assembleShots } from "../production/assembleShots.mts"
import { Video, VideoShot } from "../types.mts"
import { copyVideoFromPendingToCompleted } from "../utils/copyVideoFromPendingToCompleted.mts"
export const updateShotPreview = async (video: Video, shot: VideoShot) => {
// copy the individual shot
await copyVideoFromPendingToCompleted(shot.fileName)
// now let's create the latest version of the assembly
const shotsThatCanBeAssembled = video.shots.filter(sh => sh.hasGeneratedPreview)
// if we have multiple shots with at least a minimal image, we assemble them
if (shotsThatCanBeAssembled.length === 1) {
// copy the individual shot to become the final video
await copyVideoFromPendingToCompleted(shot.fileName, video.fileName)
} else if (shotsThatCanBeAssembled.length > 1) {
try {
// create an updated assembly
await assembleShots(shotsThatCanBeAssembled, video.fileName)
// copy the assembly to become the final video
await copyVideoFromPendingToCompleted(video.fileName)
} catch (err) {
console.error(`failed to create the temporary assembly: ${err}`)
}
}
} |