Skip to content

Linux FFmpeg + libjpeg-turbo builds #59

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

Merged
merged 11 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ This enables super fast (usually < 10 seconds) OpenCV installation for Python.

If you need only OpenCV Python bindings, no separate OpenCV installation is required.

**IMPORTANT NOTE**

MacOS and Linux packages do not support video related functionality (not compiled with FFmpeg).

Installation and Usage
----------------------

Expand Down Expand Up @@ -49,7 +45,7 @@ A: The wheel package format and manylinux builds are pretty new things. Most lik

**Q: I need contrib modules?**

A: Please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead. However, note that commercial usage might be restricted in some countries since the contrib modules contain some non-free/patented algorithms.
A: Please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead. However, note that commercial usage might be restricted in some countries since the contrib modules might contain some non-free/patented algorithms.

**Q: Import fails on Windows to some DLL load error?**

Expand All @@ -61,12 +57,6 @@ See also `this issue <https://github.com/skvark/opencv-python/issues/36>`__ if y

A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).

**Q: Why I can't open video files on GNU/Linux distribution X or on macOS?**

A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it.
The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box.
Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.

Documentation for opencv-python
-------------------------------

Expand Down Expand Up @@ -139,7 +129,7 @@ OpenCV itself is available under `3-clause BSD
License <https://github.com/opencv/opencv/blob/master/LICENSE>`__
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).

Windows wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
All wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.

Linux and MacOS wheels ship with `Qt 4.8.7 <http://doc.qt.io/qt-4.8/lgpl.html>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.

Expand Down
14 changes: 2 additions & 12 deletions README_CONTRIB.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OpenCV on Wheels

**Unofficial** OpenCV packages for Python with contrib modules.

**Note: the usage of opencv-contrib-python might be restricted in some countries since the contrib package contains some patented algorithms/non-free modules.**
**Note: the (commercial) usage of opencv-contrib-python might be restricted in some countries since the contrib package might contain some patented algorithms/non-free modules.**

If you are looking for a version without the contrib modules, please install `opencv-python <https://pypi.python.org/pypi/opencv-python>`__ instead.

Expand All @@ -12,10 +12,6 @@ This enables super fast (usually < 10 seconds) OpenCV installation for Python.

If you need only OpenCV Python bindings, no separate OpenCV installation is required.

**IMPORTANT NOTE**

MacOS and Linux wheels do not support video related functionality (not compiled with FFmpeg).

Installation and Usage
----------------------

Expand Down Expand Up @@ -57,12 +53,6 @@ See also `this issue <https://github.com/skvark/opencv-python/issues/36>`__ if y

A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).

**Q: Why I can't open video files on GNU/Linux distribution X or on macOS?**

A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries provided withing these packages are not compiled against it.
The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box.
Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.

Documentation for opencv-python
-------------------------------

Expand Down Expand Up @@ -135,7 +125,7 @@ OpenCV itself is available under `3-clause BSD
License <https://github.com/opencv/opencv/blob/master/LICENSE>`__
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).

Windows wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
All wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.

Linux and MacOS wheels ship with `Qt 4.8.7 <http://doc.qt.io/qt-4.8/lgpl.html>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.

Expand Down
11 changes: 5 additions & 6 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import os
import sys


class OpenCVTest(unittest.TestCase):
""" Simple functionality tests. """
Expand All @@ -10,8 +11,6 @@ def test_import(self):

def test_video_capture(self):

if os.name != 'posix':
import cv2

cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
self.assertTrue(cap.isOpened())
import cv2
cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
self.assertTrue(cap.isOpened())
43 changes: 39 additions & 4 deletions travis/build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,27 @@ echo "Python numpy version: $PYTHON_NUMPY_VERSION"
# Begin build
echo 'Begin build'
cd opencv

# FFmpeg version is too new.
# This is a temporary fix from upstream until we have a new OpenCV release.
git cherry-pick b1d208891b9f

mkdir build

export JPEG_INCLUDE_DIR="/opt/libjpeg-turbo/include"
export JPEG_LIBRARY="/opt/libjpeg-turbo/lib32/libjpeg.a"

MACHINE_TYPE=$(uname -m)
if [[ ${MACHINE_TYPE} == 'x86_64' ]]; then
JPEG_LIBRARY="/opt/libjpeg-turbo/lib64/libjpeg.a"
fi

export LDFLAGS=-L/root/ffmpeg_build/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/ffmpeg_build/lib/pkgconfig
export PATH=~/bin:$PATH

ffmpeg -L

export QTDIR=/opt/Qt4.8.7
export PATH=$QTDIR/bin:$PATH

Expand All @@ -45,7 +64,11 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then
-DPYTHON2_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \
-DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \
-DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \
-DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION"
-DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"

fi

Expand All @@ -61,7 +84,11 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then
-DPYTHON3_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \
-DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \
-DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \
-DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION"
-DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"

fi

Expand All @@ -77,7 +104,11 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then
-DPYTHON2_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \
-DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \
-DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \
-DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION"
-DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"

fi

Expand All @@ -93,7 +124,11 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then
-DPYTHON3_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \
-DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \
-DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \
-DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION"
-DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"

fi

Expand Down