Python cv2.VideoCapture.read() does not read all frames (Bug #1938)
Description
I have some python code that tries to read all the frames from a video file (attached). However, using the following loop:
g_capture = cv2.VideoCapture('fence.wmv') ret = True while ret: ret,im = g_capture.read() cv2.imshow("video", im) cv2.waitKey(2)
results in only ~178 or so frames read before ret becomes False and things start failing. However, when I do:
g_capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, 201)
I correctly get the frame 201. Furthermore the following C code works just fine:
int main(int argc, char* argv[]) { CvCapture* capture = cvCaptureFromAVI("fence.wmv"); IplImage* img = 0; while(true) { if(!cvGrabFrame(capture)){ // capture a frame printf("Could not grab a frame\n\7"); cvWaitKey(); exit(0); } img=cvRetrieveFrame(capture); // retrieve the captured frame cvShowImage("mainWin", img); cvWaitKey(20); // wait 20 ms } cvReleaseCapture(&capture); }
I am using the svn version of opencv source code (from about 3 days ago) and I have tried to convert the original video to a supported avi format using the mencoder command found on http://opencv.willowgarage.com/wiki/VideoCodecs .
This bug might be a duplicate of http://code.opencv.org/issues/1690
Related issues
related to Bug #1690: VideoCapture is skipping frames | Done | 2012-03-15 |
History
Updated by Dmitry Kit almost 13 years ago
Realized I forgot to follow some instructions when I filed this bug:
The opencv build information is included below:
General configuration for OpenCV 2.4.0 ===================================== Version control: svn:8335 Platform: Host: Windows 6.1 x86 CMake: 2.8.8 CMake generator: Visual Studio 10 CMake build tool: /MICROS~1.0/Common7/IDE/devenv.com MSVC: 1600 C/C++: Built as dynamic libs?: YES C++ Compiler: cl C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /EHs /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE /arch:SSE2 /Oi /fp:fast /wd4251 /MP8 /MD /O2 /Ob2 /D NDEBUG /Zi C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /EHs /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE /arch:SSE2 /Oi /fp:fast /wd4251 /MP8 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 C Compiler: cl C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE /arch:SSE2 /Oi /fp:fast /MP8 /MD /O2 /Ob2 /D NDEBUG /Zi C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE /arch:SSE2 /Oi /fp:fast /MP8 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release): /STACK:10000000 /machine:X86 /INCREMENTAL:NO /debug Linker flags (Debug): /STACK:10000000 /machine:X86 /debug /INCREMENTAL OpenCV modules: To be built: calib3d contrib core features2d flann gpu highgui imgproc legacy ml nonfree objdetect photo python stitching ts video videostab Disabled by user: world Disabled by dependency: - Unavailable: androidcamera java GUI: QT 4.x: YES (ver 4.7.4 EDITION = OpenSource) QT OpenGL support: YES (optimized /x32/qt/lib/QtOpenGL4.lib debug /x32/qt/lib/QtOpenGLd4.lib) OpenGL support: YES (glu32 opengl32) Media I/O: ZLib: build (ver 1.2.6) JPEG: build (ver 62) PNG: build (ver 1.5.9) TIFF: build (ver 42) JPEG 2000: build (ver 1.900.1) OpenEXR: NO OpenNI: NO OpenNI PrimeSensor Modules: NO XIMEA: NO Video I/O: DirectShow FFMPEG: YES (prebuilt binaries) codec: YES (ver 53.61.100) format: YES (ver 53.32.100) util: YES (ver 51.35.100) swscale: YES (ver 2.1.100) gentoo-style: YES Other third-party libraries: Use IPP: NO Use TBB: YES (ver 4.0 interface 6004) Use Cuda: YES (ver 4.2) Use Eigen: NO Use Clp: NO NVIDIA CUDA: (ver 4.2) Use CUFFT: YES Use CUBLAS: YES NVIDIA GPU arch: 11 12 13 20 21 30 NVIDIA PTX archs: 11 12 13 20 21 30 NVIDIA GPU features: 11 12 13 20 20 30 20 Python: Interpreter: /Python27/python.exe (ver 2.7.2) Libraries: /Python27/libs/python27.lib (ver 2.7.2) numpy: /Python27/lib/site-packages/numpy/core/include (ver 1.6.1) packages path: /Python27/Lib/site-packages Documentation: Build Documentation: NO Sphinx: NO PdfLaTeX compiler: /MiKTeX 2.9/miktex/bin/x64/pdflatex.exe Tests and samples: Tests: YES Performance tests: YES Examples: NO Install path: /opencv_new/trunk/opencv/build32/install cvconfig.h is in: /opencv_new/trunk/opencv/build32 -----------------------------------------------------------------
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4362