Created
January 4, 2019 02:40
-
-
Save camel113/7d3a8072ba4a7407a42702369800d0a9 to your computer and use it in GitHub Desktop.
Compress Video with FFmpeg
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
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