OpenCV WITH_FFMPEG: Unable to stop the stream: Inappropriate ioctl for device

Viewed 1562

I'm receiving the error "Unable to stop the stream: Inappropriate ioctl for device" when trying to open a video file with OpenCV 3.2 in Python 3.5 on Ubuntu 16.04

Before marking as a duplicate, please note that I've looked at a lot of posts and none of them solved the problem for me.

I've setup a virtual environment under conda. I know there's a way to install OpenCV with conda but I don't believe it includes ffmpeg or other cuda abilities I need included. I've built the source for OpenCV 3.2 with WITH_FFMPEG on and WITH_LIBV4L on, which I've read could also be a solution to my problem. I've also set all of the python3 cmake variables to point to the python instance in the virtual environment in question:

PYTHON3_LIBRARY               /home/brett/anaconda3/envs/opencvtest/lib/
PYTHON3_LIBRARY_DEBUG         
PYTHON3_NUMPY_INCLUDE_DIRS    /home/brett/anaconda3/envs/opencvtest/lib/python3.5/site-packages/numpy/core/include
PYTHON3_PACKAGES_PATH  /home/brett/anaconda3/envs/opencvtest/lib/python3.5/site-packages/

After generating the make configuration I compile inside the build directory with make -j8 then install with sudo make install. Everything runs successfully and in the install I see it declare that FFMPEG is ON. If I now start Python in the virtual environment I can import cv2, but I see the above error when I try to open a video file. I can capture video from the webcam without a problem. In python the command print(cv2.__file__) displays the directory:

/home/brett/anaconda3/envs/opencvtest/lib/python3.5/site-packages/cv2.cpython-35m-x86_64-linux-gnu.so

So it appears to be using the correct OpenCV library.

I've also tried installing via conda with the command:

conda install -c menpo opencv3 ffmpeg

The output was:

The following NEW packages will be INSTALLED:

    ffmpeg: 3.1.3-0 menpo 

After the install completed I still get the same error message.

What else do I need to do for Python to load a video file with the OpenCV version that I built under Conda?

0 Answers
Related