jbilcke-hf HF staff commited on
Commit
a9505f0
·
1 Parent(s): c11793d

handle an edge case

Browse files
Files changed (1) hide show
  1. src/main.ts +34 -1
src/main.ts CHANGED
@@ -50,7 +50,40 @@ export async function clapToTmpVideoFilePath({
50
 
51
  outputDir = outputDir || (await getRandomDirectory())
52
 
53
- const videoSegments = clap.segments.filter(s => s.category === ClapSegmentCategory.VIDEO && s.assetUrl.startsWith("data:video/"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  const storyboardSegments = clap.segments.filter(s => s.category === ClapSegmentCategory.STORYBOARD && s.assetUrl.startsWith("data:image/"))
55
 
56
  const canUseVideos = videoSegments.length > 0
 
50
 
51
  outputDir = outputDir || (await getRandomDirectory())
52
 
53
+ const alreadyAnEmbeddedFinalVideo = clap.segments.filter(s =>
54
+ s.category === ClapSegmentCategory.VIDEO &&
55
+ s.status === "completed" &&
56
+ s.startTimeInMs === 0 &&
57
+ s.endTimeInMs === clap.meta.durationInMs &&
58
+ s.assetUrl).at(0)
59
+
60
+ let ignoreThisVideoSegmentId = ""
61
+
62
+ if (alreadyAnEmbeddedFinalVideo) {
63
+ ignoreThisVideoSegmentId = alreadyAnEmbeddedFinalVideo?.id || ""
64
+
65
+ /*
66
+ you know what.. let's just ignore it, and re-generate fresh content
67
+ because most probably the user made an honest mistake
68
+
69
+ const outputFilePath = await writeBase64ToFile(
70
+ alreadyAnEmbeddedFinalVideo.assetUrl,
71
+ join(outputDir, `existing_final_video`)
72
+ )
73
+
74
+ return {
75
+ tmpWorkDir: outputDir,
76
+ outputFilePath
77
+ }
78
+ */
79
+ }
80
+
81
+ const videoSegments = clap.segments.filter(s =>
82
+ s.category === ClapSegmentCategory.VIDEO &&
83
+ s.assetUrl.startsWith("data:video/") &&
84
+ s.id !== ignoreThisVideoSegmentId
85
+ )
86
+
87
  const storyboardSegments = clap.segments.filter(s => s.category === ClapSegmentCategory.STORYBOARD && s.assetUrl.startsWith("data:image/"))
88
 
89
  const canUseVideos = videoSegments.length > 0