Created
April 22, 2017 08:32
-
-
Save samthomson/b09acf3cb9de0305c12f965664709730 to your computer and use it in GitHub Desktop.
ffmpeg video conversion
This file contains 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
var start = new Date(); | |
var ffmpeg = require('fluent-ffmpeg'); | |
var path = require('path'); | |
const outputFolder = './out'; | |
let outputName = 'gopro'; | |
let outputPath = path.join(outputFolder, outputName); | |
let inputPath = './seed-videos/MAH04656.MP4' | |
inputPath = './seed-videos/GOPR0426.MP4' | |
let pMP4 = new Promise( | |
(resolve, reject) => { | |
var startMP4 = new Date(); | |
ffmpeg(inputPath) | |
.output(`${outputPath}.mp4`) | |
.on('end', function() { | |
resolve(new Date() - startMP4); | |
}) | |
.run(); | |
} | |
); | |
let pWEBM = new Promise( | |
(resolve, reject) => { | |
var startWEBM = new Date(); | |
ffmpeg(inputPath) | |
.output(`${outputPath}.webm`) | |
.on('end', function() { | |
resolve(new Date() - startWEBM); | |
}) | |
.run(); | |
} | |
); | |
let pAVI = new Promise( | |
(resolve, reject) => { | |
var startAVI = new Date(); | |
ffmpeg(inputPath) | |
.output(`${outputPath}.avi`) | |
.on('end', function() { | |
resolve(new Date() - startAVI); | |
}) | |
.run(); | |
} | |
); | |
Promise.all([pMP4, pWEBM, pAVI]).then(values => { | |
console.log(values); | |
var end = new Date() - start; | |
console.log("total time: " + end); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment