I've ran into a problem with my opencv installation, it is unable to open an mp4 video. My system is ubuntu 16.04, 64bit, opencv3.2 used from python 3.5.
VideoCapture.read
returns False
and None
.
There are other questions with this problem, but they target different platforms or different opencv versions.
Apparently, I'm missing the proper codec.
So I ran make uninstall
from my build directory, purged opencv*
with apt and built from source again. This time making sure that ffmpeg
was installed before the compilation.
Here are my steps:
- clone opencv and opencv_contrib
cd opencv/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_EXAMPLES=ON ..
make -j 8
sudo make install
I checked the output of cmake, ffmpeg is there:
Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: NO
-- FFMPEG: YES
-- avcodec: YES (ver 56.60.100)
-- avformat: YES (ver 56.40.101)
-- avutil: YES (ver 54.31.100)
-- swscale: YES (ver 3.1.101)
-- avresample: NO
-- GStreamer: NO
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- Aravis SDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: NO/YES
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: NO
But the problem persists. How can I fix this ?