问题
I installed fluent-ffmpeg with npm install fluent-ffmpeg
and verified its present in the node-modules. There is no error if I include it in the server var ffmpeg = require('fluent-ffmpeg');
But when I use it to convert a .gif
file in the directory to .mp4
it throws an error : Error: Cannot find ffmpeg
My code :
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var ffmpeg = require('fluent-ffmpeg');
var proc = new ffmpeg({ source: '/uploads/myfile.gif' })
.usingPreset('podcast')
.saveToFile('/uploads/mynewfile.mp4', function(stdout, stderr) {
console.log('file has been converted succesfully');
});
What am I doing wrong? I want to convert the .gif
to .mp4
回答1:
The error is that node-fluent can't find ffmpeg, use which
to get the path of ffmpeg, and add this line:
ffmpeg.setFfmpegPath('Path\\to\\ffmpeg');
来源:https://stackoverflow.com/questions/43176748/unable-to-convert-files-with-fluent-ffmpeg