Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV load time linking dependency on GPL code: avformat-58.dll #11160

Closed
wstnturner opened this issue Apr 2, 2022 · 10 comments
Closed

OpenCV load time linking dependency on GPL code: avformat-58.dll #11160

wstnturner opened this issue Apr 2, 2022 · 10 comments

Comments

@wstnturner
Copy link

wstnturner commented Apr 2, 2022

The current Msys2 build of OpenCV is built with a load time linking dependency on GPL licensed code (avformat library et al/ffmpeg). The Msys2 OpenCV, due to the load time GPL linking, is no longer BSD licensed.

Users who incorporate the current Msys2 OpenCV into their code assuming the BSD license are inadvertently forcing their (potentially closed source code) to be subject to the GPL.

https://packages.msys2.org/package/mingw-w64-x86_64-opencv

Package: mingw-w64-x86_64-opencv

Upstream URL: https://opencv.org/
License(s): BSD
Version: 4.5.5-1

  • avformat-58.dll DLL load time dependency, parent package:

https://packages.msys2.org/package/mingw-w64-x86_64-ffmpeg

Package: mingw-w64-x86_64-ffmpeg

Upstream URL: https://ffmpeg.org/
License(s): GPL
Version: 4.4.1-12

Dependency detection

Running dependencies on: libopencv_videoio.dll
See: https://github.com/lucasg/Dependencies

Listing dependency modules for: libopencv_videoio.dll

Dependencies.exe -modules libopencv_videoio.dll
...
[Environment] avformat-58.dll : C:\msys64\mingw64\bin\avformat-58.dll
...
@Biswa96
Copy link
Member

Biswa96 commented Apr 3, 2022

@lazka
Copy link
Member

lazka commented Apr 3, 2022

The current Msys2 build of OpenCV is built with a load time linking dependency on GPL licensed code (avformat library et al/ffmpeg), OpenCV does not comply with GPL due to its BSD license.

GPL and BSD-3-Clause are compatible.

Users who incorporate the current Msys2 OpenCV into their code assuming the BSD license are inadvertently forcing their (potentially closed source code) to be subject to the GPL.

Correct. Assuming they release it to the public.

@wstnturner
Copy link
Author

wstnturner commented Apr 3, 2022

I'm not sure indicating that the current Msys2 OpenCV package is BSD licensed is compatible with the GPL. By combining it with a load time linking dependency on GPL code, the released software becomes subject to the GPL license (paragraph 2 part b of GPL). The OpenCV project's source code may be BSD, but the Msys2 OpenCV is now in effect GPL. I'm aware that I may simply rebuild OpenCV with a configuration that preserves its BSD license features. Though, up until recently the Msys2 OpenCV (up to version 4.5.2) was I believe not subject to the GPL license, and thus more versatile with respect to integrating into closed source projects.

Thanks for the information about Arch and Debian's libopencv_videoio GPL dependency. Maybe this "issue" should be dealt with elsewhere. I understand that the work done to maintain Msys2 is all volunteer and mostly in people's spare time, and I really appreciate it! Thank you so much for maintaining this project and for responding to the issue I created.

@jeremyd2019
Copy link
Member

Would delayimp help, or is that still too tightly coupled with GPL code? (Disclaimer: I have not tried to do delayed import on mingw-w64)

@wstnturner
Copy link
Author

wstnturner commented Apr 4, 2022

It was previously possible to use libopencv_videoio452.dll to open a camera device without any dependency on ffmpeg. That build of opencv was generally useful for image streaming from a capture device and image processing without a GPL load time linking dependency. The Dependencies program shows no ffmpeg dependency in videoio (4.5.2):

$ Dependencies.exe -modules libopencv_videoio452.dll | grep ffmpeg

Ideally we include dlfcn.h and use dlopen/dlsym to optionally runtime dynamic link/load code that would affect the license of a project. I'm not sure about delayimp, seems like a windows thing. I believe the videoio module is capable of runtime loading ffmpeg et al based on debug output such as:

[DEBUG:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/videoio_registry.cpp (191) VideoBackendRegistry VIDEOIO: Builtin backends(8): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[DEBUG:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/videoio_registry.cpp (215) VideoBackendRegistry VIDEOIO: Available backends(8): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[ INFO:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/videoio_registry.cpp (217) VideoBackendRegistry VIDEOIO: Enabled backends(8, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[ WARN:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/cap.cpp (235) open VIDEOIO(GSTREAMER): trying capture cameraNum=0 ...
[ INFO:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/backend_plugin.cpp (335) getPluginCandidates Found 2 plugin(s) for GSTREAMER
[ INFO:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/core/src/utils/plugin_loader.impl.hpp (67) libraryLoad load opencv_videoio_gstreamer452_64.dll => FAILED
[ WARN:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/cap.cpp (296) open VIDEOIO(GSTREAMER): backend is not available (plugin is missing, or can't be loaded due dependencies or it is not compatible)
[ WARN:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/cap.cpp (235) open VIDEOIO(DSHOW): trying capture cameraNum=0 ...
[ WARN:0] global C:/_/M/mingw-w64-opencv/src/opencv-4.5.2/modules/videoio/src/cap.cpp (248) open VIDEOIO(DSHOW): created, isOpened=1

In this case, the gstreamer backend is not available (nor is ffmpeg) and thus is not used and the DSHOW backend is finally used. As far as I can tell there is no load time linking dependency on ffmpefg (or gstreamer in this case); since those DLLs are not present in the local working directory and the code is not being run via Msys2/MinGW (so no ability to resolve libraries in the msys system paths).

@1480c1
Copy link
Contributor

1480c1 commented Apr 4, 2022

$ Dependencies.exe -modules libopencv_videoio452.dll | grep ffmpeg

Shouldn't the grep be for av?

@wstnturner
Copy link
Author

$ Dependencies.exe -modules libopencv_videoio452.dll | grep ffmpeg

Shouldn't the grep be for av?

Grep on avformat, also no load time linking dependency there either for 4.5.2

$ Dependencies.exe -modules libopencv_videoio452.dll | grep avformat

@Biswa96
Copy link
Member

Biswa96 commented Apr 5, 2022

Is it possible to replace ffmpeg with native WMF. There is a option in cmake file:

OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" NOT MINGW
  VISIBLE_IF WIN32
  VERIFY HAVE_MSMF)

@crackwitz
Copy link

crackwitz commented Apr 10, 2022

OpenCV is licensed under Apache 2

This says that ffmpeg is LGPL but contains optional GPL parts.

Discussion on vcpkg

More discussion on opencv-python

The biggest achievement of GPL is that everyone has to work around it, taking up work that could have been spent more productively.

@MehdiChinoune
Copy link
Collaborator

MehdiChinoune commented Sep 17, 2022

I don't think we can do something about it!
You could rebuild OpenCV with ffmpeg disabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants