我正在使用 ffmpeg 生成屏幕截图。它生成缩略图,但花费的时间太长(超过 2 分钟)。
我已经提到了这个链接
但我必须在我的nodejs代码中设置
ffmpeg(main_folder_path)
.on('filenames', function(filenames) {
console.log('Will generate ' + filenames.join(', '))
})
.on('end', function() {
console.log('Screenshots taken');
})
.screenshots({
pro_root_path+'public/uploads/inspection/'+req.body.clientID+'/images/'
timestamps: [30.5, '20%', '01:10.123'],
filename: 'thumbnail-at-%s-seconds.png',
folder: pro_root_path+'public/uploads/inspection/'+req.body.clientID+'/images/',
size: '320x240'
});
Run Code Online (Sandbox Code Playgroud)
我使用了时间戳,但即使它花费了超过 2 分钟。我该如何解决这个问题。
我已经搜索过但我找不到确切的解决方案..当我上传图像时,它应该只允许 jpg、jpeg、gif、png ..如果有任何其他文件,它应该在 UI 中显示消息。我使用了以下代码
var upload = multer({ storage: storage,
fileFilter: function (req, file, cb) {
var ext = path.extname(file.originalname);
if(ext !== '.png' && ext !== '.jpg' && ext !== '.gif' && ext !== '.jpeg') {
return cb(new Error('Wrong extension type'));
// if(Error){
// console.log("error file type")
// }
}
cb(null, true)
}
});
Run Code Online (Sandbox Code Playgroud)
如果我尝试上传 pic 而不是 jpeg,jpg,png,git 它显示错误..但是如何在我的应用程序页面本身中显示为消息
Error: Wrong extension type
at fileFilter (D:\Vishnu\octopus new\app\routes.js:912:24)
at wrappedFileFilter (D:\Vishnu\octopus new\node_modules\multer\index.js:44:7)
at Busboy.<anonymous> (D:\Vishnu\octopus new\node_modules\multer\lib\make-middleware.js:114:7)
at emitMany (events.js:127:13)
at …
Run Code Online (Sandbox Code Playgroud)