gifshot icon indicating copy to clipboard operation
gifshot copied to clipboard

How to use gifshot to create animated gif from frames(base64 img) on NodeJS?

Open goodwin74 opened this issue 5 years ago • 6 comments

How to use gifshot to create animated gif from frames(base64 img) on NodeJS? Now print error: Canvas elements are not supported in your browser

var express = require('express');
var gifshot = require('gifshot');
var app = express();
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded(({ limit: '200mb', extended: true, parameterLimit: 100 }));

app.post('/', urlencodedParser, function(req,res){
        var imgFramesBase64 = JSON.parse(req.body.images);
        gifshot.createGIF({
        images: imgFramesBase64,
        interval: 0.04,
        numFrames: 10,
        frameDuration: 1,
        gifWidth: 200,
        gifHeight: 200,
        sampleInterval: 10,
        numWorkers: 2
    },function(obj) {
        if(!obj.error) {
            res.send(obj.image);
        } else {
            res.send(obj.errorMsg);
        }
    });

});

app.listen(3333);

goodwin74 avatar Dec 08 '19 15:12 goodwin74

Did you make any progress on that? I also would like to move the heavy lifting to the server.

davidseek avatar Mar 19 '20 20:03 davidseek

Did you make any progress on that? I also would like to move the heavy lifting to the server.

I chose a different way! I send frames from canvas to the server, and on the server I send them to ffmpeg :)

goodwin74 avatar Mar 19 '20 22:03 goodwin74

Did you make any progress on that? I also would like to move the heavy lifting to the server.

I chose a different way! I send frames from canvas to the server, and on the server I send them to ffmpeg :)

Yeah I'm still busy on this... I have now a decent GIF, but my ffmpeg from base64 gif to .mov results in End of file and frustrates me.

Care to share your gif to mp4 solution?

davidseek avatar Mar 19 '20 22:03 davidseek

Did you make any progress on that? I also would like to move the heavy lifting to the server.

I chose a different way! I send frames from canvas to the server, and on the server I send them to ffmpeg :)

Yeah I'm still busy on this... I have now a decent GIF, but my ffmpeg from base64 gif to .mov results in End of file and frustrates me.

Care to share your gif to mp4 solution?

My goal was to make a GIF animation from images. So I don’t know how to make MP4 from GIF animation.

goodwin74 avatar Mar 19 '20 23:03 goodwin74

Did you make any progress on that? I also would like to move the heavy lifting to the server.

I chose a different way! I send frames from canvas to the server, and on the server I send them to ffmpeg :)

Are you able to share your solution?

jenzushsu avatar Nov 24 '20 16:11 jenzushsu

Did you make any progress on that? I also would like to move the heavy lifting to the server.

I chose a different way! I send frames from canvas to the server, and on the server I send them to ffmpeg :)

Are you able to share your solution?

Everything is very simple. With an Ajax POST (stuffing them into formdata js), I send a few frames to the server. Taking with PHP (using move_uploaded_file) I copy them to the folder. And then I use ffpmeg on the server to collect all the pictures into animation (for example: ffmpeg -f image2 -framerate 10 -i thumb /% 001d.jpg -vf scale = 480x240 out.gif)

goodwin74 avatar Nov 24 '20 17:11 goodwin74