0

I am using ffmpeg to record a camera stream using rtsp protocol. Camera stream is being consumed via rtsp-simple-server. I am creating 10 second files by setting output_ts_offset to epoch realtime.

ffmpeg command:

ffmpeg -hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://rtsp_simple_server_ip:rtsp_simple_server_port/stream_url -muxpreload 0 -muxdelay 0 -c:v copy -an -f segment -strftime 1 -segment_time 10 -output_ts_offset $EPOCHREALTIME -segment_atclocktime 1 -segment_clocktime_offset 30 -segment_format mp4 file_%s.mp4

Each file is saved with offset - start_time as epoch timestamp(current timestamp when ffmpeg pipeline starts and keep on adding 10 seconds as it creates 10 second files) and adding the same timestamp in file name also. eg file_1669903600.mp4. FPS is 15.

ffprobe output:

start_time=1669903599.93233
duration=10.106771
[/STREAM]
[FORMAT]
filename=file_1669903600.mp4
[/FORMAT]

[STREAM]
start_time=1669903605.53452
duration=10.106771
[/STREAM]
[FORMAT]
filename=file_1669903610.mp4
[/FORMAT]

In second example, there is difference of 5 seconds in start_time and filename which is incorrect. Similarily sometimes there are differences upto 50000 seconds in timestamps.

Files are being saved with start_time metadata either in past or future. Anyone faced the same issue with ffmpeg?

Suddenly I am getting files with 76ms duration and framerate increases to 1986 from 15 and then this timestamp diff(start_time - filename timestamp) starts increasing negatively by 10 and goes up to -47270(in past) or sometimes it goes in future.

[STREAM]
r_frame_rate=25/1
avg_frame_rate=778240/51953  <-- framerate = 15
time_base=1/15360
start_pts=25872908239503
start_time=1684434130.175977
duration=10.147070
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684434130.mp4
[/FORMAT]
[STREAM]
r_frame_rate=25/1
avg_frame_rate=2334720/155849  <-- framerate = 15
time_base=1/15360
start_pts=25872908394947
start_time=1684434140.296029
duration=10.146419
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684434140.mp4
[/FORMAT]
[STREAM]
r_frame_rate=25/1
avg_frame_rate=389120/16871  <-- framerate = 23
time_base=1/15360
start_pts=25872908551004
start_time=1684434150.455990
duration=6.590234
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684434150.mp4
[/FORMAT]
[STREAM]
r_frame_rate=15360/1
avg_frame_rate=466944/235  <-- framerate = 1986
time_base=1/15360
start_pts=25872908651213
start_time=1684434156.980013 <-- behind 4 seconds than filename timestamp
duration=0.076497
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684434160.mp4
[/FORMAT]
[STREAM]
r_frame_rate=15360/1
avg_frame_rate=466944/235  <-- framerate = 1986
time_base=1/15360
start_pts=25872908651366
start_time=1684434156.989974  <-- behind 14 seconds than filename timestamp
duration=0.076497
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684434170.mp4
[/FORMAT]
...
...
...
[STREAM]
r_frame_rate=15360/1
avg_frame_rate=466944/235 <-- framerate = 1986
time_base=1/15360
start_pts=25872908681733
start_time=1684434158.966992 <-- behind 2042 seconds than filename
duration=0.076497
nb_frames=152
[/STREAM]
[FORMAT]
filename=file_1684436200.mp4
[/FORMAT]


Why framerate is jumping to 1986 suddenly and why ffmpeg is adding 10 seconds to timestamp metadata?

Expected output: Timestamps should match(start_time timestamp should be equal to filename timestamp)

1
  • @gyan, can you please help here? May 23 at 7:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.