Grabbing one frame every few seconds from an RTSP camera: exec node with ffmpeg or something lighter?

What is the lightest reliable way to get one still image every few seconds from an RTSP camera inside a flow?

The approach I keep seeing is an inject node every 5 seconds into an exec node that runs ffmpeg with -rtsp_transport tcp -i URL -frames:v 1 -f image2pipe -vcodec mjpeg pipe:1, with the exec node set to return a binary buffer. It works, but starting ffmpeg each time costs a second or two and some CPU, because it has to connect and wait for a keyframe every time.

Other options I know of: keep one long running ffmpeg process that writes a frame every N seconds (-vf fps=1/5) and watch the output folder; use the camera's own snapshot URL with an http request node if it has one (much lighter, but not every camera does); or restream through go2rtc or MediaMTX and request frames from that.

For people running this on a Raspberry Pi or a small mini PC: which one did you end up with, and how many cameras did it handle before CPU became a problem? Any trouble with ffmpeg processes left hanging when the camera goes offline?

What is the camera's brand and model? Theoretically, it might expose an HTTP API for retrieving snapshots. If so, that would probably be the lightest solution, as you wouldn't need to run FFmpeg or maintain an RTSP connection just to capture a single frame.

What would you like to do with the images? Just view them or do some object detection on them?

Anyway, using MediaMTX or go2rtc is the way to proceed (I use MediaMTX on both RPi3 & RPi4 and it works brilliant with minimum CPU load and yu clould then also use the GPU which I do to reduce CPU load to a very low minimum)

One detail on the timeout suggestion: current FFmpeg documents RTSP -timeout in microseconds, so -timeout 5000000 means five seconds. That is a socket I/O timeout, not a five-second deadline for the whole capture. With an inject every five seconds, I would also prevent a second capture from starting until the previous process exits, and test that gate with the camera unplugged. Otherwise a slow or stalled capture can turn into several overlapping ffmpeg processes.