(inputFile: File)
| 381 | }; |
| 382 | |
| 383 | const extractAudioFromVideo = async (inputFile: File): Promise<void> => { |
| 384 | try { |
| 385 | const parser = await import("@remotion/media-parser"); |
| 386 | const webcodecs = await import("@remotion/webcodecs"); |
| 387 | |
| 388 | const _handleProgress = (progressEvent: { progress: number }) => { |
| 389 | setProgress(Math.min(Math.round(progressEvent.progress * 100), 99)); |
| 390 | }; |
| 391 | |
| 392 | const controller = parser.mediaParserController |
| 393 | ? parser.mediaParserController() |
| 394 | : null; |
| 395 | parserControllerRef.current = controller; |
| 396 | |
| 397 | const result = await webcodecs.convertMedia({ |
| 398 | src: inputFile, |
| 399 | container: "wav", |
| 400 | onProgress: ({ overallProgress }) => { |
| 401 | if (overallProgress !== null) { |
| 402 | setProgress(Math.min(Math.round(overallProgress * 100), 99)); |
| 403 | } |
| 404 | }, |
| 405 | controller: controller as unknown as WebCodecsController, |
| 406 | }); |
| 407 | |
| 408 | const blob = await result.save(); |
| 409 | const url = URL.createObjectURL(blob); |
| 410 | setOutputUrl(url); |
| 411 | setProgress(100); |
| 412 | |
| 413 | trackEvent(`${conversionPath}_conversion_completed`, { |
| 414 | fileSize: file?.size, |
| 415 | fileName: file?.name, |
| 416 | outputSize: blob.size, |
| 417 | }); |
| 418 | } catch (error) { |
| 419 | console.error("Error extracting audio:", error); |
| 420 | throw error; |
| 421 | } |
| 422 | }; |
| 423 | |
| 424 | const convertVideoToGif = async (inputFile: File): Promise<void> => { |
| 425 | try { |
no test coverage detected