Schüler
Schüler

Reputation: 542

How to generate video thumbnail in NodeJs?

I am trying to generate video thumbnail but I am not getting an idea how to do that, I tried using fluent-ffmpeg & Video-thumbnail libraries but I don't know how to use them. Please, someone, help me Note I cannot usersocket.io in my project

I have tried this

const ffmpeg = require('fluent-ffmpeg');
const ffmpeg_static = require('ffmpeg-static');    
 ffmpeg(req.file.path)
          .screenshots({
            timestamps: [0.0],
            filename: 'xx.png',
            folder: upload_folder
          }).on('end', function() {
            console.log('done');
          });

getting this error

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find ffmpeg

Upvotes: 1

Views: 7026

Answers (2)

zkhan
zkhan

Reputation: 81

I know this is a bit late, but I believe you have to set the ffmpeg path when you use ffmpeg-static. So your updated code would look something like:

const ffmpeg = require('fluent-ffmpeg');
const ffmpeg_static = require('ffmpeg-static');   
ffmpeg(req.file.path)
  .setFfmpegPath(ffmpeg_static)
  .screenshots({
    timestamps: [0.0],
    filename: 'xx.png',
    folder: upload_folder
  }).on('end', function() {
    console.log('done');
  });

Upvotes: 1

Sinandro
Sinandro

Reputation: 2686

You should install ffmpeg >= 0.9 on the host machine in order to use fluent-ffmpeg package.

Upvotes: 1

Related Questions