how to generate video thumbnail in node.js?

paynestrike picture paynestrike · Oct 26, 2012 · Viewed 27.9k times · Source

I am building an app with node.js, I successfully uploaded the video, but I need to generate a video thumbnail for it. Currently I use node exec to execute a system command of ffmpeg to make the thumbnail.

   exec("C:/ffmpeg/bin/ffmpeg -i Video/" + Name  + " -ss 00:01:00.00 -r 1 -an -vframes 1 -f mjpeg Video/" + Name  + ".jpg")

This code is coming from a tutorial from http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-resumable-video-uploade-in-node-js/

the code above did generate a jpg file but it's not a thumbnail but a video screen shot, I wonder is there any other method to generate video thumbnail, or how to exec the ffmpeg command to make a real thumbnail (resized), and I prefer png file.

Answer

Risadinha picture Risadinha · Jun 18, 2014

Reference to GitHub fluent-ffmpeg project.

Repeating example from original StackOverflow answer:

var proc = new ffmpeg('/path/to/your_movie.avi')
  .takeScreenshots({
      count: 1,
      timemarks: [ '600' ] // number of seconds
    }, '/path/to/thumbnail/folder', function(err) {
    console.log('screenshots were saved')
  });