Ask Your Question

Revision history [back]

Insanely high cpu usage for simple videocapture (50% cpu usage)

System information (version)

  • OpenCV => (opencv-contrib-python)
  • Operating System / Platform => Windows 10 Pro 64 Bit
  • Compiler => Visual Studio Build Tools 2019 (MSVC VS2019, C++ Cmake)

I'm trying to do some image processing using python and an IP camera input stream (H264 encoded) using an rtsp link. However when I just do a simple capturing of the frames (using the default read operation) then I see really high cpu usage, insanely high just for reading out a stream. I did some digging and I found that this might be because it is not using the correct backend system for decoding the images. I see that you could use FFMPEG or Gstreamer or something. But most of those threads are quite old, doesn't opencv have support for this built in already?

import numpy as np
import cv2
import imutils

cap = cv2.VideoCapture("rtsp://admin:[email protected]")

    ret, frame =
    frame = imutils.resize(frame, width=400)

    if cv2.waitKey(1) & 0xFF == ord('q'):


What am I missing? I installed FFMPEG and tried to pass the apiPreference flag "cv2.CAP_FFMPEG" to it but it still uses 50% of my CPU (i'm running this on a NUC server)