I can’t comment much on the nvidia solution above, because on one hand my C skills are not that good and on the other, the app is not specifically designed to handle rtsp (network) errors but merely to add / remove error-free sources.
I somehow managed to handle reconnect in python using some hacks:
- On the bus call, check
message.srcand if it’s from
rtspsrc, don’t quit the loop
- Upon detecting rtsp error, set the
uridecodebinbin to NULL state, then call
sync_state_with_parent()on this bin. This will discard previous state and start the connection process from scratch. Don’t forget to place your callbacks again for linking to nvstreammux. I’m not sure if it’ll work with a manually constructed decoding chain (instead of uridecodbin) but I’m pretty sure all elements in the chain (including the nvidia decoder) must be set to NULL.