jbilcke-hf HF staff commited on
Commit
b66c635
1 Parent(s): 18ffad7

dirty hack

Browse files
src/app/api/utils/getMediaInfo.ts CHANGED
@@ -34,7 +34,6 @@ export async function getMediaInfo(input: string): Promise<MediaMetadata> {
34
  // Generate a temporary file name
35
  const tempFileName = join(tmpdir(), `temp-media-${Date.now()}.${extension}`);
36
 
37
-
38
  // Write the buffer to a temporary file
39
  await writeFile(tempFileName, buffer);
40
 
@@ -61,7 +60,7 @@ async function getMetaDataFromPath(filePath: string): Promise<MediaMetadata> {
61
  }
62
 
63
  if (err) {
64
- console.error("getMediaInfo(): failed to analyze the source (might happen with empty files)")
65
  // reject(err);
66
  resolve(results);
67
  return;
@@ -73,7 +72,7 @@ async function getMetaDataFromPath(filePath: string): Promise<MediaMetadata> {
73
  results.hasAudio = (metadata?.streams || []).some((stream) => stream.codec_type === 'audio');
74
 
75
  } catch (err) {
76
- console.error(`getMediaInfo(): failed to analyze the source (might happen with empty files)`)
77
  results.durationInSec = 0
78
  results.durationInMs = 0
79
  results.hasAudio = false
 
34
  // Generate a temporary file name
35
  const tempFileName = join(tmpdir(), `temp-media-${Date.now()}.${extension}`);
36
 
 
37
  // Write the buffer to a temporary file
38
  await writeFile(tempFileName, buffer);
39
 
 
60
  }
61
 
62
  if (err) {
63
+ console.error("getMediaInfo(): failed to analyze the source (might happen with empty files)", err)
64
  // reject(err);
65
  resolve(results);
66
  return;
 
72
  results.hasAudio = (metadata?.streams || []).some((stream) => stream.codec_type === 'audio');
73
 
74
  } catch (err) {
75
+ console.error(`getMediaInfo(): failed to analyze the source (might happen with empty files)`, err)
76
  results.durationInSec = 0
77
  results.durationInMs = 0
78
  results.hasAudio = false
src/app/api/v1/edit/music/generateMusic.ts CHANGED
@@ -66,12 +66,7 @@ export async function generateMusic({
66
  return
67
  }
68
 
69
- const { durationInMs, hasAudio } = await getMediaInfo(assetUrl)
70
-
71
- if (!hasAudio) {
72
- console.warn(`generateMusic(): the generated music waveform appears to be silent (might be a ffprobe malfunction)`)
73
- // return
74
- }
75
 
76
  const newProperties: Partial<ClapSegment> = {
77
  assetUrl,
@@ -80,6 +75,17 @@ export async function generateMusic({
80
  status: "completed"
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
83
  if (mode !== ClapCompletionMode.FULL) {
84
  console.log(`generateMusic(): adding music to a new clap file`)
85
  newerClap.segments.push(newSegment({
 
66
  return
67
  }
68
 
69
+ let { durationInMs, hasAudio } = await getMediaInfo(assetUrl)
 
 
 
 
 
70
 
71
  const newProperties: Partial<ClapSegment> = {
72
  assetUrl,
 
75
  status: "completed"
76
  }
77
 
78
+
79
+ if (!hasAudio) {
80
+ console.warn(`generateMusic(): the generated music waveform appears to be silent (might be a ffprobe malfunction)`)
81
+ // return
82
+ // we have a bug on AiTube, basically the ffmpeg probe isn't working,
83
+ // because it doesn't find ffmpeg
84
+ // if think the issue is how the Dockerfile is formed
85
+ // so until this is fixed, we need to fake a "correct" result
86
+ newProperties.assetDurationInMs = musicSegment.assetDurationInMs
87
+ }
88
+
89
  if (mode !== ClapCompletionMode.FULL) {
90
  console.log(`generateMusic(): adding music to a new clap file`)
91
  newerClap.segments.push(newSegment({