Gabriel Kammer
Gabriel Kammer

Reputation: 51

OpenCV VideoCapture error: VIDIOC_REQBUFS: Inappropriate ioctl for device

I have been trying to read videos from a file in Java using OpenCV. I am running OpenCV 4.0.0 on Ubuntu. Currently I have been trying to do so as follows:

VideoCapture videoCapture = new VideoCapture("/home/gkammer/Downloads/test.mp4");

However, this is giving me the error message VIDIOC_REQBUFS: Inappropriate ioctl for device.

I have already tried rebuilding OpenCV with FFMPEG like many similar questions recommend, but I still get the error. When I ran cmake this was the relevant output:

Video I/O: DC1394: YES (ver 2.2.5) FFMPEG: YES avcodec: YES (ver 57.107.100) avformat: YES (ver 57.83.100) avutil: YES (ver 55.78.100) swscale: YES (ver 4.8.100) avresample: YES (ver 3.7.0) GStreamer: NO v4l/v4l2: linux/videodev2.h

Any suggestions for how to resolve this would be appreciated.

Upvotes: 4

Views: 11134

Answers (2)

Romain Laneuville
Romain Laneuville

Reputation: 497

I was able to read a .mp4 video with OpenCV 4.0.1-34-g78da67947 and GStreamer 1.14.1 with Ubuntu 18.04 LTS.

To enable this video backend, install gstreamer required dependencies with:

sudo apt install libgstreamer1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good

Then recompile OpenCV with WITH_GSTREAMER flag on.

I also have issues reading mp4 video or rtsp stream with V4L or DC1364 even if I have compiled OpenCV with the correct options :

"  Video I/O:
"
"    DC1394:                      YES (2.2.5)
"
"    FFMPEG:                      NO
"
"      avcodec:                   NO
"
"      avformat:                  NO
"
"      avutil:                    NO
"
"      swscale:                   NO
"
"      avresample:                NO
"
"    GStreamer:                   YES (1.14.1)
"
"    v4l/v4l2:                    YES (linux/videodev2.h)

If someone has a solution to this problem (specifically the DC1394 backend).

Upvotes: 3

A.Ametov
A.Ametov

Reputation: 2020

If gstreamer is not installed or there are problems with installing with sudo apt-get gstreamer-xxx, try sudo apt install ubuntu-restricted-extras.

I also have faced with this problem, then I have paid attention to the OpenCV compilation headers, installed almost all packages listed in official docs (except libjasper), cmake made it without WITH_GSTREAMER but with WITH_FFMPEG=ON and got videos with different files extensions(avi, mkv) playing on C++ and Python in Ubuntu 18.04.

Besides, explicit WITH_GSTREAMER=ON does not set flag GSTREAMER to YES.

Upvotes: 0

Related Questions