Skip to content

Build using FFMPEG #26

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

Closed
kartikarora opened this issue Feb 20, 2017 · 7 comments
Closed

Build using FFMPEG #26

kartikarora opened this issue Feb 20, 2017 · 7 comments

Comments

@kartikarora
Copy link

Hi

I need to use cv2 for video files on my cloud foundry python app. Could you guide me on how to build this package with ffmpeg compatibility for ubuntu trusty?

Thanks

@skvark
Copy link
Member

skvark commented Feb 20, 2017

The current build setup in this repository uses special CentOS 5 Docker containers. Installing latest FFmpeg on them might be a bit complicated.

I'm not familiar with Cloud Foundry, but I think that the easiest way for your use case is to build OpenCV manually and copy the OpenCV binary to your Trusty environment.

@kartikarora
Copy link
Author

kartikarora commented Feb 20, 2017

@skvark I did try to build OpenCV manually, and the python bindings for it using anaconda. It failed everytime.

I have a deb python-opencv which works perfectly on my local machine, but cloud foundry doesn't allow installation of deb files or anything using apt-get for that matter. I'm trying to figure out a way to make my custom buildpack, but in the meantime, is there any way in which I could package an already compiled and working cv2.so and cv.py files extracted from that deb so that I can install it using pip?

@skvark
Copy link
Member

skvark commented Feb 20, 2017

How the OpenCV was compiled? If I understand you correctly, it depends on FFmpeg, and it means that the FFmpeg binaries must be also in the Trusty machine. If they are not there/can't be installed there, you have to first copy all the precompiled binaries to the cv2 folder along with the OpenCV binary or binaries.

After that clean the setup.py script and then run python setup.py bdist_wheel. All the other files/folders in this repo are irrelevant in your case. I'm not sure if this works. If you end up packaging the FFmpeg binaries to the same package, cv2/__init__.py might need some additional logic to add the binary folder path to LD_LIBRARY_PATH (I'm just guessing, I have never tried this).

@kartikarora
Copy link
Author

kartikarora commented Feb 20, 2017

There is no setup.py file. The .deb file has the precompiled cv2.so file.

As far as my compilation of OpenCV is concerned, I do have FFmpeg binaries and all the dependencies installed.

Just to re iterate the query I have right now, given that I have the .so file needed by python, it there a way to make a package install-able by pip?

@skvark
Copy link
Member

skvark commented Feb 20, 2017

Sorry, I wasn't clear enough. My previous post was a guide how to adapt the files in this repo to construct a a wheel package to be installed with pip. So, in short:

  1. Take the setup.py file and cv2 folder from this repo
  2. Follow the instructions in my previous comment
  3. You will end up with a wheel package. This package must be installed manually: pip install wheel_package_name.whl

@kartikarora
Copy link
Author

Gotcha. I'll try this and get back to you.

@kartikarora
Copy link
Author

@skvark This didn't work. My wheel contained an empty cv2 package, with an empty __init.py__.

I solved this issue by moving to docker from cloud foundry and building everything from source. It seems to be working now.

Thanks for the advice!

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

2 participants