Tuesday, 7 August 2018

How can I bundle a precompiled binary with electron

I am trying to include a precompiled binary with an electron app. I began with electron quick start app and modified my renderer.js file to include this code that is triggered when a file is dropped on the body:

spawn = require( 'child_process' ).spawn,
        ffmpeg = spawn( 'node_modules/.bin/ffmpeg', ['-i',clips[0],'-an','-q:v','1','-vcodec','libx264','-y','-pix_fmt','yuv420p','-vf','setsar=1,scale=trunc(iw/2)*2:trunc(ih/2)*2,crop=in_w:in_h-50:0:50', '/tmp/out21321.mp4']);

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

I have placed my precompiled ffmpeg binary in node_modules/.bin/. Everything works great in the dev panel, but when I use electron-packager to set up the app, it throws a spawn error ENOENT to the console when triggered. I did find a very similar question on SO, but the question doesn't seem to be definitively answered. The npm page on electron-packager does show that they can be bundled, but I cannot find any documentation on how to do so.



from How can I bundle a precompiled binary with electron

No comments:

Post a Comment