node.jsffmpegfluent-ffmpegvideo-thumbnails

Creating Thumbnail of Video from screenshot using Fluent FFMPEG in Node JS


I am using Node JS to create API and have used Fluent- FFMPEG to take the screenshot once the video is uploaded. I am getting the below error. I found many answers for this error but none worked.Fluent-ffmpeg is installed. I have attached the package.json sample code, too. Also the snippet of the ffmpeg code.

Do I have to install ffmpeg on my windows to make this api to work ? do I have to set any environment variables ?

Error

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

Error: Cannot find ffprobe
at D:\project\node_modules\fluent-ffmpeg\lib\ffprobe.js:145:31
at D:\project\node_modules\fluent-ffmpeg\lib\capabilities.js:194:9

Package.json

"express": "^4.17.1",
"express-validator": "^6.6.1",
"fluent-ffmpeg": "^2.1.2", // it has been installed
"i18n": "^0.8.4",

Code

const ffmpeg = require('fluent-ffmpeg');
await ffmpeg(getFileFromLocal)
                .screenshots({
                    count: 1,
                    filename: fileName,
                    folder: folderName
                }).on('end', async function () {
                    //further code
                })
            return;

Solution

  • I figured out why it wasn't working. I was missing with 2 things.

    1. FFmpeg is not installed. I installed from this Link. (Note: Fluent-ffmpeg requires FFmpeg to be installed in your OS. Without FFmpeg, Fluent-ffmpeg will not work.)
    2. Set Environment Variable. Follow this tutorial to set the environment variable.

    After doing the above two task, I was successfully able to create screenshots of videos.