From 4248ac45d438929a5adb0452ae12c2f1c311e4a5 Mon Sep 17 00:00:00 2001 From: Luke Harries Date: Sun, 16 Jun 2024 18:54:18 -0400 Subject: [PATCH] add duration as input --- examples/sound-effects/video-to-sfx/lib/videoToSFX.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/sound-effects/video-to-sfx/lib/videoToSFX.ts b/examples/sound-effects/video-to-sfx/lib/videoToSFX.ts index 98213b8..2ffd61b 100644 --- a/examples/sound-effects/video-to-sfx/lib/videoToSFX.ts +++ b/examples/sound-effects/video-to-sfx/lib/videoToSFX.ts @@ -1,14 +1,15 @@ +import { maxDuration } from "./../app/api/route"; import { posthog } from "posthog-js"; import { VideoToSFXRequestBody, VideoToSFXResponseBody, } from "@/app/api/interface"; -const apiVideoToSFX = async (frames: string[]) => { +const apiVideoToSFX = async (frames: string[], maxDuration: number) => { posthog?.capture("video_to_sfx_started"); const response = await fetch("/api", { method: "POST", - body: JSON.stringify({ frames } as VideoToSFXRequestBody), + body: JSON.stringify({ frames, maxDuration } as VideoToSFXRequestBody), }); if (!response.ok) { const errorText = await response.text(); @@ -62,7 +63,7 @@ export const convertVideoToSFX = async ( const frame = await getFramesFromVideo(video, canvas, i); frames.push(frame as string); } - const sfx = await apiVideoToSFX(frames); + const sfx = await apiVideoToSFX(frames, video.duration); resolve({ soundEffects: sfx.soundEffects, caption: sfx.caption,