Hello there, I have this code for convert from video to a sticker this is my code:
const media = await quotedMsg.downloadMedia();
// Save video to a file
const videoPath = 'video.mp4';
const webpPath = 'output.webp';
fs.writeFileSync(videoPath, media.data, 'base64');
const maxDuration = 4;
ffmpeg(videoPath)
.setDuration(maxDuration)
.toFormat('webp')
.save(webpPath)
.on('end', async () => {
const webpData = fs.readFileSync(webpPath).toString('base64');
const media = new MessageMedia('image/webp', webpData);
try {
await msg.reply(media, null, { sendMediaAsSticker: true });
fs.unlinkSync(videoPath);
fs.unlinkSync(webpPath);
} catch (error) {
console.error('Error sending sticker ', error);
}
});
But i got the error :
Error sending sticker Error: Evaluation failed: a
at ExecutionContext._evaluateInternal (/home/hap/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (/home/hap/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async Client.sendMessage (/home/hap/node_modules/whatsapp-web.js/src/Client.js:869:28)
What is the problem here? sometimes it works and sometimes not in most cases it doesnt work..