简体   繁体   中英

OpenCV (C++) Can't get XVID video file framerate

I'm trying to get VideoCapture working with OpenCV. The video I'm trying to load is in XVID format (checked it with VideoCapture::get(CV_CAP_PROP_FOURCC) ). It works fine, but whenever I try to get the video framerate ( VideoCapture::get(CV_CAP_PROP_FPS) ) I get -nan .

I've used the same video and the same code on another computer (at uni, they have a custom Debian installation) and I can confirm that the framerate info is there (it works fine there). I read somewhere that Ubuntu recently removed ffmpeg from their repositories (I use Linux Mint 17.2), so I installed the ffmpeg package from the ppa:kirillshkrogalev/ffmpeg-next repositories. After that I recompiled OpenCV and installed again, without any change.

I'm using OpenCV 2.4.11 with C++ under Linux Mint 17.2.

Probably XVID is missing on your linux machine which is required by ffmpeg. Try installing XVID as below, it may help you.

cd /opt

wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz

tar xzvf xvidcore-1.3.2.tar.gz

cd xvidcore/build/generic

./configure --prefix="$HOME/ffmpeg_build"

make

make install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM