小编Vis*_*hnu的帖子

在 ffmpeg 中生成屏幕截图花费太长时间

我正在使用 ffmpeg 生成屏幕截图。它生成缩略图,但花费的时间太长(超过 2 分钟)。

我已经提到了这个链接

使用 FFmpeg 从大电影创建缩略图需要太长时间

但我必须在我的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 分钟。我该如何解决这个问题。

ffmpeg node.js

5
推荐指数
1
解决办法
3672
查看次数

在multer中使用文件过滤器时如何捕获错误?

我已经搜索过但我找不到确切的解决方案..当我上传图像时,它应该只允许 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)

file node.js filefilter multer

2
推荐指数
1
解决办法
3012
查看次数

标签 统计

node.js ×2

ffmpeg ×1

file ×1

filefilter ×1

multer ×1