cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
337 stars 22 forks source link

Consider make available precompiled binaries with FFmpeg included #193

Open Wigny opened 1 year ago

Wigny commented 1 year ago

As mentioned in the README, currently the precompiled binaries do not use FFmpeg, but it is still considered to be delivered at some point. Having these pre-compiled binaries with FFmpeg included would be very useful since (at least in my personal use of the library) having to compile OpenCV locally is time-consuming and a task performed very often (when changing Mix environments, updating mix.exs file...).

So I'd like to check if this change is still planned to be made, or if there's a way to speed up my setup right now.

cocoa-xu commented 1 year ago

That's really a good point.

But currently, I'm not doing it for the three reasons listed below. But, of course, if we can find a way to address these issues, I'm happy to include FFmpeg in the precompiled version :)

  1. if we precompile it with FFmpeg, then we also need to ship FFmpeg's shared libraries, but FFmpeg has tons of encoders and decoders. If we compile them all, it will increase the size of this library.
  2. And these encoders and decoders may have different licenses (like GPL and nonfree ones). That may cause some licensing issues.
  3. There're also plenty of free encoders and decoders that can be compiled in FFmpeg, but they're also optional. It's hard to choose which ones to include in the precompile version and which ones not.
Wigny commented 1 year ago

These are really good reasons we need to solve first! Since your comment, I've been trying to figure out how we can solve these points, but given my lack of knowledge about compiling and licensing correctly the OpenCV binaries, I have not made good progress on it.

Trying to solve the first and third points firstly, I was thinking if there is a way we can build OpenCV with the FFmpeg support enabled, leaving it up to the Evision users to decide including or not FFmpeg on their project. Since I've not found any directions so far about this idea being feasible or not, I'm hoping you can tell if it's something we can try...

cocoa-xu commented 1 year ago

I was thinking if there is a way we can build OpenCV with the FFmpeg support enabled, leaving it up to the Evision users to decide including or not FFmpeg on their project.

Yeah, I think it's possible, and it should be easy to build it with FFmpeg enabled, although the next question is mainly about the build time.

I think if we build the ones with FFmpeg support after the ones without it (i.e., adding another step in the workflow), CMake should be able to reconfigure everything required, and that should be an incremental build thus should be fairly quick. I'll try it locally, and if it works (it should), I'll do a PR!

But in the worst case it would double the number of workflows,

with contrib/CUDA with FFMpeg Build Time
No No ~40 minutes
No Yes should be close to ~40 minutes
Yes No ~5 hours (Windows)
Yes Yes should also be ~5 hours