I am using OpenCV 2.2.0 compiled on Ubuntu from the source. I can confirm that the source code you provided is working properly. So the problem is elsewhere.
I could not reproduce your problem using mencoder (installing a bit of a problem on it), so I used ffmpeg to wrap the raw video in an AVI container:
ffmpeg -s cif -i ~/local/sample-video/foreman.yuv -vcodec copy foreman.avi
(foreman.yuv is the standard CIF image sequence that you can find on the net if you look around ).
Running AVI from ffmpeg through your source gives the following:
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, everything works as expected. What you should check:
- Do you get any errors with standard release / standard error? OpenCV uses the
ffmpeg to read video files, so stay tuned for informative messages. Here's what happens if you try to play a RAW video file without a container (seems like your problem):
Mistake:
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
- Make sure your AVI file contains the necessary information to play the video. At a minimum, these should be the dimensions of the frame. RAW video usually does not contain any information other than the actual pixel data, so you need to know the frame size and FPS. You may mistakenly guess about FPS and receive video with the ability to view, but if you make a mistake in size, the video will be impossible to view.
- Make sure that the AVI file you are trying to open is actually playing. Try
ffplay file.avi - if this fails, the problem may be with the file. Try using ffmpeg to transcode instead of mencoder . - Make sure you can play other videos using the same method as above. If you do not, it is possible that your
ffmpeg installation is broken.
misha
source share