jbilcke-hf HF staff commited on
Commit
350665d
1 Parent(s): 1cef24b
src/app/api/utils/getMediaInfo.ts CHANGED
@@ -19,13 +19,16 @@ export async function getMediaInfo(input: string): Promise<MediaMetadata> {
19
  // If the input is a base64 string
20
  if (input.startsWith("data:")) {
21
  // Extract the base64 content
22
- const base64Content = input.split(";base64,").pop();
23
- if (!base64Content) {
24
  throw new Error("Invalid base64 data");
25
  }
26
 
 
 
 
27
  // Decode the base64 content to a buffer
28
- const buffer = Buffer.from(base64Content, 'base64');
29
 
30
  // Generate a temporary file name
31
  const tempFileName = join(tmpdir(), `temp-media-${Date.now()}`);
@@ -56,7 +59,7 @@ async function getMetaDataFromPath(filePath: string): Promise<MediaMetadata> {
56
  }
57
 
58
  if (err) {
59
- console.error("getMediaInfo(): failed to analyze the source (might happen with empty files)")
60
  // reject(err);
61
  resolve(results);
62
  return;
@@ -68,7 +71,7 @@ async function getMetaDataFromPath(filePath: string): Promise<MediaMetadata> {
68
  results.hasAudio = (metadata?.streams || []).some((stream) => stream.codec_type === 'audio');
69
 
70
  } catch (err) {
71
- console.error(`getMediaInfo(): failed to analyze the source (might happen with empty files)`)
72
  results.durationInSec = 0
73
  results.durationInMs = 0
74
  results.hasAudio = false
 
19
  // If the input is a base64 string
20
  if (input.startsWith("data:")) {
21
  // Extract the base64 content
22
+ const [head, tail] = input.split(";base64,")
23
+ if (!tail) {
24
  throw new Error("Invalid base64 data");
25
  }
26
 
27
+ const extension = head.split("/").pop() || ""
28
+ const base64Content = tail || ""
29
+
30
  // Decode the base64 content to a buffer
31
+ const buffer = Buffer.from(base64Content, 'base64')
32
 
33
  // Generate a temporary file name
34
  const tempFileName = join(tmpdir(), `temp-media-${Date.now()}`);
 
59
  }
60
 
61
  if (err) {
62
+ console.error("getMediaInfo(): failed to analyze the source (might happen with empty files)", err)
63
  // reject(err);
64
  resolve(results);
65
  return;
 
71
  results.hasAudio = (metadata?.streams || []).some((stream) => stream.codec_type === 'audio');
72
 
73
  } catch (err) {
74
+ console.error(`getMediaInfo(): failed to analyze the source (might happen with empty files)`, err)
75
  results.durationInSec = 0
76
  results.durationInMs = 0
77
  results.hasAudio = false
src/app/api/v1/edit/music/generateMusicWithMusicgen.ts CHANGED
@@ -2,8 +2,6 @@ import { addBase64Header } from "@/lib/data/addBase64Header"
2
  import { MusicGenerationParams } from "./types"
3
  import { getClusterMachine } from "./cluster"
4
 
5
- const gradioSpaceApiUrl = `https://jbilcke-hf-ai-tube-model-musicgen.hf.space`
6
- const huggingFaceSpace = "jbilcke-hf/ai-tube-model-musicgen"
7
  const microserviceApiKey = `${process.env.MICROSERVICE_API_SECRET_TOKEN || ""}`
8
 
9
  /**
 
2
  import { MusicGenerationParams } from "./types"
3
  import { getClusterMachine } from "./cluster"
4
 
 
 
5
  const microserviceApiKey = `${process.env.MICROSERVICE_API_SECRET_TOKEN || ""}`
6
 
7
  /**
src/app/api/v1/edit/videos/processShot.ts CHANGED
@@ -87,7 +87,7 @@ export async function processShot({
87
  if (!shotVideoSegment.assetUrl) {
88
  // console.log(`[api/edit/videos] processShot: generating video file..`)
89
 
90
- const debug = true
91
 
92
  let width = existingClap.meta.width
93
  let height = existingClap.meta.height
@@ -124,7 +124,7 @@ export async function processShot({
124
  throw err
125
  }
126
 
127
- console.log(`[api/edit/videos] processShot: generated video files: ${shotVideoSegment?.assetUrl?.slice?.(0, 50)}...`)
128
 
129
  // if mode is full, newerClap already contains the ference to shotVideoSegment
130
  // but if it's partial, we need to manually add it
 
87
  if (!shotVideoSegment.assetUrl) {
88
  // console.log(`[api/edit/videos] processShot: generating video file..`)
89
 
90
+ const debug = false
91
 
92
  let width = existingClap.meta.width
93
  let height = existingClap.meta.height
 
124
  throw err
125
  }
126
 
127
+ // console.log(`[api/edit/videos] processShot: generated video files: ${shotVideoSegment?.assetUrl?.slice?.(0, 50)}...`)
128
 
129
  // if mode is full, newerClap already contains the ference to shotVideoSegment
130
  // but if it's partial, we need to manually add it
src/app/api/v1/render/route.ts CHANGED
@@ -31,7 +31,7 @@ export async function POST(req: NextRequest, res: NextResponse) {
31
  const nbFrames = 80
32
  const nbFPS = 24
33
  const nbSteps = turbo ? 4 : 8
34
- const debug = true
35
 
36
  const assetUrl = await render({
37
  prompt,
 
31
  const nbFrames = 80
32
  const nbFPS = 24
33
  const nbSteps = turbo ? 4 : 8
34
+ const debug = false
35
 
36
  const assetUrl = await render({
37
  prompt,