问题描述
我正在使用 node.js 构建一个应用程序,我成功上传了视频,但我需要为其生成视频缩略图.目前我使用 node exec 执行 ffmpeg 的系统命令来制作缩略图.
I am building an app with node.js, I successfully uploaded the video, but I need to generate a video thumbnail for it. Currently I use node exec to execute a system command of ffmpeg to make the thumbnail.
exec("C:/ffmpeg/bin/ffmpeg -i Video/" + Name + " -ss 00:01:00.00 -r 1 -an -vframes 1 -f mjpeg Video/" + Name + ".jpg")
上面的代码确实生成了一个jpg文件,但它不是缩略图而是视频屏幕截图,我想知道有没有其他方法可以生成视频缩略图,或者如何执行ffmpeg命令来制作真正的缩略图(调整大小),我更喜欢 png 文件.
the code above did generate a jpg file but it's not a thumbnail but a video screen shot, I wonder is there any other method to generate video thumbnail, or how to exec the ffmpeg command to make a real thumbnail (resized), and I prefer png file.
推荐答案
通过向命令添加 -s widthxheight 选项来调整大小.
Resize by adding a -s widthxheight option to your command.
这篇关于如何在 node.js 中生成视频缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!