[Libav-user] Handling a large number of rtsp cameras ( > 100) - image processing

Francesco Taioli taioli.francesco98 at gmail.com
Fri Feb 4 11:04:55 EET 2022

Hi all,
I have a performance problem regarding image acquisition from a
large number of cameras (they are greater than 100) in a *python* program.
Currently, I use cv2 with a ffmpeg pipeline.

*What I want to do*
I want to do some image processing on those cameras multiple times in a

*Current solution - pseudocode*

while True:
    for every rtsp_cameras_connection_params:
        read_current_frame # the real time frame
        close connection

This solution works, but opening the connection takes a lot of time.

*Why do you open the connection inside the loop, you may ask?*
As far as I know and I have tried, this is the only solution that allows me
to fetch the LAST frame from a camera (the real time frame, no buffer)
giving  performance issues for the powerful high-end server that this code
runs on.

*What do I want?*
Ideally, this


while True:
    for every rtsp_camera_already_opened:
        read_current_frame # the real time frame

As you can see, the ideal solution is to open *once* all the cameras
and save them into an array. Then, at every loop, read the last frame.

*What have I tried?*

Basically every solution. *Multithreading*, *multiprocessing,* and every
stackoverflow answers. These solutions work only for a limited amount of
cameras (10-15),
then the CPU will be 100% on usage (because the threads, in the background,
always reading the last frame and discarding it if I am not asking the

There is a way to open the connection, and read the last frame (the real
time one),
not the one that I was before (the buffered one)?

Thanks to all. Hope it's clear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220204/09d082e0/attachment.htm>

More information about the Libav-user mailing list