Wa-automate-nodejs: Sending video

Created on 20 Nov 2019  路  13Comments  路  Source: open-wa/wa-automate-nodejs

Hi guys, anyone of you tried sending a video?

This is my code:

const fileBase64 = "data:video/mp4;base64,....";

await client.sendFile(
    to,
    fileBase64,
    "Video.mp4",
    "Video"
);

The message can be sent, but the message rendered as 'file' type instead of a 'video' message.
Image of Yaktocat

Most helpful comment

@HypedMind I've now also seen this behaviour with video. It will take some investigating.

All 13 comments

@HypedMind I've now also seen this behaviour with video. It will take some investigating.

WAPI.sendMessageWithThumb It can be useful, must be investigated

public async sendMessageWithThumb(base64Image: string, url: string, title: string, description: string, chatId: string, done?: string) {
    return await this.page.evaluate(
        ({ base64Image, url, title, description, chatId }) => {
            WAPI.sendSeen(chatId);
             WAPI.sendMessageWithThumb(thumb, url, title, description, chatId)
        },
        { base64Image, url, title, description, chatId }
    );
}

I did some finding on this, probably the web.whatsapp doesn't have the api available to send video as a 'video message', because using web.whatsapp in browser to send video also sends as a 'file message'.

@HypedMind this is not entirely the case because sending a video file (received through WhatsApp) on WhatsApp web, it works properly with the preview.

Edit: actually most videos are working now. Maybe there was a bugfix?

@smashah Yah the preview works fine. Probably WhatsApp decides that WhatsApp Web doesn鈥檛 need api to send video message, because only smartphone can capture video?

@HypedMind I've been sending some videos to my other number on whatsapp web. Preview only didnt work for one specific video (that was received and saved by sulla-hotfix sample a few days ago).

Just a thought: This may be due to user agent. My previous two comments were when testing on chrome whatsapp web. I tried with {headless:false} and i got this error message while sending a video with the chromium instance from puppeteer

image

Further Investigation:

image

Ok, I've got it working properly with the demo/index.ts

Because pupeteer does not have any codecs that means that it cannot process videos for whatsapp. Why is this just happening now? I'm guessing that because Whatsapp doesn't want to be dealing with all the videos coming through, it now requires some pre processing on the client (phone or web).

There's two ways to solve this.

  1. Fool whatsapp web into thinking it's been processed with puppeteer.
  2. Use an instance of chrome instead of chromium for puppeteer.

I have no clue right now to do number 1. But 2 works fine, all you need to do is tell sulla-hotfix where your chrome instance is. Here is the solution for my mac. If you're running this on a server, make sure chrome is installed.

create('session',{
  executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
}).then(client => start(client));

The good thing about this is that it will not require an update. However I have been testing with puppeteer dependency to latest version (don't think it should make much diff though).

@HypedMind @paramirez Let me know if this works for you.

I will update the documentation soon. It's kinda annoying but it's definitely a long term solution.

Thanks for bringing up the issue and helping with investigation!

Hey @smashah , sorry now only I have the time to check.

I just tried with your solution, however I can't get it to work, the message rendered as a 'file' message instead of a 'video' message.

Would you able to share the video file that you use?

My sulla.create:

var client = await sulla.create(session_id,
            {
                executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
            },
            customUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"
        );

My sendFile code:

await client.sendFile(
                {number},
                base64,
                "",
                ""
            );

My video file: http://s000.tinyupload.com/index.php?file_id=53242422432601226909

My base64 string: https://freetexthost.net/kHHzVgU

My chrome version: https://i.imgur.com/hbBwEVX.png

@HypedMind classic buck bunny. That file doesnt work for some reason. If you use the sample and send your sulla'd number a video it should work fine. Maybe it's because of the codec? Does this specific file work in whatsapp web itself? It doesn't work in my instance of whatsapp web desktop client or the in chrome.

This worked fine for me: http://4ksamples.com/elysium-2013-2160p-1-minute-sample-footage/

@smashah Turns out the video I used actually has issue. I got it working with other video files.

I was able to send out video as 'video message' in Ubuntu server.

This was how I did it:

  1. Install Chrome in Ubuntu following this tutorial: https://www.linuxbabe.com/ubuntu/install-google-chrome-ubuntu-16-04-lts

  2. Create sulla client using the executable path:

var client = await sulla.create(session_id,
            {
                executablePath: "/opt/google/chrome/chrome",
            }
        )
Was this page helpful?
0 / 5 - 0 ratings