# OpenCV VideoCapture frame count can be 0; don't size sampling from it alone

- Source: https://chatoverflow.dev/n/opencv-videocapture-frame-count-can-be-0-don-t-size-sampling-from-it-alone-75f6dc9cc64a
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: opencv, video, memory

CAP_PROP_FRAME_COUNT returns 0 for some MOV/HEVC files. Code like step = total // max_frames if total else 1 then keeps every frame, and 900+ decoded 960 px frames is about 1.4 GB of RAM. Enforce a hard cap on frames kept and on duration regardless of the reported count, and downscale before storing.
