Information about bundled ffmpeg?


#1

Hello there,

our applications makes heavy use of ffmpeg so we are bundling the binaries.

It is my understanding from reading here and there and the changelogs is that ffmpeg is somehow bundled in electron.

Can someone please clear this out for me? Is ffmpeg included in the final packaged application? How can I access the bundled ffmpeg binary?

Any information is welcome


#2

In the latest versions of Electron, ffmpeg has been stripped out of the bundled libraries and is available as a separate download that is compiled to work best with the matching version of Electron:


#3

So bundling the ffmpeg binary as I do today is the best way to go?

If not what are the other options? Is there a guide / documentation as to how?

Thanks


#4

Has it ?

If I understand properly, that would contradict statement such this one

The default prebuilt binaries of Electron will still include the possible proprietary codecs, but it will be very easy to replace the ffmpeg library with one that removes all proprietary codecs, which will also be provided by us.

I think you may be able to link to ffmpeg.dll / libffmpeg.so / libffmpeg.dylib depending of the platform.


#5

I’ve been trying to figure out how to get ffmpeg to work in in my packaged app for almost 2 weeks. It works perfectly in dev of course. I have downloaded the static builds and placed them in the main directory. Using fluent-ffmpeg and have set the paths like so:

const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath('./ffmpeg');
ffmpeg.setFfprobePath('./ffprobe');

When I packaged the app and try to run it I get this…

Error: spawn ./ffmpeg ENOENT
    at exports._errnoException (util.js:949:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
    at onErrorNT (internal/child_process.js:348:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

You mentioned linking to .dll, .so and .dylib but where do I put these files and how do I link to them? What file(s)?

My info:
Mac OS X Yosemite
Started from electron-prebuilt
using fluent-ffmpeg
Electron version 1.2.5
initially used brew install for ffmpeg but downloaded static binaries later

I see this and wondered if it’s what I need. Will try it next - https://github.com/zimbatm/ffmpeg-static

Any help would be greatly appreciated.

Thanks,
Dazed and confused


#6

I was able to get ffmpeg bundled for my app. I couldn’t find any good documentation for including 3rd party precompiled binaries, so I just fiddled with it until it finally worked. I have no idea if this is best practice or not. Im an uber novice w/ electron. Here’s what I did (starting with the electron quick start):

From the app directory I ran the following commands to include the ffmpeg binary as a module:

mkdir node_modules/ffmpeg
cp /usr/local/bin/ffmpeg node_modules/ffmpeg/
ln -s ../ffmpeg/ffmpeg node_modules/.bin/ffmpeg

(replace /usr/local/bin/ffmpeg with your current binary path, download it from here) Placing the link allowed electron-packager to include the binary I saved to node_modules/ffmpeg/.

Then to get the bundled app path I installed the npm package app-root-dir by running the following command:
npm i -S app-root-dir

Since I could then get the app path, I just appended the subfolder for my binary and spawned from there. This is the code that I placed in renderer.js:.

var appRootDir = require('app-root-dir').get();
var ffmpegpath=appRootDir+'/node_modules/ffmpeg/ffmpeg';
console.log(ffmpegpath);

const
  spawn = require( 'child_process' ).spawn,
  ffmpeg = spawn( ffmpegpath, ['-i',clips_input[0]]);  //add whatever switches you need here

ffmpeg.stdout.on( 'data', data => {
     console.log( `stdout: ${data}` );
    });
   ffmpeg.stderr.on( 'data', data => {
console.log( `stderr: ${data}` );
    });

#7

Ah, so you’re you able to run the package on another box that doesn’t have FFMPEG installed? Also, are you packaging for Windows and Mac and if so, have you tested those?


#8

OS X. Yes, runs just fine on my other box. Haven’t tested method with Windows yet.


#9

Not sure if still relevant but this is what I’ve been looking for a while ago as well. I just got around to solving it for my own project, together I thought I’d share.

Disclaimer: I created ffbinaries Node module and API.

I simply repackaged existing builds by other people into individual packages for modularity and consistency and uploaded to a GitHub repo. I created an API and a Node module to integrate this into my project. I just started this two nights ago so might be still lacking but give it a try.

You can include it in your build, it can be used from Node scripts or through CLI.

You’d then have to point fluent-ffmpeg or other library to use the binary downloaded by ffbinaries.


#10

I wanted to use ffmpeg bundled with my application and what I did was to:

  • Use the npm package ffmpeg-static that provides static binaries for Windows, Mac and Linux
  • Avoid packaging the package into the asar file
  • Use require('ffmpeg-static').path.replace('app.asar', 'app.asar.unpacked') to find the ffmpeg binary for the platform you are running in any scenario (whether or not the app is bundled or you are in development).

See my answer to this other StackOverflow question for more information.