Meteor.JS CollectionFS Video to Image Thumbnails (Graphics Magick)
Asked Answered
P

1

7

I am working on one Meteor App where I am using CollectionFS to upload Files.

I am able to upload and generate thumbnails for Images.

But my Issue is : How should I create thumbnails for Videos?

I can see that it is possible via command line: https://superuser.com/questions/599348/can-imagemagick-make-thumbnails-from-video

But how can I apply this to my Meteor code.

Here is what I am doing:

VideoFileCollection = new FS.Collection("VideoFileCollection", {
stores: [
  new FS.Store.FileSystem("videos", {path: "/uploads/videos"}),
  new FS.Store.FileSystem("videosthumbs", {path: "/uploads/videosthumbs",
    beforeWrite: function(fileObj) {
      // We return an object, which will change the
      // filename extension and type for this store only.
      return {
        extension: 'png',
        type: 'image/png'
      };
    },
    transformWrite: function(fileObj, readStream, writeStream) {
      gm(readStream, fileObj.name()).stream('PNG').pipe(writeStream);

    }
  })
]
});

What is happening here that video is getting Uploaded to "videos" folder and one PNG is created under "videosthumbs" with 0 Bytes and thumbnail is not getting generated.

I have also read at : https://github.com/aheckmann/gm#custom-arguments

that we can use : gm().command() - Custom command such as identify or convert

Can Anybody advise me on what can be done to handle this situation?

Thanks and Regards

Prairial answered 27/8, 2015 at 9:8 Comment(0)
B
1

Checked the link that you have added and here is a rough solution that might help you

ffmpeg -ss 600 -i input.mp4 -vframes 1 -s 420x270 -filter:v 'yadif' output.png

Here is a function that i have made.

var im = require('imagemagick');

var args = [
    "ffmpeg", "-ss", "600", "-i", "input.mp4", "-vframes", " 1", "-s", "420x270", "-filter:v", "'yadif'", "output.png"
    ];

// Function to convert and 
im.convert(args, function(err) 
if (err) throw err;
});
Batson answered 27/8, 2015 at 9:40 Comment(1)
Thanks, I have tried it but still unable to rectify this issuePrairial

© 2022 - 2024 — McMap. All rights reserved.