1

I am trying to convert a .mp4 file to .gif using NPM packages, but nothing seems to be working.

I tried using gifski binary package (NPM) for this, but no luck. It says its a binary package and you can use it by child_process.spawn() or similar. I installed it with -g (global) flag and seems like its not recognized even with global flag. Not sure If you can set PATH or anything. Let me know if its possible.

As for the other tries, I used gify and its just not doing anything (no file or error).

I am getting the .mp4 file from puppeteer-lottie NPM package. Here's my code, if needed for testing:

const renderLottie = require('puppeteer-lottie');

await renderLottie({ animationData: data, output: 'example.mp4', width: 640 });

animationData: Sticker JSON

I am pretty sure that there are much easier ways to do this, but I am just using complex ones. I just want .mp4 to .gif at the end.

Thanks for your time.

1 Answers1

3

For those of you who are still trying to find solution, I finally found it.

We just use ffmpeg with child_process.exec(). No need to install anything.

const { exec } = require("child_process");

exec("ffmpeg -i input.mp4 -qscale 0 output.gif");

input is your mp4 file that you want to convert, and output is your result gif file.

Source: Conrad Lotz's answer