Cutting VideoCapture latency on USB cameras

2026-05-11 · 5 min read

If your loop is slower than the camera, VideoCapture hands you stale frames from its internal buffer. On Linux with V4L2 you can shrink it:

cap = cv2.VideoCapture(0, cv2.CAP_V4L2)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)

Not every driver honours BUFFERSIZE. The reliable fix is a grabber thread that always keeps only the newest frame.