Created
August 7, 2019 16:49
-
-
Save Talento90/885927ecc3663bd00add337fd7588851 to your computer and use it in GitHub Desktop.
Generate Thumbnail from video using Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const | |
ffmpegPath = require("@ffmpeg-installer/ffmpeg").path, | |
ffprobePath = require("@ffprobe-installer/ffprobe").path, | |
ffmpeg = require("fluent-ffmpeg"); | |
ffmpeg.setFfprobePath(ffprobePath); | |
ffmpeg.setFfmpegPath(ffmpegPath); | |
async function generateThumbnail(videoPath) { | |
return ffmpeg(videoPath) | |
.thumbnail({ | |
timestamps: ['50%'], | |
filename: 'thumbnail.png', | |
size: '320x240', | |
}); | |
} | |
generateThumbnail('sample-video.mp4') | |
.then(() => console.log('Thumnail generated successfully')) | |
.catch((err) => console.error(err)); |
thanks
Thanks for this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we use base64 in place of mp4 file