我想使用fluent-ffmpeg
中的NodeJS
创建视频。我的目标是使用一个图像创建视频。到目前为止,我所做的是:
var express = require('express')
var router = express.Router()
const ffmpeg = require('fluent-ffmpeg');
router.get('/test', function (req, res) {
// make sure you set the correct path to your video file
var proc = ffmpeg('http://localhost:3000/images/image.jpg')
// loop for 5 seconds
.loop(5)
// using 25 fps
.fps(25)
// setup event handlers
.on('end', function () {
console.log('file has been converted succesfully');
})
.on('error', function (err) {
console.log('an error happened: ' + err.message);
console.log(' error code is : ' + err.code);
})
// save to file
.save('http://localhost:3000/video/image-cdo.mp4');
})
module.exports = router;
运行此命令时,出现以下错误结果:
GET /mixer/ 200 6.364 ms - 13
GET /images/image.jpg 206 3.355 ms - 311484
GET /images/image.jpg 206 4.041 ms - 311484
GET /images/image.jpg 206 3.509 ms - 311484
GET /images/image.jpg 206 1.225 ms - 311484
GET /images/image.jpg 206 0.742 ms - 311484
GET /images/image.jpg 206 0.655 ms - 311484
GET /images/image.jpg 206 0.695 ms - 311484
GET /images/image.jpg 206 0.691 ms - 311484
GET /images/image.jpg 206 0.676 ms - 311484
GET /images/image.jpg 206 0.648 ms - 311484
GET /images/image.jpg 206 0.663 ms - 311484
GET /images/image.jpg 206 0.886 ms - 311484
GET /images/image.jpg 206 0.598 ms - 311484
GET /images/image.jpg 206 0.532 ms - 311484
GET /images/image.jpg 206 0.547 ms - 311484
GET /images/image.jpg 206 0.630 ms - 311484
GET /images/image.jpg 206 0.560 ms - 311484
GET /images/image.jpg 206 0.536 ms - 311484
POST /video/image-cdo.mp4 404 30.270 ms - 1212
发生错误:ffmpeg以代码1退出:无法写入标头 对于输出文件#0(编解码器参数不正确?):无效的参数 初始化输出流0:0时出错 转换失败!
error code is : undefined
有人可以帮我吗:)
"dependencies": {
"fluent-ffmpeg": "^2.1.2",
}
和NodeJS v12.13.0