I'm trying to start a recording every evening, starting from 19:00 and stopping at 02:00. The webcam does export its stream as rtsp video stream and I am able to start the recording correctly with VLC using this:

For some reason it sometimes loses the connection (my guess is the WiFi is blocked). No matter how hard I try I can't get vlc to reconnect and just continue writing to the file where it left off. Any pointers to what I should be looking into?