A simple way of implementing FFmpeg regardless of OS
constffmpeg=require("ffmpeg-cli");ffmpeg.run("-version");console.log(ffmpeg.runSync("-version"));No need to install other programs as ffmpeg-cli will download and extract necessary binaries for your OS!
- MacOS ~ 64 bit
- Linux ~ 32/64 bit
- Windows ~
32/64 bit
Returns the path of FFmpeg executable
ffmpeg.path;// Ex: C:\Users\PotatoParser\Desktop\NodeJS\ffmpeg-cli\ffmpeg\win32x64\bin\ffmpeg.exeReturns the output from FFmpeg
ffmpeg.runSync(commands);// Ex: ffmpeg.runSync(`-i input.jpg -vf scale=320:240 output.png`);Returns a Promise
ffmpeg.run(commands);ffmpeg.run(commands).catch((error)=>{...});// Catch errorsffmpeg.run(commands).then((result)=>{...});// Only resultsffmpeg.run(commands).then((result)=>{...}).catch((error)=>{...});// Catches when errors foundRun to redownload (synchronously) ffmpeg files Returns true if download is successful
ffmpeg.forceDownload();