How to avoid the 4GB file size limit when recording video?

asked 2017-12-04 05:47:11 -0500

Hello, I am recording a video with a VideoWriter, passing the parameter -1 so the codec select pops up. That only works for AVI files and those have a 4GB file size limit, so my video ends up glitched as I add frames to it.

Is there anyway to avoid this? what codec to install?

I am working on a windows 10 machine.


-- David

edit retag flag offensive close merge delete



try not to use -1, but specify a real codec.

(using -1 will use the outdated vfw graph, not ffmpeg)

berak gravatar imageberak ( 2017-12-04 06:53:23 -0500 )edit

I have tried that, the problem is that the AVI container has a maximum size of 4GB, and apparently it is the only way I can record more than 0 bytes. I have also checked the frame size and everything... Is there any way to use MKV as a container, when you use the right video for windows codec with a fourcc?

Studiosi gravatar imageStudiosi ( 2017-12-04 06:57:06 -0500 )edit

I have Lagarith and x264vfw, both pop up in the dialog.

Studiosi gravatar imageStudiosi ( 2017-12-04 06:58:09 -0500 )edit

How about using the .mp4 container? I have used that for large videos. Combine it with MPEG or XVID codec and it should work just fine.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-12-04 08:03:40 -0500 )edit

Yeah, at the end I had to hardcode the codec + specify a "mkv" container by changing the extension.

Studiosi gravatar imageStudiosi ( 2017-12-04 08:15:14 -0500 )edit

@Studiosi, You can't use this for windows 10. This will merely worked for Linux

supra56 gravatar imagesupra56 ( 2017-12-04 13:20:39 -0500 )edit

Here is link for only OpenCV 3.0 or later. Videowriter

supra56 gravatar imagesupra56 ( 2017-12-04 13:31:41 -0500 )edit