fictrac
fictrac copied to clipboard
Timestamp discontinuity with `CVSource` class
The condition to fallback to system time in the CVSource
class is the following:
https://github.com/rjdmoore/fictrac/blob/9ac055e52d89f49f492a8eb4e1f7c5b8cd6df40a/src/CVSource.cpp#L162-L165
But I think the condition should be strict, that is, I think the condition should be _timestamp < 0
. Otherwise, timestamps which are 0 are ignored and the fallback of the system time is used instead which creates a time discontinuity. As an example, this is the data that I got by running the algorithm in the sample.mp4
:
frame_counter | sequence_counter | movement_direction | movement_speed | timestamp | alt_timestamp | delta_timestamp | |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | -0 | 0 | 1.69019e+12 | 4.14554e+07 | 0 |
1 | 1 | 1 | 5.79849 | 0.0246007 | 33.3333 | 4.14554e+07 | -1.69019e+12 |
2 | 2 | 2 | 3.5273 | 0.0211707 | 66.6667 | 4.14554e+07 | 33.3333 |
See the large discontinuity caused by the first timestamp being 0.
To confirm that the first timestamp is indeed 0 we can run ffprobe:
ffprobe -i sample.mp4 -select_streams v:0 -show_entries frame=best_effort_timestamp_time,pkt_pts_time,pkt_dts_time,pkt_duration_time -of default=noprint_wrappers=1 -v quiet | head -n 20
pkt_pts_time=0.000000
pkt_dts_time=0.000000
best_effort_timestamp_time=0.000000
pkt_duration_time=0.033333
pkt_pts_time=0.033333
pkt_dts_time=0.033333
best_effort_timestamp_time=0.033333
pkt_duration_time=0.033333
pkt_pts_time=0.066667
pkt_dts_time=0.066667
best_effort_timestamp_time=0.066667
pkt_duration_time=0.033333
pkt_pts_time=0.100000
pkt_dts_time=0.100000
best_effort_timestamp_time=0.100000
pkt_duration_time=0.033333
pkt_pts_time=0.133333
pkt_dts_time=0.133333
best_effort_timestamp_time=0.133333
pkt_duration_time=0.033333