Skip to content

Instantly share code, notes, and snippets.

@samthomson
Created April 22, 2017 08:32
Show Gist options
  • Save samthomson/b09acf3cb9de0305c12f965664709730 to your computer and use it in GitHub Desktop.
Save samthomson/b09acf3cb9de0305c12f965664709730 to your computer and use it in GitHub Desktop.
ffmpeg video conversion
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