node.js

NodeJs - Fluent-FFMPEG cannot find FFMPEG


Situation:

Run mp3-to-video with fluent-ffmpeg and ffmpeg on windows and nodejs. command used to startup server: nodemon server.js When starting up, it executes mp3-to-video function. Then calls fluent-ffmpeg and i debugged it down to the line where fluent-ffmpeg cannot find my ffmpeg package. I did add a couple of system variables. FFMPEG_PATH is included, PATH is included, and all the different directories like ffmpeg\ and ffmpeg\lib\

I dont know what to do.. I get this error:

Error: Cannot findd ffmpeg
    at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\processor.js:136:22
    at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\capabilities.js:123:9
    at C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:421:16
    at next (C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:5302:29)
    at C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:906:16
    at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\capabilities.js:116:11
    at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\utils.js:223:16
    at F (C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:68:16)
    at E (C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:80:29)
    at C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:89:16

Solution

  • EvilBurrito saved the day on this one. Just wanted to add, make sure use this require:

    const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
    const ffmpeg = require('fluent-ffmpeg');
    ffmpeg.setFfmpegPath(ffmpegPath);