1

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
Schüler
  • 512
  • 4
  • 10
  • 25
  • Possible duplicate of [how to generate video thumbnail in node.js?](https://stackoverflow.com/questions/13079742/how-to-generate-video-thumbnail-in-node-js) – molaga Mar 05 '19 at 06:41
  • @bar.m I can't use socket.io in my project – Schüler Mar 05 '19 at 06:46
  • I really can't see how socket.io is related to the action of taking a screenshot from within a video. It seems like you are missing `ffmpeg` in your machine – molaga Mar 05 '19 at 06:51
  • @bar.m second that. https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#ffmpeg-and-ffprobe – Eric Wong Mar 05 '19 at 07:31
  • Did you check if `ffmpeg` is installed in your machine? Because `fluent-ffmpeg` **requires** `ffmpeg >= 0.9` – asendjasni Mar 05 '19 at 10:44

2 Answers2

1

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

Sinandro
  • 2,426
  • 3
  • 21
  • 36
1

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');
  });
zkhan
  • 81
  • 2