我正在尝试发送 mp4 视频作为贴纸,但出现错误,这是我的代码
client.on("message", (message) => {
const media = MessageMedia.fromFilePath("./vid.mp4");
client.sendMessage(message.from, media, { sendMediaAsSticker: true });
}
但我收到此错误
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!
它可以与其他 mp4 文件一起使用,但对于这个文件却不能,这是我使用 concat 方法使用 ffmpeg 生成的一个很好的工作 mp4 文件。
您只需在创建会话时指定 chrome.exe 路径即可。
我在Windows上的解决方案:
const client = new Client({
puppeteer: {
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
}
});
请参阅链接:https://wwebjs.dev/guide/handling-attachments.html#caveat-for-sending-videos-and-gifs
另见:https://github.com/pedroslopez/whatsapp-web.js/issues/1834
大家好,希望你们做得很棒!我需要帮助 这是我的发送文件代码 wwebJS :
client.on('file', async (destnation, file) => {
try {
// Check if the file exists
if (fs.existsSync(file.path)) {
const media = MessageMedia.fromFilePath(file.path);
await client.sendMessage(destnation, media);
console.log('File sent successfully', media,destnation);
} else {
console.error('File not found:',file);
}
} catch (error) {
console.error('Error sending file:', error);
}
});
这段代码工作正常,但没有将文件发送到目标号码,希望你能帮助我解决这个问题