# VI Capture system time offset

**URL:** <https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795>\
**Category:** Jetson TX2\
**Created:** [August 2, 2018, 9:10pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795 "2018-08-02T21:10:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [August 2, 2018, 9:10pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/1 "2018-08-02T21:10:22Z")

</div>

Hi,  
I’ve noticed that buffers captured have a timestamp that is about 4 seconds ahead of system time.

Is there any way to change this?

I added a bit of debugging prints and I see that the SOF timestamp is already offset in tegra\_ivc\_vi\_notify\_get\_capture\_status()

See the system timestamp output on the left, and the SOF timestamp displayed on the right in nanoseconds… there is a 4 second delta.

[116.856140] tegra-ivc-vi-notify ivc-b000000.rtcpu:vinotify@12c0: tegra\_ivc\_vi\_notify\_get\_capture\_status: 121247362176

Thanks

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [August 3, 2018, 3:38am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/2 "2018-08-03T03:38:59Z")

</div>

hello phabsch,

thanks for point out,  
may I know which JetPack release you’re working with?  
thanks

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [August 3, 2018, 1:17pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/3 "2018-08-03T13:17:43Z")

</div>

Running TX2, 28.1.

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [August 3, 2018, 8:18pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/4 "2018-08-03T20:18:21Z")

</div>

If my understanding is correct, these values are populated by vinotify which comes from the RTCPU. I don’t understand where these would be synchronized. Is there a way of ensuring they have the same time? Or a way of determining the offset so that we can compensate in software?

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [August 6, 2018, 2:14am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/5 "2018-08-06T02:14:50Z")

</div>

hello phabsch,

you’re right, we’re using the timestamp of sensor start of frame to make it as v4l2 buffer timestamp.  
since there are stream setup and buffer initialization stages, time offset between v4l2 buffer and system time is expect.  
you can enable the dynamic debug prints of vi\_notify.c to confirm the SOF timestamp.  
also, may I know what’s your use-case about timestamp synchronization.  
thanks

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [August 7, 2018, 12:54pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/6 "2018-08-07T12:54:32Z")

</div>

Hi JerryChang,  
Thanks for the reply. While I understand that you are saying there is a delay between SOF and when we get the buffer, buy why is it 4 seconds IN THE FUTURE?

Note in my original post:  
kernel time: 116.856140 sec  
SOF time: 121.247362176 sec

We have a system with an IMU and are trying to synchronize physical movement with camera vision.

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [August 8, 2018, 3:34am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/7 "2018-08-08T03:34:12Z")

</div>

hello phabsch,

we had several kernel fixes integrate after 28.1,  
may I know is it possible to move your works to our latest release?  
thanks

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [August 9, 2018, 2:46pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/8 "2018-08-09T14:46:44Z")

</div>

Hi Jerry,

I just tried jetpack 3.3 on my Jetson dev kit and the ov5693 and experience the same problem. While I don’t have my debug code in place to see the timestamps per frame, I do see that stopping the streaming displays messages on the console.

./yavta -c10 -n4 -F/tmp/test.raw /dev/video0

[4918.955558] tegra-vi4 15700000.vi: timestamp sof 4929813128064 eof 4929840366880 data 0x00000001  
[4918.965131] tegra-vi4 15700000.vi: capture\_id 20 stream 2 vchan 0  
[5075.432800] tegra-vi4 15700000.vi: Status: 5 channel:00 frame:000A

Note that the kernel time is 4918.9 seconds, while the SOF message comes at 4929.8 seconds.

The duration of the test was under one second, how can the SOF be from 10 seconds in the future?

Note: I used yavta from here: [GitHub - brgl/yavta: Yet Another V4L2 Test Application](https://github.com/brgl/yavta)

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [August 10, 2018, 8:54am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/9 "2018-08-10T08:54:43Z")

</div>

hello phabsch,

thanks for point out, we will investigate this internally,  
thanks

---

<div class="post-metadata">

**Author:** ![dk1900](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@dk1900](https://forums.developer.nvidia.com/u/dk1900)\
**Post date:** [August 14, 2018, 1:51pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/10 "2018-08-14T13:51:31Z")

</div>

Hi Jerry, is there any updates on this? Thanks

Current v4l2 buffer stamp on TX2 does not comply with V4L2 standard.

[https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/buffer.html](https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/buffer.html)

[quote]

struct timeval   
timestamp   
For capture streams this is time when the first data byte was captured, as returned by the clock\_gettime() function for the relevant clock id; see V4L2\_BUF\_FLAG\_TIMESTAMP\_\* in Buffer Flags. For output streams the driver stores the time at which the last data byte was actually sent out in the timestamp field. This permits applications to monitor the drift between the video and system clock. For output streams that use V4L2\_BUF\_FLAG\_TIMESTAMP\_COPY the application has to fill in the timestamp which will be copied by the driver to the capture stream.

[quote]

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [September 13, 2018, 3:46pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/11 "2018-09-13T15:46:10Z")

</div>

@JerryChang, any updates?

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 14, 2018, 7:08am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/12 "2018-09-14T07:08:29Z")

</div>

hello phabsch,

there is bug about RTCPU and kernel system out-of-sync, we’re not root cause yet.  
please download [Tegra X2 (Parker Series SoC) Technical Reference Manual], and please refer to [Figure 202: NOTIFY System Diagram] and [Real-Time CPU Transport] chapter for more details.

may I have details about your use-case?  
I would suggest you to overwrite the timestamp of vi-notify for a temporary solution.  
thanks

---

<div class="post-metadata">

**Author:** ![dk1900](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@dk1900](https://forums.developer.nvidia.com/u/dk1900)\
**Post date:** [September 14, 2018, 12:08pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/13 "2018-09-14T12:08:57Z")

</div>

Hey, I am working together with phabsch.  
We need achieve high accuracy synchronization between cameras with other sensors like IMU and Lidar to do some SLAM applications.

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 17, 2018, 2:57am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/14 "2018-09-17T02:57:39Z")

</div>

hello dk1900,

my suggestion to unblock your process would be overwrite the timestamp of each capture frame for r28.2.1/ TX2.  
for example,  
please have modification in below VI driver function, and update the timestamp with linux kernel function.

```auto
<top>/kernel/kernel-4.4/drivers/media/platform/tegra/camera/vi/vi4_fops.c

static bool vi_notify_wait(...)
{
..
    *ts = ns_to_timespec((s64)status.sof_ts);

```

---

<div class="post-metadata">

**Author:** ![phabsch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@phabsch](https://forums.developer.nvidia.com/u/phabsch)\
**Post date:** [September 17, 2018, 1:46pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/15 "2018-09-17T13:46:24Z")

</div>

Hi JerryChang,  
I do already have that work around in place, but I am seeing problems with it. It seems that the vi\_notify\_wait portion of code after the nvhost\_syncpt\_wait\_timeout\_ext() is prone to delays. I haven’t figured out yet whether this is a kernel thread scheduling issue or something else.

I have 4 cameras synced together running at 60 fps. I can see the image is acquired at the same time on all 4 cameras. I used a chasing LED strobe with 100us between LED increment. When I use the timestamp from the RTCPU the values are really close across buffers (+/- 1us). But if I restamp the value in this function I have seen up to 84ms (yes milliseconds) delta between synchronized frames (the content is still synced).

I am thinking that since this code runs in a separate thread for each channel it is being delayed due to thread context switching.

We could probably work with this and just restamp each of the frames with the lowest of all 4 frames, but I am concerned that we are seeing 84ms between them. This means that we sometimes drop multiple frames (because the next acquisition in our code doesn’t start until all 4 frames have captured).

---

<div class="post-metadata">

**Author:** ![kko-smol](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kko-smol](https://forums.developer.nvidia.com/u/kko-smol)\
**Post date:** [October 2, 2018, 1:19pm UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/16 "2018-10-02T13:19:45Z")

</div>

Hello. Any news about issue?

We faced with same problem: system time and timestamps difference about 10 seconds.

After reading Parker TRM I found TSC used for timestamps.

How to read current TSC value? or set it? Or use as system clock

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [October 4, 2018, 8:29am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/17 "2018-10-04T08:29:20Z")

</div>

hello kko-smol,

as I mentioned in comment [#14](https://devtalk.nvidia.com/default/topic/1038131/jetson-tx2/vi-capture-system-time-offset/post/5281853/#5281853),  
you may overwrite the timestamp of each capture frame for r28.2.1/ TX2 to unblock your process so far,  
thanks

---

<div class="post-metadata">

**Author:** ![kko-smol](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kko-smol](https://forums.developer.nvidia.com/u/kko-smol)\
**Post date:** [October 8, 2018, 10:18am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/18 "2018-10-08T10:18:45Z")

</div>

JerryChang, restamp frames in software is not good idea: it will add delay and jitter under load (code in #14 runs as thread, not in interrupt)

I found, that CLOCK\_MONOTONIC\_RAW return time, close to v4l2 timestamps, but after some hours it got offset too (looks like it work on close, but different frequency. offset grows with uptime)

We want timestamp error not more 1ms.

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [November 19, 2018, 6:44am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/19 "2018-11-19T06:44:18Z")

</div>

hello kko-smol,

sorry for late reply,  
may I have your confirmation that “after-some-hour offset” is caused by system suspend/resume?  
thanks

---

<div class="post-metadata">

**Author:** ![1129538701](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@1129538701](https://forums.developer.nvidia.com/u/1129538701)\
**Post date:** [April 29, 2025, 1:11am UTC](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795/20 "2025-04-29T01:11:49Z")

</div>

嗨，在r35.6.0 SDK在orin nx上也出现了这个问题，请问我应该怎么解决这个问题

[Next page](https://forums.developer.nvidia.com/t/vi-capture-system-time-offset/63795.md?page=2)
