I can\'t seem to capture frames from a file using OpenCV -- I\'ve compiled from source on Ubuntu with all the necessary prereqs according to: http://opencv.willowgarage.com/wik
You don't have the gstreamer-ffmpeg
or gsteamer-python
or gsteamer-python-devel
packages installed. I installed all three of them. and the exact same problem was resolved.
I'm using OpenCV 2.2.0, compiled on Ubuntu from source. I can confirm that the source code you provided works as expected. So the problem is somewhere else.
I couldn't reproduce your problem using mencoder (installing it is a bit of a problem on my machine) so I used ffmpeg
to wrap a raw video in the AVI container:
ffmpeg -s cif -i ~/local/sample-video/foreman.yuv -vcodec copy foreman.avi
(foreman.yuv is a standard CIF image sequence you can find on the net if you look around).
Running the AVI from ffmpeg
through your source gives this:
misha@misha-desktop:~/Desktop/stackoverflow$ python ocv_video.py foreman.avi
<Capture 0xa71120>
352.0
288.0
<iplimage(nChannels=3 width=352 height=288 widthStep=1056 )>
<iplimage(nChannels=3 width=352 height=288 widthStep=1056 )>
...
So things work as expected. What you should check:
ffmpeg
libraries to read video files, so be on the lookout for informative messages. Here's what happens if you try to play a RAW video file without a container (sounds similar to your problem):error:
misha@misha-desktop:~/Desktop/stackoverflow$ python ocv_video.py foreman.yuv
[IMGUTILS @ 0x7fff37c8d040] Picture size 0x0 is invalid
[IMGUTILS @ 0x7fff37c8cf20] Picture size 0x0 is invalid
[rawvideo @ 0x19e65c0] Could not find codec parameters (Video: rawvideo, yuv420p)
[rawvideo @ 0x19e65c0] Estimating duration from bitrate, this may be inaccurate
GStreamer Plugin: Embedded video playback halted; module decodebin20 reported: Your GStreamer installation is missing a plug-in.
<Capture 0x19e3130>
0.0
0.0
ffplay file.avi
-- if that fails, then the problem is likely to be with the file. Try using ffmpeg
to transcode instead of mencoder
.ffmpeg
install is broken.