Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fluent-ffmpeg thumbnail creation error

i try to create a video thumbnail with fluent-ffmpeg here is my code

var ffmpeg = require('fluent-ffmpeg');

exports.thumbnail = function(){
    var proc = new ffmpeg({ source: 'Video/express2.mp4',nolog: true })
    .withSize('150x100')
    .takeScreenshots({ count: 1, timemarks: [ '00:00:02.000' ] }, 'Video/', function(err, filenames) {
    console.log(filenames);
    console.log('screenshots were saved');
  });
}

but i keep getting this error

  "mate data contains no duration, aborting screenshot creation"

any idea why,

by the way am on windows, and i put the ffmpeg folder in c/ffmpeg ,and i added the ffmpeg/bin in to my environment varable, i dont know if fluent-ffmpeg need to know the path of ffmpeg,but i can successfully create a thumbnail with the code below

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

please help me!!!

like image 657
paynestrike Avatar asked Oct 29 '12 02:10

paynestrike


1 Answers

I think the issue can be caused by the .withSize('...') method call. The doc says:

It doesn't interract well with filters. In particular, don't use the size() method to resize thumbnails, use the size option instead.

And the size() method is an alias of withSize().

Also - but this is not the problem in your case - you don't need to set either the count and the timemarks at the same time. The doc says:

count is ignored when timemarks or timestamps is specified.

Then you probably could solve with:

const ffmpeg = require('fluent-ffmpeg');

exports.thumbnail = function(){
    const proc = new ffmpeg({ source: 'Video/express2.mp4',nolog: true })
    .takeScreenshots({ timemarks: [ '00:00:02.000' ], size: '150x100' }, 'Video/', function(err, filenames) {
    console.log(filenames);
    console.log('screenshots were saved');
  });
}

Have a look at the doc: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#screenshotsoptions-dirname-generate-thumbnails

like image 118
menestrello Avatar answered Nov 15 '22 00:11

menestrello