Skip to content

Instantly share code, notes, and snippets.

@camel113
Created January 4, 2019 02:40
Show Gist options
  • Save camel113/7d3a8072ba4a7407a42702369800d0a9 to your computer and use it in GitHub Desktop.
Save camel113/7d3a8072ba4a7407a42702369800d0a9 to your computer and use it in GitHub Desktop.
Compress Video with FFmpeg
const compressVideo = (req,res,next) => {
var cmd = 'ffmpeg';
var args = [
'-i', constants.rawVideosPath + req.file.filename,
'-c', 'copy',
'-vcodec', 'libx264',
'-crf', '24',
'-an', constants.processedVideosPath + req.file.filename
];
var proc = spawn(cmd, args);
proc.stdout.on('data', function(data) {
console.log(data);
});
proc.stderr.on('data', function(data) {
console.log(data);
});
proc.on('close', function() {
console.log('finished');
next()
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment