jbilcke-hf HF staff commited on
Commit
7051193
·
1 Parent(s): c7bd1f3
src/core/ffmpeg/imageToVideoBase64.mts CHANGED
@@ -43,6 +43,18 @@ export async function imageToVideoBase64({
43
 
44
  outputDir = outputDir || (await getRandomDirectory())
45
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  // Decode the Base64 image and write it to a temporary file.
47
  const base64Data = inputImageInBase64.substring(inputImageInBase64.indexOf(',') + 1);
48
  const buffer = Buffer.from(base64Data, 'base64');
@@ -53,9 +65,12 @@ export async function imageToVideoBase64({
53
  outputFilePath = outputFilePath || path.join(outputDir, `output.${outputVideoFormat}`);
54
  const durationInSeconds = outputVideoDurationInMs / 1000;
55
 
 
 
56
  // Process the image to video conversion using ffmpeg.
57
  await new Promise<void>((resolve, reject) => {
58
  ffmpeg(inputImagePath)
 
59
  .outputOptions([
60
  `-t ${durationInSeconds}`,
61
  `-r ${fps}`,
 
43
 
44
  outputDir = outputDir || (await getRandomDirectory())
45
 
46
+
47
+ console.log(`imagetoVideoBase64 called with: ${JSON.stringify({
48
+ inputImageInBase64: inputImageInBase64?.slice(0, 50),
49
+ outputFilePath,
50
+ width,
51
+ height,
52
+ outputVideoDurationInMs,
53
+ outputDir,
54
+ clearOutputDirAtTheEnd,
55
+ outputVideoFormat,
56
+ }, null, 2)}`)
57
+
58
  // Decode the Base64 image and write it to a temporary file.
59
  const base64Data = inputImageInBase64.substring(inputImageInBase64.indexOf(',') + 1);
60
  const buffer = Buffer.from(base64Data, 'base64');
 
65
  outputFilePath = outputFilePath || path.join(outputDir, `output.${outputVideoFormat}`);
66
  const durationInSeconds = outputVideoDurationInMs / 1000;
67
 
68
+ console.log("durationInSeconds: " + durationInSeconds)
69
+
70
  // Process the image to video conversion using ffmpeg.
71
  await new Promise<void>((resolve, reject) => {
72
  ffmpeg(inputImagePath)
73
+ .inputOptions(['-loop 1']) // Loop the input image
74
  .outputOptions([
75
  `-t ${durationInSeconds}`,
76
  `-r ${fps}`,
src/main.mts CHANGED
@@ -114,15 +114,6 @@ export async function clapToTmpVideoFilePath({
114
  console.log(`clapToTmpVideoFilePath: concatenatedAudio = ${concatenatedAudio}`)
115
  }
116
 
117
- console.log(`clapToTmpVideoFilePath: calling concatenateVideosWithAudio with: ${JSON.stringify({
118
- output: join(outputDir, `final_video.${format}`),
119
- format,
120
- audioFilePath: concatenatedAudio ? concatenatedAudio?.filepath : "",
121
- videoFilePaths: [concatenatedVideosNoMusic.filepath],
122
- // videos are silent, so they can stay at 0
123
- videoTracksVolume: 0.85,
124
- audioTrackVolume: 0.15, // let's keep the music volume low
125
- }, null, 2)}`)
126
 
127
  const finalFilePathOfVideoWithMusic = await concatenateVideosWithAudio({
128
  output: join(outputDir, `final_video.${format}`),
 
114
  console.log(`clapToTmpVideoFilePath: concatenatedAudio = ${concatenatedAudio}`)
115
  }
116
 
 
 
 
 
 
 
 
 
 
117
 
118
  const finalFilePathOfVideoWithMusic = await concatenateVideosWithAudio({
119
  output: join(outputDir, `final_video.${format}`),