pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.49k stars 3.45k forks source link

Error Converting Specific Video to Sticker (Error: Evaluation failed: a) #2666

Closed Lucas-Angelo closed 5 months ago

Lucas-Angelo commented 7 months ago

Is there an existing issue for this?

Describe the bug

I am encountering an issue in WhatsApp Web JS when trying to convert a specific video into a sticker. The error occurs only with this video and is visible in the console. The video: https://user-images.githubusercontent.com/49598959/208319245-65451134-ef4a-49cb-84dc-55ec6e801ab5.mp4

The error: image

pyrobot        | Error: Evaluation failed: a
pyrobot        |     at ExecutionContext._evaluateInternal (/usr/pyrobot/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
pyrobot        |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
pyrobot        |     at async ExecutionContext.evaluate (/usr/pyrobot/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
pyrobot        |     at async Client.sendMessage (/usr/pyrobot/node_modules/whatsapp-web.js/src/Client.js:686:28)
pyrobot        |     at async Object.sticker (/usr/pyrobot/src/functions/Commands.js:359:9

Expected behavior

The bot should process the video and return a corresponding sticker.

Steps to Reproduce the Bug or Issue

  1. Launch the bot.
  2. Open a chat where the bot is active.
  3. Send the problematic video in the chat with the !sticker command in the captions. Here is the link to the video: Video Link.

Relevant Code

    let mediaMessage;
    if (msg.type == "video") mediaMessage = await msg.downloadMedia();
    else if (msg.type == "image") mediaMessage = await msg.downloadMedia();

    if (mediaMessage) {
        await chat.sendMessage(mediaMessage, {
            sendMediaAsSticker: true,
            stickerName: customName || "lcs2001",
            stickerAuthor: "lucasangelo.com",
        });
    } else if (customMediaMessage) {
        await chat.sendMessage(customMediaMessage, {
            sendMediaAsSticker: true,
            stickerName: customName || "lcs2001",
            stickerAuthor: "lucasangelo.com",
        });
    } else await chat.sendMessage("Error ;(")

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

OS: Linux on Docker (FROM node:16.14.0) Phone OS: iOS whatsapp-web.js version 1.23.0 WhatsApp Web version last Node.js Version 16.14.0

Additional context

Dockerfile:

FROM node:16.14.0

ENV DOCKER_ENV true

# Update and upgrade
RUN apt update -y && apt full-upgrade -y && apt-get dist-upgrade -y && apt autoremove -y && apt clean -y && apt autoclean -y

# Install dependency
RUN apt install apt-transport-https ca-certificates curl software-properties-common -y

# Install dependency
RUN apt-get update -y && apt-get install -y vim git bash inotify-tools dos2unix zip wget gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils

RUN apt-get update -y && apt-get install -y ffmpeg
RUN echo "ffmpeg version: " && ffmpeg -version

# Create destination directory
RUN mkdir -p /usr/pyrobot
WORKDIR /usr/pyrobot

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update -y \
    && apt-get install -y gnupg \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update -y \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
      --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*
RUN echo "Chrome version: " && google-chrome --version

# Install python3 and pip3
RUN apt-get update -y
RUN set -xe \
    && apt-get install -y python3-pip
RUN pip3 install --upgrade pip
RUN echo "Python version: " && python3 --version
RUN echo "Pip3 version: " && pip3 --version

# Install Pytorch
RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
RUN echo "Torch version: " && python3 -c "import torch; print(torch.__version__)"

# Install backgroundremover
RUN pip3 install backgroundremover

# Install Twitch-dl
COPY ./tools/twitch-dl.pyz .
RUN echo "Twitch-dl version: " && python3 twitch-dl.pyz

# Install Youtube-dl
RUN pip3 install --upgrade youtube-dl
RUN echo "Youtube-dl version: " && youtube-dl --version

# Install puppeteer so it's available in the container.
RUN npm i puppeteer

# Clear node
# RUN rm -rf ./node_modules
# RUN rm -rf package-lock.json

# Install app dependencies
COPY ./package.json .
RUN npm install -g nodemon
RUN npm install -g telegraf
RUN npm install
#COPY ./Injected.js /usr/pyrobot/node_modules/whatsapp-web.js/src/util/Injected.js

# Bundle app source
COPY . .
# convert from windows to linux
RUN find /usr/pyrobot -type f -print0 -not -path /usr/pyrobot/node_modules | xargs -0 -n 1 -P 4 dos2unix 

# to wait database image
COPY ./wait-for-it.sh /usr/wait-for-it.sh
RUN chmod +x /usr/wait-for-it.sh
marinisz commented 7 months ago

up, still a problem

guizombas commented 6 months ago

Up

777-victor commented 6 months ago

up

sergiooak commented 5 months ago

This is not a Wwebjs bug, this is because the output .webp is bigger than 1MB and default the default ffmpeg config was not able to generate the WEBP lower than 1MB

MikeyA-yo commented 2 months ago

This is not a Wwebjs bug, this is because the output .webp is bigger than 1MB and default the default ffmpeg config was not able to generate the WEBP lower than 1MB

my issue was referrenced with this, but my webp isn't even up to 100KB and yet i get some unknown fluent-ffmpeg error that i believs is from whatsapp-web.js