'connect to rtsp and create multiple files every 10 seconds based from computer/device time

I wanted to run ffmpeg to connect to an RTSP stream and create multiple mkv files every 10 seconds based on the device time (device time where ffmpeg is running), and not the runtime of ffmpeg.

So if ffmpeg was run on midnight, file splits would be on 00:00:00, 00:00:10, 00:00:20, 00:00:30, 00:00:40, 00:00:50, 00:01:00, 00:01:10, etc.

An example file output would be:

stream_2022MAR07_00.00.00.mkv
stream_2022MAR07_00.00.10.mkv
stream_2022MAR07_00.00.20.mkv
etc.

And if the run hasn't started on the 10th second, it should still split on the next 10th second.

Example, the ffmpeg ran on 09:24:43, it should split on 09:24:50 and the succeeding 10th second of the device time. Expected file output would be:

stream_2022MAR07_09.24.43.mkv
stream_2022MAR07_09.24.50.mkv
stream_2022MAR07_09.25.00.mkv
etc.

The code that I have seen splits on the 10th second of the runtime, and not based on the device time.

ffmpeg -rtsp_transport tcp -i <rtsp_url> -f segment -strftime 1 \ 
    -segment_time 00:00:10 -segment_atclocktime 1 -segment_clocktime_offset 30 \
    -segment_format mp4 -an -vcodec copy -reset_timestamps 1 \ 
    stream_%Y-%m-%d-%H.%M.%S.mp4

And also, I haven't really got the explanation of the flags used. Can someone please help me here as I am new with ffmpeg.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source