From cf996b28ac3e19caeff74bcc539a0067aa671aba Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Tue, 21 Mar 2023 13:46:16 +0800 Subject: [PATCH] Possible cache support Use cache for sending previously downloaded videos --- src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1a883ae..19f0579 100644 --- a/src/index.ts +++ b/src/index.ts @@ -124,12 +124,13 @@ class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmit ffmpegProcessAudioStreamArgs.push(clipDuration); } + const cacheFilename = 'output.webm'; // todo label this on the cache const ffmpegProcessArgs = [ ...ffmpegProcessVideoStreamArgs, ...ffmpegProcessAudioStreamArgs, '-map', '0:v', '-map', '1:a', - 'output.webm', + cacheFilename, ]; this.emit('process', { type: 'postprocess', @@ -142,8 +143,8 @@ class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmit this.emit('end'); return; } - const output = readFileSync('output.webm'); - unlinkSync('output.webm'); + const output = readFileSync(cacheFilename); + unlinkSync(cacheFilename); this.emit('process', { type: 'postprocess', phase: 'success',