Reputation: 49
var fs = require('fs');
var ffmpeg = require('fluent-ffmpeg');
var outStream = fs.createWriteStream('output.mp4'); //output path
ffmpeg('input.mp4')
.duration(600) //trim
.on('error', function(err) {
console.log('An error occurred: ' + err.message);
})
.on('end', function() {
console.log('Processing finished !');
})
.pipe(outStream, { end: true });
I installed fluent-ffmpeg in my working directory, can anybody tell me what are the other requirements? I'm working on a windows machine.
Upvotes: 2
Views: 5297
Reputation: 31
This worked for me. Make sure you've ffmpeg installed in your machine properly. Check by running "ffmpeg" in command prompt.
const conv = new ffmpeg({ source: "sourcepath" });
conv
.setStartTime(2) //Can be in "HH:MM:SS" format also
.setDuration(10)
.on("start", function(commandLine) {
console.log("Spawned FFmpeg with command: " + commandLine);
})
.on("error", function(err) {
console.log("error: ", +err);
})
.on("end", function(err) {
if (!err) {
console.log("conversion Done");
}
})
.saveToFile("outputpath");
Upvotes: 3