Created
August 21, 2016 21:48
-
-
Save zehfernandes/76a8a13fde9398c81b54abb22345475a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ffmpeg = require('fluent-ffmpeg'); | |
const moment = require('moment'); | |
var myArgs = process.argv.slice(2); | |
//Convert Video | |
var filePath = myArgs[0]; | |
var startTime = moment(myArgs[1], "HH:mm:ss.SSS"); | |
var endTime = moment(myArgs[2], "HH:mm:ss.SSS"); | |
var fileOutput = myArgs[3]; | |
var diff = moment.duration(startTime.diff(endTime)); | |
if (diff < 0) { | |
diff = Math.abs(diff); | |
} | |
var d = moment.utc(diff).format("HH:mm:ss.SSS"); | |
console.log(d); | |
ffmpeg(filePath) | |
.setStartTime(startTime.format("HH:mm:ss.SSS")) | |
.setDuration(d) | |
.output(fileOutput) | |
.on('end', function(err) { | |
if(!err) | |
{ | |
console.log('conversion Done'); | |
} | |
}) | |
.on('error', function(err){ | |
console.log('error: ', +err); | |
}).run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment