@@ -2,13 +2,18 @@ import { createWriteStream, existsSync } from 'fs';
22import { readFile } from 'fs/promises' ;
33import { Readable } from 'stream' ;
44import { finished } from 'stream/promises' ;
5- import path from 'path' ;
65import { FFmpeg } from '@ffmpeg.wasm/main' ;
76import type { Show } from '@prisma/client' ;
87import core from '@ffmpeg.wasm/core-mt' ;
8+ import { VERCEL } from '$env/static/private' ;
99import { logProgress } from './logProgress' ;
1010
11- const flag_paths = [ './audio/wes-flagger.mp3' , './audio/scott-flagger.mp3' ] ;
11+ import wes_flagger from './audio/wes-flagger.mp3' ;
12+ import scott_flagger from './audio/scott-flagger.mp3' ;
13+
14+ const flag_paths = [ wes_flagger , scott_flagger ] . map ( ( path ) =>
15+ VERCEL ? `.vercel/output/static${ path } ` : path
16+ ) ;
1217
1318export type ProgressEvent = {
1419 duration ?: number ;
@@ -79,9 +84,7 @@ export async function addFlaggerAudio(show: Show): Promise<Buffer> {
7984 console . log ( `wrote ${ file_name } to ffmpeg memory` ) ;
8085 // Write Flaggers to ffmpeg memory
8186 for ( const [ i , flag_path ] of flag_paths . entries ( ) ) {
82- // eslint-disable-next-line @typescript-eslint/naming-convention
83- const __dirname = new URL ( '.' , import . meta. url ) . pathname ;
84- const flag_buffer = await readFile ( path . join ( __dirname , flag_path ) ) ;
87+ const flag_buffer = await readFile ( flag_path ) ;
8588 ffmpeg . fs . writeFile ( `flagger-${ base_name } -${ i } .mp3` , flag_buffer ) ;
8689 console . log ( `wrote flagger-${ base_name } -${ i } .mp3 to ffmpeg memory` ) ;
8790 }
0 commit comments