electron - how to use ffmpeg within an electron app
Asked Answered
L

4

13

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?

Luddite answered 29/8, 2015 at 21:45 Comment(1)
I once wrote a native C++ wrapper around some basic decoding functionality of FFMPEG for node, I could post it and you could try to adapt it to your needs if you'd like. I think that would be the only way to use FFMPEG directly without the command line tool.Beulahbeuthel
P
2

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

Pretonic answered 6/4, 2016 at 3:3 Comment(1)
So, basically, what you're saying is - they bundled ffmpeg with electron, but we can't use it? (not without additional hassle at least)Inhospitality
C
12

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 :)

Coastland answered 13/11, 2016 at 11:35 Comment(0)
P
2

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

Pretonic answered 6/4, 2016 at 3:3 Comment(1)
So, basically, what you're saying is - they bundled ffmpeg with electron, but we can't use it? (not without additional hassle at least)Inhospitality
T
1

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.

Tadd answered 18/11, 2016 at 14:21 Comment(0)
S
0

Use ffmpeg-static

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

spawn(pathToFfmpeg, [
  // ...,
  // '-i', 'input', 'output'
])
Sacha answered 13/8, 2024 at 10:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.