I'm trying to generate thumbnail of mp4 video files on a node server and I'm using fluent-ffmpeg. My goal is to be able to send it to the frontend. I thought that I'm able to convert the video file but when I try to load and preview it on the frontend, nothing really shows up. Here is my code
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
const ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)
let thumbnail
const outputPath = `${url.replace('.mp4', '.png')}`
await new Promise((resolve, reject) => {
ffmpeg(url)
.seekInput('0:01')
.size('150x150')
.frames(1)
.output(outputPath)
.on('end', () => {
const thumbnailPath = outputPath
console.log(thumbnailPath, 'thumbnailPath')
resolve(thumbnailPath)
})
.on('error', error => {
console.error('Error generating thumbnail', error)
reject(error)
})
.run()
})
.then(thumbnailPath => {
thumbnail = thumbnailPath
console.log(thumbnail, 'thumbnail')
})
.catch(error => {
console.error('Error generating thumbnail:', error)
Sentry.captureException(error)
})
}
The output of this is:
'https://sample.nyc3.digitaloceanspaces.com/uploads/300705/1899672-sample-file.png'
and this is what is being received on the frontend.
Anybody have any tips to fix this? Not sure what it's going wrong here. Thank you!