We are currently working on capturing images from cameras using an RTSP stream and storing them in a Redis database.
With up to 6 cameras 4MP @ 10fps, everything runs smoothly and we get 60 fps at our Redis database. But, when we try and add 9 cameras we see a decrease in fps (they remain at 60 fps when we expected 90 fps, 10 fps for every camera).
Our network settings are ok, we can do this same task with CPU processing (cv2.videocapture) up to 15 cameras and it works fine but it consumes many CPU resources and we think we could manage our resources better by processing this in GPU.
Our camera settings are:
h.265 codec
2688x1520
10 fps
6144 bit rate
We run this on 1 RTX 3090.
We use compiled FFmpeg and hevc_cuvid. Here’s the code we are running:
pipe = sp.Popen(
[
"ffmpeg",
"-y",
"-loglevel",
"error",
"-vsync",
"0",
"-c:v",
"hevc_cuvid",
"-rtsp_transport",
"tcp",
"-i",
config["device_url"],
"-preset",
"superfast",
"-pix_fmt",
"bgr24",
"-f",
"rawvideo",
"-",
],
stdout=sp.PIPE,
bufsize=bufsize,
)
while True:
pipe_content = pipe.stdout.read(bufsize)
if len(pipe_content) > 1:
self.store_frame(
str(config["id"]),
numpy.frombuffer(pipe_content, dtype="uint8").reshape(
(image_y, image_x, 3)
),
)
pipe.stdout.flush()