Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 745
jansmolders86 Avatar asked Jun 25 '26 12:06

jansmolders86


1 Answers

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){
like image 122
jansmolders86 Avatar answered Jun 29 '26 07:06

jansmolders86



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!