Carlo
Carlo

Reputation: 1194

electron - how to use ffmpeg within an electron app

In the last release (v0.31.0) electron comes with a statically linked FFMpeg library (not the command line tool, see #2588)

I am aware of the many nodejs modules for ffmpeg, but they all look like an api to the command line tool, so how can I ideally access the ffmpeg library bundled with electron and encode a stream?

Upvotes: 13

Views: 9369

Answers (4)

Tukun33
Tukun33

Reputation: 27

Use ffmpeg-static

const pathToFfmpeg = require('ffmpeg-static')
const { spawn } = require('child_process')

spawn(pathToFfmpeg, [
  // ...,
  // '-i', 'input', 'output'
])

Upvotes: 0

Vot
Vot

Reputation: 199

Disclaimer: This is a shameless plug for ffbinaries Node module and ffbinaries.com API I created.

I was looking for the answer to this a while ago and couldn't find anything useful. I decided to put something together myself and thought I'd come back here in case you still need it.

I created ffbinaries downloader to achieve this. I just started this two nights ago so might be still lacking but give it a try.

Still very much work in progress, currently (at 0.0.12) it doesn't set permissions on the file yet but it downloads the required binaries just fine.

Edit: ffbinaries has reached version 1.0.0 milestone a while back - nice, stable and it does set permissions correctly :)

Upvotes: 12

UltrasoundJelly
UltrasoundJelly

Reputation: 1900

It's possible to bundle the precompiled static ffmpeg binary with an electron app; of course you'll have to make sure you bundle the correct binary with the correct distro. I have a complete answer here.

Upvotes: 1

eljefedelrodeodeljefe
eljefedelrodeodeljefe

Reputation: 6791

This is currently not possible, since there is no decent ffmpeg library for node.js. Meaning, there are only such that abstract the CLI. However it is possible to compile and link ffmpeg as node native addon, which simply no-one seems to have done yet. So the advice, unfortunately, would be to write this kind of abstraction and include the lib into your electron build

Upvotes: 2

Related Questions