question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to manually include DLL from Python package (e.g. FFmpeg in OpenCV)

See original GitHub issue

I am using Python 3.8.11 (through Anaconda) on Windows, with packages (installed with pip, not conda):

Nuitka==0.6.17.2
numpy==1.21.1
opencv-python==4.5.3.56

I am using --plugin-enable=numpy --plugin-enable=anti-bloat to enable use of numpy, which is a dependancy of OpenCV for Python.

opencv-python includes a build of FFmpeg as a dll. The exact file name depends on the version of FFmpeg, which in turn depends on the version of opencv-python; in this version particular it is:

<conda-env>\Lib\site-packages\cv2\opencv_videoio_ffmpeg453_64.dll

It isn’t found by the dependency walker. But this is to be expected because it’s loaded dynamically only when needed, with a graceful failure (e.g. VideoWriter will throw a Python exception). This is done as part of satisfying the LGPL requirements of FFmpeg.

This is more a question than a bug report: what command line option (if any) could I use to include this file?

  • I considered (and tried!) --include-plugin-files= but it seems to be for Python files to be compiled
  • I considered --include-data-file= but it takes a file system path, not a path relative to the Python environment
  • I considered --include-package-data= but it specifically says it excludes DLLs.

For now I am using --include-data-file=%CONDA_PREFIX%\Lib\site-packages\cv2\opencv_videoio_ffmpeg453_64.dll=opencv_videoio_ffmpeg453_64.dll and it works (e.g. I can use VideoWriter) but it’s a bit fragile as it assumes that I’m using Anaconda and Windows (although that is likely to usually be true for me) and the specific FFmpeg number will change as OpenCV version changes.

(Off topic: Many thanks for all your hard work on Nuitka 😄)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
kayhayencommented, Nov 30, 2021

The said work is complete and will be in 0.6.18, so this is next on the agenda.

1reaction
kayhayencommented, Nov 10, 2021

This is the next one right after static optimization for importlib.import_module is complete, which itself will take some time. Feel free to remind me when I make a release that claims to do it, but only then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenCV Python unable to open videofile - Stack Overflow
Suggest you download the binary from OpenCV Download site, install it and try again. The ffmpeg DLL is located in 'C:\Program Files (x86)\OpenCV...
Read more >
How to install OpenCV-Python package to Anaconda (Windows)
Download OpenCV Package. Firstly, go to the official OpenCV site to download the complete OpenCV package. · Copy and Paste the cv2.pyd file...
Read more >
OpenCV configuration options reference
At this moment only separate compilation process is supported: first you have to build OpenCV with some default parallel backend (e.g. pthreads), then...
Read more >
opencv-python-headless - Python Package Health Analysis
If you have previous/other manually installed (= not installed via pip ) version of OpenCV installed (e.g. cv2 module in the root of...
Read more >
opencv-python 3.3.0.9 - PyPI
Wrapper package for OpenCV python bindings. ... Adding FFmpeg as an additional dependency without a “universal” FFmpeg build (e.g. LGPL licensed build like ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found