jbilcke-hf HF staff commited on
Commit
6349b58
·
1 Parent(s): 4cb7ad9

add more logs

Browse files
src/core/exporters/clapWithStoryboardsToVideoFile.mts CHANGED
@@ -47,6 +47,8 @@ export async function clapWithStoryboardsToVideoFile({
47
  s.category === "interface" &&
48
  startOfSegment1IsWithinSegment2(s, segment)
49
  )
 
 
50
  const interfaceSegment = interfaceSegments.at(0)
51
  if (interfaceSegment) {
52
  // here we are free to use mp4, since this is an internal intermediary format
@@ -67,11 +69,15 @@ export async function clapWithStoryboardsToVideoFile({
67
  storyboardSegmentVideoFilePath = videoSegmentWithOverlayFilePath
68
  }
69
 
 
70
  const dialogueSegments = clap.segments.filter(s =>
71
  s.assetUrl.startsWith("data:audio/") &&
72
  s.category === "dialogue" &&
73
  startOfSegment1IsWithinSegment2(s, segment)
74
  )
 
 
 
75
  const dialogueSegment = dialogueSegments.at(0)
76
  if (dialogueSegment) {
77
  extractBase64(dialogueSegment.assetUrl)
@@ -103,6 +109,8 @@ export async function clapWithStoryboardsToVideoFile({
103
  videoFilePaths.push(storyboardSegmentVideoFilePath)
104
  }
105
 
 
 
106
  return {
107
  outputDir,
108
  videoFilePaths,
 
47
  s.category === "interface" &&
48
  startOfSegment1IsWithinSegment2(s, segment)
49
  )
50
+ console.log(`clapWithStoryboardsToVideoFile: got ${interfaceSegments.length} interface segments for shot ${segment.id} [${segment.startTimeInMs}:${segment.endTimeInMs}]`)
51
+
52
  const interfaceSegment = interfaceSegments.at(0)
53
  if (interfaceSegment) {
54
  // here we are free to use mp4, since this is an internal intermediary format
 
69
  storyboardSegmentVideoFilePath = videoSegmentWithOverlayFilePath
70
  }
71
 
72
+
73
  const dialogueSegments = clap.segments.filter(s =>
74
  s.assetUrl.startsWith("data:audio/") &&
75
  s.category === "dialogue" &&
76
  startOfSegment1IsWithinSegment2(s, segment)
77
  )
78
+
79
+ console.log(`clapWithStoryboardsToVideoFile: got ${dialogueSegments.length} dialogue segments for shot ${segment.id} [${segment.startTimeInMs}:${segment.endTimeInMs}]`)
80
+
81
  const dialogueSegment = dialogueSegments.at(0)
82
  if (dialogueSegment) {
83
  extractBase64(dialogueSegment.assetUrl)
 
109
  videoFilePaths.push(storyboardSegmentVideoFilePath)
110
  }
111
 
112
+ console.log(`clapWithStoryboardsToVideoFile: videoFilePaths: ${JSON.stringify(videoFilePaths, null, 2)}`)
113
+
114
  return {
115
  outputDir,
116
  videoFilePaths,
src/core/exporters/clapWithVideosToVideoFile.mts CHANGED
@@ -101,6 +101,8 @@ export async function clapWithVideosToVideoFile({
101
  videoFilePaths.push(videoSegmentFilePath)
102
  }
103
 
 
 
104
  return {
105
  outputDir,
106
  videoFilePaths,
 
101
  videoFilePaths.push(videoSegmentFilePath)
102
  }
103
 
104
+ console.log(`clapWithVideosToVideoFile: videoFilePaths: ${JSON.stringify(videoFilePaths, null, 2)}`)
105
+
106
  return {
107
  outputDir,
108
  videoFilePaths,
src/main.mts CHANGED
@@ -66,17 +66,24 @@ export async function clapToTmpVideoFilePath({
66
  throw new Error(`the provided Clap doesn't contain any video or storyboard`)
67
  }
68
 
 
 
69
  const concatenatedVideosNoMusic = await concatenateVideos({
70
  videoFilePaths,
71
  output: join(outputDir, `tmp_asset_concatenated_videos.mp4`)
72
  })
73
 
 
 
74
  const audioTracks: string[] = []
75
 
76
  const musicSegments = clap.segments.filter(s =>
77
  s.category === "music" &&
78
  s.assetUrl.startsWith("data:audio/")
79
  )
 
 
 
80
  for (const segment of musicSegments) {
81
  audioTracks.push(
82
  await writeBase64ToFile(
@@ -86,12 +93,25 @@ export async function clapToTmpVideoFilePath({
86
  )
87
  }
88
 
 
 
89
  const concatenatedAudio = await concatenateAudio({
90
  output: join(outputDir, `tmp_asset_concatenated_audio.wav`),
91
  audioTracks,
92
  crossfadeDurationInSec: 2 // 2 seconds
93
  })
94
-
 
 
 
 
 
 
 
 
 
 
 
95
  const finalFilePathOfVideoWithMusic = await concatenateVideosWithAudio({
96
  output: join(outputDir, `final_video.${format}`),
97
  format,
@@ -101,12 +121,18 @@ export async function clapToTmpVideoFilePath({
101
  videoTracksVolume: 0.85,
102
  audioTrackVolume: 0.15, // let's keep the music volume low
103
  })
104
-
 
105
  if (clearTmpFilesAtEnd) {
106
  // we delete all the temporary assets
107
  await deleteFilesWithName(outputDir, `tmp_asset_`)
108
  }
109
 
 
 
 
 
 
110
  return {
111
  tmpWorkDir: outputDir,
112
  outputFilePath: finalFilePathOfVideoWithMusic
 
66
  throw new Error(`the provided Clap doesn't contain any video or storyboard`)
67
  }
68
 
69
+ console.log(`clapToTmpVideoFilePath: calling concatenateVideos over ${videoFilePaths.length} video chunks`)
70
+
71
  const concatenatedVideosNoMusic = await concatenateVideos({
72
  videoFilePaths,
73
  output: join(outputDir, `tmp_asset_concatenated_videos.mp4`)
74
  })
75
 
76
+ console.log(`clapToTmpVideoFilePath: concatenatedVideosNoMusic`, concatenatedVideosNoMusic)
77
+
78
  const audioTracks: string[] = []
79
 
80
  const musicSegments = clap.segments.filter(s =>
81
  s.category === "music" &&
82
  s.assetUrl.startsWith("data:audio/")
83
  )
84
+
85
+ console.log(`clapToTmpVideoFilePath: got ${musicSegments.length} music segments in total`)
86
+
87
  for (const segment of musicSegments) {
88
  audioTracks.push(
89
  await writeBase64ToFile(
 
93
  )
94
  }
95
 
96
+ console.log(`clapToTmpVideoFilePath: calling concatenateAudio over ${audioTracks.length} audio tracks`)
97
+
98
  const concatenatedAudio = await concatenateAudio({
99
  output: join(outputDir, `tmp_asset_concatenated_audio.wav`),
100
  audioTracks,
101
  crossfadeDurationInSec: 2 // 2 seconds
102
  })
103
+ console.log(`clapToTmpVideoFilePath: concatenatedAudio = ${concatenatedAudio}`)
104
+
105
+ console.log(`clapToTmpVideoFilePath: calling concatenateVideosWithAudio with: ${JSON.stringify({
106
+ output: join(outputDir, `final_video.${format}`),
107
+ format,
108
+ audioFilePath: concatenatedAudio.filepath,
109
+ videoFilePaths: [concatenatedVideosNoMusic.filepath],
110
+ // videos are silent, so they can stay at 0
111
+ videoTracksVolume: 0.85,
112
+ audioTrackVolume: 0.15, // let's keep the music volume low
113
+ }, null, 2)}`)
114
+
115
  const finalFilePathOfVideoWithMusic = await concatenateVideosWithAudio({
116
  output: join(outputDir, `final_video.${format}`),
117
  format,
 
121
  videoTracksVolume: 0.85,
122
  audioTrackVolume: 0.15, // let's keep the music volume low
123
  })
124
+ console.log(`clapToTmpVideoFilePath: finalFilePathOfVideoWithMusic = ${finalFilePathOfVideoWithMusic}`)
125
+
126
  if (clearTmpFilesAtEnd) {
127
  // we delete all the temporary assets
128
  await deleteFilesWithName(outputDir, `tmp_asset_`)
129
  }
130
 
131
+ console.log(`clapToTmpVideoFilePath: returning ${JSON.stringify( {
132
+ tmpWorkDir: outputDir,
133
+ outputFilePath: finalFilePathOfVideoWithMusic
134
+ }, null, 2)}`)
135
+
136
  return {
137
  tmpWorkDir: outputDir,
138
  outputFilePath: finalFilePathOfVideoWithMusic