Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Building with an alternative libffmpeg #198

Closed
dcposch opened this issue Apr 16, 2016 · 33 comments
Closed

Building with an alternative libffmpeg #198

dcposch opened this issue Apr 16, 2016 · 33 comments

Comments

@dcposch
Copy link

dcposch commented Apr 16, 2016

Since electron/electron#4530, Electron is using libffmpeg as a shared library (so/dylib/dll).

I'm trying to swap libffmpeg.so with one that supports a wider range of codecs, so that I can play back AC3 audio tracks from an Electron app.

Currently, the build process for this looks pretty involved

As far as I can tell, you have to modify four separate codebases:

  • Custom build of electron. Electron downloads libchromiumcontent from S3. You can specify your own download URL and a custom LIBCHROMIUMCONTENT_COMMIT
  • Custom build of libchromiumcontent. libchromiumcontent references the Chromium source tree at https://chromium.googlesource.com/chromium/src.git, as defined in vendor/chromium/.gclient. I guess you could replace this with your own fork of Chromium.
  • Custom build of chromium. Chromium references ffmpeg by once again referring to a git repo, which looks like it's cloned into third_party/ffmpeg. You can replace that with your own fork of ffmpeg.
  • Custom build of ffmpeg Finally, in your own fork of ffmpeg, you could add a new ffmpeg_branding value. The built-in values are Chrome, Chromium, ChromeOS, and ChromiumOS. I tried adding a fifth one I called CompleteCommonCodecs, which adds support for AC3.

Questions

  • Is there an easier way to do this, maybe using the patches folder here in libchromiumcontent?
  • Is it possible to do this without modifying libchromiumcontent at all, just swapping in a custom libffmpeg.so into the finished Electron build?
  • Has anyone else done this before?
@dcposch dcposch changed the title Building an alternative libffmpeg Building with an alternative libffmpeg Apr 16, 2016
@dcposch
Copy link
Author

dcposch commented Apr 16, 2016

@zcbenz @felixrieseberg @RSATom any advice much appreciated!

@RSATom
Copy link

RSATom commented Apr 16, 2016

@dcposch, I can invite you to private slack room where you will find guys who did it already for well known torrent related project "which-name-better-not-call-in-public".

@RSATom
Copy link

RSATom commented Apr 16, 2016

@dcposch, could you send me your email? I'll send you invite. My email is rsatom@gmail.com.

@RSATom
Copy link

RSATom commented Apr 16, 2016

@feross, btw, I can invite you too, but don't sure if you'll like it. Guys there want get you there long time already...

@dcposch
Copy link
Author

dcposch commented Apr 16, 2016

@RSATom, I found these patches, in case these are what you mean:

They're off of older versions of Chromium and FFmpeg than what we're using.

I can invite you to private slack room where you will find guys who did it already for well known torrent related project "which-name-better-not-call-in-public"

Haha, you don't have to censor the name, they're not Voldemort.

Their project encourages piracy so I'd rather not work with them. Thanks for the invite though.

@jaruba
Copy link

jaruba commented Apr 16, 2016

@RSATom I don't think there's even one person that is still working with Voldemort in there now.

@jaruba
Copy link

jaruba commented Apr 16, 2016

I'm also pretty sure that no one is using a re-built Electron 0.37+ with extended ffmpeg support. Only the Butter guys are using NW.js with extended ffmpeg support if i'm not mistaken, but none do it with Electron atm.

@RSATom
Copy link

RSATom commented Apr 16, 2016

@dcposch, I've talked more about Butter Project than Popcorn-Time - but it's your decision, and I respect it. So, if you would like get access to mentioned above room, just notify me, I will be glad get you there. Anyway, I respect your decision.

@zcbenz
Copy link
Contributor

zcbenz commented Apr 18, 2016

@dcposch To add support for more codecs in Electron, you basically need to do 2 things:

  1. Add a patch in libchromiumcontent to make Chromium recognize more codes, and I will be good merging it to upstream;
  2. Replace the ffmpeg library in Electron with your own one.

@tensor5
Copy link

tensor5 commented Apr 18, 2016

Isn't it easier to use the system installed ffmpeg? I do it in my Electron package for Arch Linux by compiling Chromium with a patch from Gentoo. Then you can configure your system ffmpeg as you like.

@hadees
Copy link

hadees commented Aug 9, 2016

@tensor5 if you just used the system installed ffmpeg would everything still play through the video tag?

@RSATom is butter going the route of using a modified libchromiumcontent? I really love your library webchimera but with the headache i've had with node and native libraries I'm starting to wish I could just recompile libchromiumcontent to support more codecs.

@tensor5
Copy link

tensor5 commented Aug 9, 2016

@hadees the video tag works.

@hadees
Copy link

hadees commented Aug 9, 2016

@tensor5 cool, and the video tag will work with any codex ffmpeg supports? That does seem a lot easier. I mean couldn't you just package up ffmpeg with electron then?

EDIT: Doh, that's pretty much what @zcbenz said on a second reading

@RSATom
Copy link

RSATom commented Aug 10, 2016

@hadees

@RSATom is butter going the route of using a modified libchromiumcontent ?

It depends... If you are able build ffmpeg yourself - then yes, it could give you benefits in some aspects. But most of Electron users just not skilled enough to do it.

@RSATom
Copy link

RSATom commented Aug 10, 2016

On other side <video> tag api is limited, that's why some prefer use WebChimera.js

@stale stale bot added the wontfix label Mar 15, 2017
@LukasBombach
Copy link

