|
1 | 1 | import { createWriteStream, existsSync } from 'fs'; |
2 | | -import { readFile } from 'fs/promises'; |
3 | 2 | import { Readable } from 'stream'; |
4 | 3 | import { finished } from 'stream/promises'; |
5 | 4 | import { FFmpeg } from '@ffmpeg.wasm/main'; |
6 | 5 | import type { Show } from '@prisma/client'; |
7 | 6 | import core from '@ffmpeg.wasm/core-mt'; |
8 | | -import { VERCEL } from '$env/static/private'; |
| 7 | +import { read } from '$app/server'; |
9 | 8 | import { logProgress } from './logProgress'; |
10 | 9 |
|
11 | 10 | import wes_flagger from './audio/wes-flagger.mp3'; |
12 | 11 | import scott_flagger from './audio/scott-flagger.mp3'; |
13 | 12 |
|
14 | | -const flag_paths = [wes_flagger, scott_flagger].map((path) => |
15 | | - VERCEL ? `.vercel/output/static${path}` : path |
16 | | -); |
| 13 | +const flag_paths = [wes_flagger, scott_flagger]; |
17 | 14 |
|
18 | 15 | export type ProgressEvent = { |
19 | 16 | duration?: number; |
@@ -84,7 +81,7 @@ export async function addFlaggerAudio(show: Show): Promise<Buffer> { |
84 | 81 | console.log(`wrote ${file_name} to ffmpeg memory`); |
85 | 82 | // Write Flaggers to ffmpeg memory |
86 | 83 | for (const [i, flag_path] of flag_paths.entries()) { |
87 | | - const flag_buffer = await readFile(flag_path); |
| 84 | + const flag_buffer = Buffer.from(new Uint8Array(await read(flag_path).arrayBuffer())); |
88 | 85 | ffmpeg.fs.writeFile(`flagger-${base_name}-${i}.mp3`, flag_buffer); |
89 | 86 | console.log(`wrote flagger-${base_name}-${i}.mp3 to ffmpeg memory`); |
90 | 87 | } |
|
0 commit comments