Node.js Fluent-FFMPEG Example to Create Screenshot Thumbnail of MP4 Video as PNG/JPEG Image Using Javascript Full Project For Beginners

 

 

Installation

 

 

npm i fluent-ffmpeg

 

 

 

I’m not a fan of the fluent-ffmpeg “screenshot” command. ffmpeg has a built-in screenshot capability, and it’s much more flexible. Most notably, it allows you to take advantage of ffmpeg’s ability to quickly seek on on the “input” rather than the “output”. (“Seeking on output” basically means that it will process every single frame between the start of the video and the one that you want to screenshot.)

Fortunately, fluent-ffmpeg allows you to use any command line parameters, by way of outputOptions. The following command would take a screenshot at the 15-minute mark. It takes about 1 second on my machine.

 

 

 

Without the command ‘-frames 1’, it would take a screenshot for every frame of the video.

As an illustration of just how powerful this can be, the following command makes consecutive sprited 5×5 images (25 images per file) of an entire video. Great for making thumbnails.

 

 

Leave a Reply