I want to cut a video in specific start & end time & save it. I am able to copy a full video but cant understand to how to cut specific time of that video by Node JS.
Video copy code :
ffmpeg('public/'+req.body.video)
.on('end', function(err) {
if(!err)
{
console.log('Done');
}
})
.on('error', function(err){
console.log('error: '+err);
callback(err);
}).run();
I have found a solution. Here it is :
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
const ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)
ffmpeg('video.mp4')
.setStartTime('00:00:03')
.setDuration('10')
.output('video_out.mp4')
.on('end', function(err) {
if(!err) { console.log('conversion Done') }
})
.on('error', err => console.log('error: ', err))
.run()
Note that you should install these two:
npm install @ffmpeg-installer/ffmpeg
npm install fluent-ffmpeg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With