VIDEOIO ERROR: V4L

asked 2017-01-25 11:55:25 -0600

victor.dmdb gravatar image

updated 2017-01-25 12:29:02 -0600

I get the following error when I try to initialise a videocapture with a url:

cv::VideoCapture cap = cv::VideoCapture( "http://www.example.com/vid"  );

error:

VIDEOIO ERROR: V4L: device http://www.example.com/vid: Unable to query number of channels

There is nothing wrong with the videofile or access rights.

I recently recompiled ffmpeg with extra libs, and opencv 3.2 on ubuntu xenial, with the following configs:

ffmpeg

./configure --enable-gpl --enable-version3 --enable-nonfree --enable-libmfx --enable-runtime-cpudetect --enable-gray --enable-vaapi --enable-vdpau --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libfdk-aac --enable-libtheora --enable-libvpx --enable-libwebp --enable-x11grab --cpu=native --enable-vaapi --enable-vdpau --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libwavpack --enable-libxvid --enable-libx264 --enable-libx265 --enable-openssl --enable-nvenc --enable-cuda --enable-omx --enable-libv4l2

opencv 3.2

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -DWITH_LIBV4L=ON -DWITH_CLP=ON -DWITH_OPENCL=ON -DWITH_VA_INTEL=ON -DWITH_VA=ON ..

Could it be that I compiled opencv with VAor opencl?

EDIT: I tried recompiling opencv without the extra parameters and get the same issue:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -DWITH_LIBV4L=ON -DWITH_CLP=ON ..
edit retag flag offensive close merge delete

Comments

I might have fixed this with

cv::VideoCapture cap = cv::VideoCapture( "http://www.example.com/vid", cv::CAP_FFMPEG  );
victor.dmdb gravatar imagevictor.dmdb ( 2017-01-25 12:48:27 -0600 )edit

Ok no the solution above simply silences the error, but will still get an empty stream if it opens successfully

cap.get(CV_CAP_PROP_FRAME_WIDTH)

will be 0

victor.dmdb gravatar imagevictor.dmdb ( 2017-01-26 22:05:33 -0600 )edit

@ victor.dmdb you should fixed the bug by opening the video via ffmpeg, there is a another method to fix the question, the steps are as the following: 1. compile opencv with disabled v4l and enabled ffmpeg.

cmake -DWITH_LIBV4L=OFF -DWITH_FFMPEG=ON ..
  1. open the video without any flags(apiPreference).

    cv::VideoCapture videoCapture("videos/0188_03_021_al_pacino.avi", cv::CAP_FFMPEG);

ZhangYouyi gravatar imageZhangYouyi ( 2018-01-12 20:37:26 -0600 )edit