问题描述
目前我正在处理一些视频上传,所以我想在上传视频的过程中创建一个缩略图..我安装了 fluent-ffmpeg 包,但在第一次运行时出现错误 Error: cannnot find ffprobe 然后我将 ffmpeg 改为 ffmpeg.ffprobe 然后我得到了 undefined .on .. 这是我用于视频上传的完整代码:
const multer = require('multer');
const uuid = require('uuid/v1');
const ffmpeg = require('fluent-ffmpeg');
const MIME_TYPE_MAP = {
'video/MPEG-4': 'MPEG-4','video/mpeg-4': 'mpeg-4','video/mp4': 'mp4','video/MP4': 'MP4'
};
const videoUpload = multer({
limits: 10000000,storage: multer.diskStorage({
destination: (req,file,cb) => {
cb(null,'uploads/videos');
},filename: (req,cb) => {
const ext = MIME_TYPE_MAP[file.mimetype];
const currentfilename = uuid() + '.' + ext;
cb(null,currentfilename);
ffmpeg.ffprobe(`uploads/videos/${currentfilename}`)
.on('end',function() {
console.log('Screenshots taken');
})
.on('error',function(err) {
console.error(err);
})
.screenshots({
count: 1,folder: 'uploads/videos/thumb',filename: uuid() + '_screenshot.' + ext
});
}
}),fileFilter: (req,cb) => {
const isValid = !!MIME_TYPE_MAP[file.mimetype];
let error = isValid ? null : new Error('Invalid mime type!');
cb(error,isValid);
}
});
module.exports = videoUpload;
解决方法
问题是 pipeline {
agent any
stages {
stage("ARCHIVE DIST ARTIFACTS") {
steps{
archiveArtifacts artifacts: 'dist',followSymlinks: false
}
}
stage("COPY DIST") {
steps{
copyArtifacts fingerprintArtifacts: true,projectName: 'ev-frontend',target: '/opt/front-end'
}
}
}
}
为您提供了与 fluent-ffmpeg
一起使用的功能,但它没有为您提供(因此您必须手动安装它们)。其他方法是再安装 2 个库 ffprobe and ffmpeg
和 @ffmpeg-installer/ffmpeg
并将 thr 路径传递到 @ffprobe-installer/ffprobe
。Here