Ask Your Question

VideoCapture stops replay at approx 1 GB in Win 7

asked 2012-08-14 08:08:12 -0500

powlee gravatar image

updated 2012-08-14 08:47:12 -0500

sammy gravatar image


I have a multiplatform application using OpenCV 2.4.2, and the problems only appears in Windows. The videos i use are up to 3 GB in size and form Axis cameras. Format is avi, mpeg 4. Playback / jumping to frames stops at approximately 1 GByte.

I estimated the file size because depending on the exact size of the video files it stops somewhere between 31.000 - 35.000 frames. Up to this boundary playback/jumping works perfectly fine. The framework is Qt. I used OpenCV 2.1.0 before and updated because i thought it may resolve the issue. I post the CMake output below.

Detected version of GNU GCC: 44 (404)
CUDA_TOOLKIT_ROOT_DIR not found or specified
Could NOT find PythonInterp (missing:  PYTHON_EXECUTABLE) (Required is at least version "2.0")

General configuration for OpenCV 2.4.2 =====================================

    Host:                        Windows 6.1 x86
    CMake:                       2.8.4
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/Qt/2010.05/mingw/bin/mingw32-make.exe
    Configuration:               Release

    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Qt/2010.05/mingw/bin/g++.exe (ver 4.4.0)
    C++ flags (Release):         -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
    C Compiler:                  C:/Qt/2010.05/mingw/bin/gcc.exe
    C flags (Release):           -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core imgproc flann highgui features2d calib3d ml video objdetect contrib legacy nonfree photo stitching ts videostab
    Disabled:                    gpu
    Disabled by dependency:      -
    Unavailable:                 androidcamera java python world

    QT 4.x:                      YES (ver 4.7.0 EDITION = OpenSource)
    QT OpenGL support:           NO
    OpenGL support:              NO

  Media I/O: 
    ZLib:                        build (ver 1.2.6)
    JPEG:                        build (ver 62)
    PNG:                         build (ver 1.5.9)
    TIFF:                        build (ver 42 - 4.0.1)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     NO

  Video I/O:
    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
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    DirectShow:                  YES
    XIMEA:                       NO

  Other third-party libraries:
    Use IPP:                     NO
    Use TBB:                     NO
    Use Cuda ...
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-08-14 08:45:52 -0500

sammy gravatar image

updated 2012-08-14 08:48:54 -0500

You say it stops somewhere around 35 000 frames.

It is a good chance that some counter inside OpenCV or ffmpeg is hardcoded as short int, whose maximum value is 32 767. If that is the case, it's little to do. Another chance is that 1GB is the hardcoded limit of what your codec can support - some variable overflows after counting that many bits, or whatever.

What you can do:

  • Use another codec.

  • try to compile and run your program on an 64bit system - and hope that the troublesome variable will get upgraded to 4 bytes.

  • Use a decent compiler. Mingw is known to have some problems o windows. Use Visual Studio's compiler.

  • use the latest OpenCV, ffmpeg, codecs, Windows packages, etc. It is a chance that the problem has been fixed by someone else already.

  • Go with Linux. It may be that Linux has better support for it.

If none of these help, I'am afraid there is little else to do. You can try to find the problem by yourself and fix it. It may be anywhere, from OpenCV to the codec. Good luck!

And last, but not least, the easiest way, the "dummy solution":

  • Split your video in smaller sequences. VLC or the vanilla ffmpeg may be good at helping you with it.
edit flag offensive delete link more


Sorry it took so long, but it was a bit of work to get my project work with MSVC10. The compiler was the issue. Everything works fine now using MSVC10.


powlee gravatar imagepowlee ( 2012-09-26 05:35:39 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2012-08-14 08:08:12 -0500

Seen: 482 times

Last updated: Aug 14 '12