code-rabbit suggested fixes

This commit is contained in:
Shubbu03
2025-06-23 22:22:43 +05:30
parent 7d1b5ceb0d
commit 327196356c

View File

@ -108,18 +108,19 @@ export const getVideoInfo = async (videoFile: File): Promise<{
// Write input file // Write input file
await ffmpeg.writeFile(inputName, new Uint8Array(await videoFile.arrayBuffer())); await ffmpeg.writeFile(inputName, new Uint8Array(await videoFile.arrayBuffer()));
// Capture FFmpeg stderr output // Capture FFmpeg stderr output with a one-time listener pattern
let ffmpegOutput = ''; let ffmpegOutput = '';
let listening = true;
const listener = (data: string) => { const listener = (data: string) => {
ffmpegOutput += data; if (listening) ffmpegOutput += data;
}; };
ffmpeg.on('log', ({ message }) => listener(message)); ffmpeg.on('log', ({ message }) => listener(message));
// Run ffmpeg to get info (stderr will contain the info) // Run ffmpeg to get info (stderr will contain the info)
await ffmpeg.exec(['-i', inputName, '-f', 'null', '-']); await ffmpeg.exec(['-i', inputName, '-f', 'null', '-']);
// Remove listener // Disable listener after exec completes
// (No off() method in ffmpeg.wasm, so this is a no-op, but included for clarity) listening = false;
// Cleanup // Cleanup
await ffmpeg.deleteFile(inputName); await ffmpeg.deleteFile(inputName);