Update index.js
Browse files19 unmodified lines20212223232425261 unmodified line2829303132333435363738394041364243444519 unmodified linesconst ffmpeg = require('fluent-ffmpeg');const { spawn } = require('child_process');
function convertWebmToMp4(webmBuffer) {async function convertWebmToMp4(webmBuffer) { return new Promise((resolve, reject) => { const ffmpegProcess = spawn('ffmpeg', [ '-i', '-', // Input dari stdin1 unmodified line 'pipe:1' // Output ke stdout ]);
let chunks = []; // Define chunks array to accumulate data
ffmpegProcess.on('error', (err) => { reject(err); });
ffmpegProcess.stdout.on('data', (chunk) => { // Listen for data events from stdout chunks.push(chunk); // Accumulate data chunks });
ffmpegProcess.on('close', () => { resolve(Buffer.concat(chunks)); resolve(Buffer.concat(chunks)); // Concatenate all chunks into a single buffer });
ffmpegProcess.stdin.write(webmBuffer);index.js+8-2