Hey, has there been any progress on this? I am too trying to get more / most! codecs work in the video tag and as you know this is pretty hard. I have a lot of questions

  • Has anyone succeeded in compiling this and distributes it somewhere?
  • Also @RSATom is your Slack still alive?
  • How does it work using the system's ffmpeg to play videos in the <video> tag?
  • And while I am here: Is there any decent documentation on how to compile ffmpeg / libchromiumcontent to make Electron support more videos?

@LukasBombach
Copy link

For reference, I asked the maintainers to provide a "full" ffmpeg alongside the "normal" distribution here electron/electron#9534

@RSATom
Copy link

RSATom commented May 24, 2017

Also @RSATom is your Slack still alive?

Don't know. Didn't use it long time. Better ask @luigiplr

@luigiplr
Copy link

Hey @RSATom long time no see ping, @LukasBombach it is alive yes.. however discussion regarding torrent'ing clients ended a while back. Would be happy to throw you a invite should you be interested.

A few have compiled nw.js successfully with full pretty good codec support, we ran into alot of perf problems decoding in the wild though (was a while back so i don't recall the specifics).

Have you investigated the usage of Web Chimera as an alternative?

@RSATom
Copy link

RSATom commented May 24, 2017

WebChimera is almost dead, don't think it's good idea use it.

@LukasBombach
Copy link

Yeah, I read that (that it's dying), very sad. In the WebChimera issues I found an alternative, but as I read in their issues, this library is also heavy on the CPU, so a "native" playback would still be much better.

@zeke zeke removed the wontfix label May 25, 2017
@jchwei
Copy link

jchwei commented Sep 18, 2017

I found there are some work on building chromium from customized ffmpeg henrypp/chromium , so I extend it to libchromiumcontent.
The basic method is very similar to @dcposch's post, I'm working on it.

---- update -----
I have finished it, and enable full-codecs in electron just like the way in chromium.

@themihai
Copy link

themihai commented Feb 7, 2018

@jchwei would you mind to send a PR to electron/libchromiumcontent ? It would be great to have a flag enabling whatever codecs we want from ffmpeg.

@smolleyes
Copy link

smolleyes commented Feb 17, 2018

hello, after yearsssssssssssss of nwjs i still can t find a better way for this problem than live transcoding thru http pipe / ffmpeg (if canPlay fail) i still can read any video with not that much cpu (and in 2018 shitty pc have i5 so lol) i ll try to make a basic project with this one day :p, currently i can play

['aiff','ra','mka','webm','aac','wma','mp4','flac','wav','mpeg','opus','avi','flv','wmv','mkv','ogg','mov','ogv']; and hevc/x265... dts ac3 etc etc

@themihai
Copy link

@smolleyes did you manage to make the shuffling work as well ?(i.e. convert byte ranges used by the browser to time ranges used by ffmpeg)

@smolleyes
Copy link

hi, dammnnn just added the dxva2 support to my ffmpeg command line and it s huge improvement ! now my nwjs app play youtube 4k videos like a breeze :D

image

@themihai you mean seeking ?

@LukasBombach
Copy link

@jchwei is there a chance you can share your codec-enabled binaries?
@smolleyes Do you have a demo project we can learn from?

<3

@smolleyes
Copy link

hey @LukasBombach everything is in my github... streamstudio is my first project from years ago ... code is a real shit lol but still working, look at the js/ht5server.js (shame on me)... i started a small project from an electron / react boilerplate and i ll just add this system if possible (in clean es6)... when i ll have time

@themihai
Copy link

@smolleyes yeah I mean seeking.

@smolleyes
Copy link

@themihai i dont have any problems with seeking :), just use the -ss option of ffmpeg

@manast
Copy link

manast commented Dec 25, 2018

ok, so I would like to replace thelibffmpeg.so from electron with a custom one that is built for RPI with hw decoding enabled. I managed to build ffmpeg and also have an MPV player using it which plays videos super smooth in the RPI, however I am not able to build libffmpeg.so that I can use to replace the standard one, I just get a list of .so libraries like these:

libavcodec.so
libavdevice.so
libavfilter.so
libavformat.so
libavutil.so
libswresample.so
libswscale.so
libpostproc.so

For building ffmpeg I used this flags in configure:

./configure --prefix=/usr --enable-gpl --enable-nonfree --enable-shared --enable-libtheora --enable-libvorbis --enable-omx --enable-omx-rpi --enable-mmal --enable-libxcb --enable-libfreetype --enable-libass --enable-gnutls --disable-opencl --enable-libcdio --enable-libbluray --extra-cflags="-march=armv8-a+crc -mfpu=neon-fp-armv8 -mtune=cortex-a53" --enable-libx264 --enable-libfdk-aac --enable-libmp3lame --extra-cflags="-fPIC" --enable-pic --extra-ldflags="-Wl,-Bsymbolic"

Do you guys know how to create the desired libffmpeg.so?

@jchwei
Copy link

jchwei commented Dec 26, 2018

@LukasBombach Here is the windows x64 release .

@nornagon
Copy link
Member

nornagon commented Jan 2, 2019

If you want to do this the same way Electron does, see the GN build docs. Instead of building the electron target, you can build the //third_party/ffmpeg target (with your changes applied to that directory). A bit heavyweight since you'll need to check out the whole chromium repository, but it'll definitely work.

See https://github.com/electron/electron/blob/77f73830e8fea5c5acbb745985732ceff5091fce/.circleci/config.yml#L284 for how we do this in CI.

@nornagon nornagon closed this as completed Jan 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests