Dynamic linking and conditional recording with tee

Hello, I’m trying to make a simple ml pipeline in agx orin which should record a 10 second video:

nvarguscamerasrc -> streammux -> nvinfer -> nvtracker -> nvosd -> tee (main branch)
t. -> queue -> nvv4l2h265enc -> rtspclientsink (RTSP branch)
t. -> queue -> valve -> nvv4l2h265enc -> h265parse -> splitmuxsink (video recording branch)

I have a probe in nvosd which triggers a callback when there is new track that starts recording by opening a valve or if I don’t use a valve by dynamically linking and unliking of queue and tee pads. However both approaches end up hanging after first video successfully saved. I have tried these branches on their own seperately and they both work fine. Anyone knows whats going on?

Not sure there’s enough info here to know what’s going on, but you could take a look at this code example which on demand saves a few seconds of video (with some backlog).

You can remove the backlog part of course if you don’t need it.