Update index.js
Browse files19 unmodified lines202122232324252611 unmodified lines383940414243444546474845464950515253545556575859606119 unmodified linesconst ffmpeg = require('fluent-ffmpeg');const { spawn } = require('child_process');
async function convertWebmToMp4(webmBuffer) {function convertWebmToMp4(webmBuffer) { return new Promise((resolve, reject) => { const ffmpegProcess = spawn('ffmpeg', [ '-i', '-', // Input dari stdin11 unmodified lines chunks.push(chunk); // Accumulate data chunks });
ffmpegProcess.stdin.on('error', (err) => { // Handle errors on stdin reject(err); });
ffmpegProcess.on('close', () => { resolve(Buffer.concat(chunks)); // Concatenate all chunks into a single buffer });
ffmpegProcess.stdin.write(webmBuffer); ffmpegProcess.stdin.end(); ffmpegProcess.stdin.write(webmBuffer, (err) => { // Write data to stdin if (err) { reject(err); // If there's an error during writing, reject the promise } ffmpegProcess.stdin.end(); // End the stdin stream after writing }); });}
// Menggunakan fungsi konversi sebelum mengonversi ke MP3async function convertVideoToMp3(videoBuffer) { try {index.js+12-3