Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,146 Bytes
5dfc565 |
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 |
import path from "node:path"
import concat from 'ffmpeg-concat'
import { VideoShot } from '../types.mts'
import { pendingFilesDirFilePath } from "../config.mts"
export const assembleShots = async (shots: VideoShot[], fileName: string) => {
if (!Array.isArray(shots) || shots.length < 2) {
throw new Error(`need at least 2 shots`)
}
const transitions = [
{
name: 'circleOpen',
duration: 1000,
},
{
name: 'crossWarp',
duration: 800,
},
{
name: 'directionalWarp',
duration: 800,
// pass custom params to a transition
params: { direction: [1, -1] },
},
/*
{
name: 'squaresWire',
duration: 2000,
},
*/
]
const videoFilePath = path.join(pendingFilesDirFilePath, fileName)
const shotFilesPaths = shots.map(shot => path.join(
pendingFilesDirFilePath,
shot.fileName
))
await concat({
output: videoFilePath,
videos: shotFilesPaths,
transitions: shotFilesPaths
.slice(0, shotFilesPaths.length - 1)
.map(
(vid) => transitions[Math.floor(Math.random() * transitions.length)]
),
})
}
|