node.jspathffmpegbinaries

NodeJS: Set path to FFMPEG binaries for module Fluent-FFMPEG


I am building a application that uses the module node-fluent-ffmpeg. https://github.com/schaermu/node-fluent-ffmpeg

And I'm trying to package the ffmpeg binaries along with my application. I want to do this so (especially on Windows) the user does not have to install FFMPEG manually.

Sadly everything I've tried results in errors. I've tried the following:

  ffmpeg.setFfmpegPath   : Gives an error saying setFfmpegPath is not a method

and:

  proc.setFfmpegPath    : Gives a createproces error.

It seems I'm doing something wrong. Could someone point out my mistake. Thanks a lot.


Solution

  • I fix it! I did not know I had to include the binary itself in the path. So I made something like this:

      if(os.platform() === 'win32'){
         var ffmpegPath = './bin/ffmpeg/ffmpeg.exe'
     }else{
         var ffmpegPath = './bin/ffmpeg/ffmpeg'
     }
    
     proc = new ffmpeg({ source: movieUrl, nolog: true, timeout: FFMPEG_TIMEOUT })
     proc.setFfmpegPath(ffmpegPath)
     proc.addOptions(opts)
     proc.writeToStream(response, function(return_code, error){