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

asked 2020-10-26 11:15:43 -0600

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)

edit retag flag offensive close merge delete


I see that you could use FFMPEG or Gstreamer or something.

on windows, it will use ffmpeg for ip streams by default (and prebuilt cv2 won't have any gstreamer support)

I installed FFMPEG

no, it will use the opencv_ffmpeg.dll that comes with your cv2 install

berak gravatar imageberak ( 2020-10-26 11:37:20 -0600 )edit

Ok thank you berak, so am I missing something? Why is it still using the cpu for the image processing? If i look at my task manager i can see that it barely uses any GPU, while using around 50% cpu

Rickvanhek gravatar imageRickvanhek ( 2020-10-26 13:26:51 -0600 )edit