jbilcke-hf HF staff commited on
Commit
1f38dc1
·
1 Parent(s): 6349b58
Files changed (2) hide show
  1. src/index.mts +1 -1
  2. src/main.mts +6 -4
src/index.mts CHANGED
@@ -68,7 +68,7 @@ app.post("/", async (req, res) => {
68
  let fileData = Buffer.concat(data)
69
 
70
  const clap: ClapProject = await parseClap(new Blob([fileData]));
71
- console.log("got a clap project:", clapProject)
72
 
73
  const {
74
  tmpWorkDir,
 
68
  let fileData = Buffer.concat(data)
69
 
70
  const clap: ClapProject = await parseClap(new Blob([fileData]));
71
+ console.log("got a clap project:", clap)
72
 
73
  const {
74
  tmpWorkDir,
src/main.mts CHANGED
@@ -39,29 +39,31 @@ export async function clapToTmpVideoFilePath({
39
 
40
  outputDir = outputDir || (await getRandomDirectory())
41
 
42
- const videoFilePaths: string[] = []
43
-
44
  const videoSegments = clap.segments.filter(s => s.category === "video" && s.assetUrl.startsWith("data:video/"))
45
  const storyboardSegments = clap.segments.filter(s => s.category === "storyboard" && s.assetUrl.startsWith("data:image/"))
46
 
47
  const canUseVideos = videoSegments.length > 0
48
  const canUseStoryboards = !canUseVideos && storyboardSegments.length > 0
49
 
 
 
50
  // two possibilities:
51
  // we can either generate from the video files, or from the storyboards
52
  // the storyboard video will be a bit more boring, but at least it should process faster
53
  if (canUseVideos) {
54
- await clapWithVideosToVideoFile({
55
  clap,
56
  videoSegments,
57
  outputDir,
58
  })
 
59
  } else if (canUseStoryboards) {
60
- await clapWithStoryboardsToVideoFile({
61
  clap,
62
  storyboardSegments,
63
  outputDir,
64
  })
 
65
  } else {
66
  throw new Error(`the provided Clap doesn't contain any video or storyboard`)
67
  }
 
39
 
40
  outputDir = outputDir || (await getRandomDirectory())
41
 
 
 
42
  const videoSegments = clap.segments.filter(s => s.category === "video" && s.assetUrl.startsWith("data:video/"))
43
  const storyboardSegments = clap.segments.filter(s => s.category === "storyboard" && s.assetUrl.startsWith("data:image/"))
44
 
45
  const canUseVideos = videoSegments.length > 0
46
  const canUseStoryboards = !canUseVideos && storyboardSegments.length > 0
47
 
48
+ let videoFilePaths: string[] = []
49
+
50
  // two possibilities:
51
  // we can either generate from the video files, or from the storyboards
52
  // the storyboard video will be a bit more boring, but at least it should process faster
53
  if (canUseVideos) {
54
+ const concatenatedData = await clapWithVideosToVideoFile({
55
  clap,
56
  videoSegments,
57
  outputDir,
58
  })
59
+ videoFilePaths = concatenatedData.videoFilePaths
60
  } else if (canUseStoryboards) {
61
+ const concatenatedData = await clapWithStoryboardsToVideoFile({
62
  clap,
63
  storyboardSegments,
64
  outputDir,
65
  })
66
+ videoFilePaths = concatenatedData.videoFilePaths
67
  } else {
68
  throw new Error(`the provided Clap doesn't contain any video or storyboard`)
69
  }