Sudden issues reading uncompressed video using opencv

Posted by JohnSavage on Stack Overflow See other posts from Stack Overflow or by JohnSavage
Published on 2012-03-27T17:26:42Z Indexed on 2012/03/27 17:29 UTC
Read the original article Hit count: 387

Filed under:
|
|

I have been using a particular pipeline to process video using opencv to encode uncompressed video (fourcc = 0), and opencv python bindings to then open and work on these files. This has been working fine for me on OpenCV 2.3.1a on Ubuntu 11.10 until just a few days ago. For some reason it currently is only allowing me to read the first frame of a given file the first time I open that file. Further frames are not read, and once I touch the file once with my program, it then cannot even read the first frame. More detail:

I created the uncompressed video files as follows:

out_video.open(out_vid_name,
               0, // FOURCC = 0 means record raw
               fps,
               Size(640, 480))

Again, these videos worked fine for me until about a week ago. Now, when I try to open one of these I get the following message (from what I think is ffmpeg):

Processing video.avi
Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later.
[avi @ 0x29251e0] parser not found for codec rawvideo, packets or times may be invalid.

It reads and displays the first frame fine, but then fails to read the next frame. Then, when I try to run my code on the same video, the capture still opens with the same message as above. However, it cannot even read the very first frame.

Here is the code to open the capture:

self.capture = cv2.VideoCapture(filename)
if not self.capture.isOpened()
    print "Error: could not open capture"
    sys.exit()

Again, this part is passed without any issue, but then the break happens at:

success, rgb = self.capture.read()
if not success:
    print "error: could not read frame"
    return False

This part breaks at the second frame on the first run of the video file, and then on the first frame on subsequent runs.

I really don't know where to even begin debugging this. Please help!

© Stack Overflow or respective owner

Related posts about python

Related posts about opencv