0

I am using OpenCV and Java with InteliJ idea. I want to track FPS of a video. I have checked this sample code and it returned an error.

    VideoCapture videoCapture = new VideoCapture();
    videoCapture.open("/home/chinthaka/Downloads/wow/giphy.mp4");
    double fps = videoCapture.get(Videoio.CAP_PROP_FPS);
    System.out.println( "fps: " + fps);

error:

(DEBUG) try_init_v4l2 VIDIOC_QUERYCAP "/home/chukz/Downloads/wow/giphy.mp4": Inappropriate ioctl for device Unable to stop the stream: Inappropriate ioctl for device fps: 0.0

I am using Linux environment. How to solve this?

Jazz
  • 916
  • 1
  • 8
  • 22
ChukZ
  • 79
  • 2
  • 14

2 Answers2

0

I think you ffmpeg not installed.

  • 1.apt-get install ffmpeg.

  • 2.Recompile OpenCV.

cd opencv
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j 8
make install

Notice if ffmpeg in configure does not show yes when recompiling!!!

Dany
  • 25
  • 1
0

try to rebuild your opencv by adding -D WITH_LIBV4L=ON:

cd opencv
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=./local -D WITH_LIBV4L=ON ..
make -j
make install
JustingGong
  • 45
  • 1
  • 8