[Camera][JetPack 5.1.1][R35.3.1]Question about per-frame SOF timestamps in camera recording

i am debugging per-frame SOF timing in a camera recording pipeline on a Jetson Xavier board. The timestamp read in the recording application is different from the frame timestamp read on the kernel side.

The code that reads the timestamp on the kernel side is:
struct timespec64 ts_sof, ts_eof;
ts_sof = ns_to_timespec64((s64)descr->status.sof_timestamp);
ts_eof = ns_to_timespec64((s64)descr->status.eof_timestamp);
trace_tegra_channel_capture_frame(“sof”, &ts_sof);
trace_tegra_channel_capture_frame(“eof”, &ts_eof);

The output log is:
kworker/0:7-142 [000] … 1197.746686: tegra_channel_capture_frame: sof:1223.782082080
kworker/0:7-142 [000] … 1197.786686: tegra_channel_capture_frame: sof:1223.822081984
kworker/0:7-142 [000] … 1197.826680: tegra_channel_capture_frame: sof:1223.862081856
kworker/0:7-142 [000] … 1197.866650: tegra_channel_capture_frame: sof:1223.902081728
kworker/0:7-142 [000] … 1197.906650: tegra_channel_capture_frame: sof:1223.942081600
kworker/0:7-142 [000] … 1197.946648: tegra_channel_capture_frame: sof:1223.982081504

The recording is done with gst-launch-1.0:gst-launch-1.0 -e nvarguscamerasrc sensor-id=0 sensor-mode=0 wbmode=1 ! “video/x-raw(memory:NVMM),format=NV12,width=5496,height=3694,framerate=25/1” ! nvvidconv ! “video/x-raw(memory:NVMM),width=2880,height=2880” ! nvv4l2h265enc bitrate=8000000 ! h265parse ! qtmux ! filesink location=stretch.mp4

in file gstnvarguscamerasrc.cpp of this libgstnvarguscamerasrc.so
static const guint64 ground_clk = iFrame->getTime();
std::cout << "ground_clk = " << iFrame->getTime() << std::endl;
The output is:
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198036420000
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198136488000
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198199552000
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198247937000
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198287277000
10月 22 08:24:35 zzcomm-desktop bash[12102]: ground_clk = 1198320963000
So my questions are:

  1. Where does the timestamp returned by iFrame->getTime() come from?

  2. Is there source code available for the implementation of getTime()?

  3. Is there an implemented way to obtain the status.sof_timestamp in our recard app?

Any help would be appreciated. Thank you.

Hi @xianglin134 ,

IFrame::getTime() and descr->status.sof_timestamp represent different points in the capture pipeline, so I would not expect them to match directly.

descr->status.sof_timestamp corresponds to the hardware Start-of-Frame (SOF) timestamp recorded by the Video Input (VI) subsystem, while IFrame::getTime() is associated with the frame being acquired at the EGLStream/FrameConsumer level, which occurs later in the capture path.

For obtaining per-frame SOF timestamps through LibArgus, the following API documentation may be useful:

Since you are looking to correlate the application timestamps with the kernel-side SOF timestamps, getSensorSofTimestampTsc() may be particularly relevant, as it corresponds to the VI hardware SOF event and is therefore more closely aligned with the kernel-side timestamp in the capture pipeline.

Hope this helps!

Julian Camacho
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com