Search code examples
javascriptpythonffmpegbotswhatsapp

sending video issue whatsapp-web.js


I'm trying to send an mp4 video as a sticker but i get an error, here's my code

client.on("message", (message) => {
    const media = MessageMedia.fromFilePath("./vid.mp4");
    client.sendMessage(message.from, media, { sendMediaAsSticker: true });
}

but I get this error

handleExit(new Error('ffmpeg exited with code ' + code));
                     ^

Error: ffmpeg exited with code 1: pipe:0: Invalid data found when processing input
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished
Conversion failed!

its working with other mp4 files but with this one it doesnt, this is a good working mp4 file I generated with ffmpeg using the concat method.


Solution

  • You just need to specify your chrome.exe path when creating your session.

    My solution on windows:

       const client = new Client({
            puppeteer: {
                executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
            }
        });
    

    See the link: https://wwebjs.dev/guide/handling-attachments.html#caveat-for-sending-videos-and-gifs

    also on: https://github.com/pedroslopez/whatsapp-web.js/issues/1834