Getting the number of frames of an AVI video file for OpenCV

I’ve been using the OpenCV (ver. 1.0.0) lately and I noticed that under Linux, using the “cvCaptureFromAVI” does not detect the correct number of frames from an AVI video file. So this code returns 0 as the number of frames: