# Measuring Sync Quality and Correcting Drift

> After a recording: how to find dropped and duplicated frames with ffprobe and device counters, measure clock offset and drift, recover timing from arrival times, prove the streams are in sync with published benchmarks, and correct them by timestamp remapping, interpolation or resampling.

Page: https://egocam.ai/sync/drift-correction-and-verification/

Choosing a [hardware trigger](https://egocam.ai/sync/hardware-sync/), a [network clock](https://egocam.ai/sync/ptp-and-network-time/) or a [visual sync target](https://egocam.ai/sync/qr-and-visual-sync/) is half the job. After the session, you still have to show that every camera, [IMU](https://egocam.ai/hardware/imu-sensors/) and audio track stayed aligned, and fix the recordings where they did not.

This matters even on current hardware-triggered rigs. The 6C capture cap, a six-camera head rig whose cameras all expose on one 30 Hz pulse, documents in its sample release that "Monos skip scattered single frames, marked in the sync table" and that "The monos' timestamps run 4 frames late" ([The Open Robot Company, 6C capture cap](https://six-cam-samples.pages.dev/)). Head-plus-wrist rigs built from separate devices, such as [EgoKit](https://arxiv.org/abs/2605.16797)'s headset with two USB wrist cameras, have no shared trigger at all. And in RocSync's surgical recordings with more than 25 cameras, the one failure in 73 recordings came from frame drops in a pair of Aria glasses, not from the sync method ([Meyer et al., 2025](https://arxiv.org/abs/2511.14948)).

This page assumes the terms on [why synchronisation matters](https://egocam.ai/sync/why-sync-matters/#terms-used-in-this-section): offset, drift in parts per million (ppm), latency and jitter. The arithmetic of drift and the two-sync-point worked example are on that page; the short verification checklist and four prompts are on [sync methods compared](https://egocam.ai/sync/sync-methods-compared/#how-to-verify-your-sync). This page goes deeper into each step.

## The order of work

1. **Count frames first.** Find dropped and duplicated frames in every stream. A clock model fitted to a stream with silent drops is wrong.
2. **Measure offset and drift** for each device against one reference clock.
3. **Prove the result** with a test whose error you can measure.
4. **Correct the streams**, preferably by rewriting timestamps rather than pixels or samples.

## Finding dropped and duplicated frames

A **dropped frame** is an exposure that never reaches the file; a **duplicated frame** is written twice. Both break any pipeline that computes a frame's time as its index times the frame period.

### Reading frame timestamps with ffprobe

A container stores a time for every frame: the presentation timestamp (PTS), which says when a frame is shown, and the decode timestamp (DTS), which says when its compressed packet is decoded. They differ when the encoder reorders frames. The stream header's `avg_frame_rate` is only a summary and hides gaps.

This command prints one timestamp per decoded frame, in seconds:

```bash
ffprobe -v error -select_streams v:0 \
  -show_entries frame=best_effort_timestamp_time \
  -of default=noprint_wrappers=1:nokey=1 recording.mp4
```

`best_effort_timestamp_time` is FFmpeg's best estimate of each frame's presentation time; `pts_time` gives the raw PTS. Older scripts, such as the widely copied [`plotframetimes.py` gist](https://gist.github.com/dreness/916025a5f049c94f2177), ask for `pkt_pts_time`, a field that current FFmpeg versions no longer output; on FFmpeg 6.1 it is silently left out.

This short script turns those timestamps into a list of gaps. We tested it on a 30 fps clip with three frames removed:

```python

def frame_times(path):
    out = subprocess.run(
        ["ffprobe", "-v", "error", "-select_streams", "v:0",
         "-show_entries", "frame=best_effort_timestamp_time",
         "-of", "default=noprint_wrappers=1:nokey=1", path],
        capture_output=True, text=True, check=True).stdout
    return np.array([float(x) for x in out.split() if x != "N/A"])

t = frame_times(sys.argv[1])
fps = float(sys.argv[2])
d = np.diff(t) * 1000.0                      # intervals in ms
nominal = 1000.0 / fps
missing = np.rint(d / nominal).astype(int) - 1
print(f"{len(t)} frames, median interval {np.median(d):.3f} ms, max {d.max():.3f} ms")
for i in np.flatnonzero(missing > 0):
    print(f"after frame {i}: gap {d[i]:.1f} ms, about {missing[i]} frame(s) missing")
if np.any(d <= 0):
    print("timestamps repeat or go backwards at", np.flatnonzero(d <= 0))
```

At 30 fps the nominal interval is 33.3 ms, so one missing frame shows as a 66.7 ms gap and two as 100 ms. This only works if the recorder writes real capture times. A recorder that stamps frames at a constant rate regardless of what arrived will show perfect intervals over a drop; for those, use the device counters below.

### Clustered intervals: drops that keep the phase

Akhmetyanov et al. measured frame timestamps on 47 Android phone models and found two behaviours. On some, the intervals between frames scatter around one value; on others, "the smartphone occasionally drops some frames, not shifting the phase but breaking the Gaussian assumption presenting a set of clusters" ([Akhmetyanov et al., 2021](https://arxiv.org/abs/2107.00987)). The clusters sit at whole multiples of the frame period.

Their fix is to recover each frame's true exposure number before fitting the period. Take the smallest interval as a first guess of the period, τ_init, then number each frame by rounding: N_i = floor(t_i / τ_init + 0.5). With those numbers, a least-squares fit of the intervals against the number of periods each one spans gives the true period, even with frames missing. The same numbering tells you exactly where the drops were.

### Device counters

When container times are not enough, the device often records what happened before encoding.

| Counter | Where | What it records |
|---|---|---|
| `MSKP`, Main video frame SKiP | GoPro GPMF telemetry track | "Number frames skips or duplicated from sensor image captured to encoded frame. Normally 0." `LSKP` is the same for the low-resolution proxy file ([gpmf-parser](https://github.com/gopro/gpmf-parser)). |
| `TSMP`, Total Samples delivered | GoPro GPMF, per sensor stream | Counts "all the sample delivered since record start"; `EMPT` counts "payloads that contain no new data" ([gpmf-parser](https://github.com/gopro/gpmf-parser)). |
| Per-pulse sync table | 6C capture cap | `sync.csv` "has one row per pulse", with the monos' skipped frames marked ([6C capture cap](https://six-cam-samples.pages.dev/)). |

The 6C release shows what to expect from a triggered rig. Across three sessions totalling 11 minutes 53 seconds, the stereo pairs missed 4 frames at start-up in the first session and none afterwards, while the two side cameras missed 9 and 8, 6 and 5, and 3 and 2 frames ([6C capture cap](https://six-cam-samples.pages.dev/)).

Duplicates come mostly from recorders that treat audio as the master clock. OpenCamera Sensors, an Android app that records video with gyroscope and accelerometer data, disables audio for this reason: "When recording video with audio recording enabled, MediaRecorder adds extra frames to the video to match the sound" ([OpenCamera Sensors](https://github.com/MobileRoboticsSkoltech/OpenCamera-Sensors)).

### Lab Streaming Layer recordings

Lab Streaming Layer (LSL) smooths timestamps on import by assuming regular sampling. Its authors warn that for devices that switch rate or lose packets, "the load_xdf's attempt to linearly smooth the timestamps will significantly (even catastrophically) distort the data." Their check: compare the effective rate, "the number of samples divided by the recording length", with the rate in the stream's metadata, and if they differ, call `load_xdf` with `HandleJitterRemoval` set to false ([Kothe et al., 2025](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC12434378/)).

## Measuring offset and drift

Once drops are accounted for, each device's clock relates to the reference by a straight line, T = α · t + β: β is the offset and α − 1 the drift. [Why synchronisation matters](https://egocam.ai/sync/why-sync-matters/#clock-offset-and-clock-drift) explains the model and works through an example; this section covers how published systems estimate it.

### Fitting the line with outlier rejection

You need sync events near both ends of the recording; one event gives the offset but not the drift. RocSync decodes its LED clock in every frame where the board is visible, at the start and end, then fits the line robustly: "robust RANSAC regression [ 40 ] is applied to combine the independent timestamps from all decoded frames by fitting a linear function and computing the global offset and drift of the video" ([Meyer et al., 2025](https://arxiv.org/abs/2511.14948)). RANSAC fits the line to the largest consistent set of points, so misread frames are ignored. With only one sample, RocSync sets α = 1, "which assumes that the camera’s local clock has no drift relative to the global clock."

> **Diagram:** Clock drift between two cameras over an hour. Sync readings at the start give an offset of about 1240 ms and readings at the end, sixty minutes later, about 1312 ms. A straight line through both gives the offset for every frame in between; 72 ms of drift in an hour means the clocks run 20 parts per million apart.

Pupil Labs' LSL relay stores the result in exactly this form: a linear-regression mapping from each eye tracker's clock to LSL time, with an intercept and a slope (for example 0.9999924730866947, a drift of about 7.5 ppm), checked by switching a light "on and off four times" in view of both devices ([Pupil Labs](https://pupil-invisible-lsl-relay.readthedocs.io/en/latest/guides/device_sync.html)).

### Sensor rates from sample counts

Sensors inside a device can run on a much worse clock than its video. GoPro's documentation says audio and video share a crystal, but "Camera internal sensors or data via a connected Bluetooth device, will have timing errors in the range ±1%." Its reference clip shows the size of the effect:

| Stream | Set rate | Measured rate |
|---|---|---|
| Shutter | 23.976 Hz | 23.976 Hz |
| Accelerometer | 200 Hz | 201.923 Hz |
| Gyroscope | 400 Hz | 403.846 Hz |
| GPS | 18 Hz | 18.169 Hz |

Samples also arrive in uneven batches: "A 200Hz device, flushed at one second intervals, could have payload sample counts of 199, 202, 201, 198, 199, etc." GoPro's method is to ignore the nominal rate: "If you compare the TSMP of the first payload with the last, you can easily determine the number of samples, then compare with the time of the video track (or MP4 clock timing), establishing the average sample rate for the GPMF data" ([gpmf-parser](https://github.com/gopro/gpmf-parser)). The same applies to any IMU logged without its own timestamps.

### Recovering timing from arrival times

Some sensors stamp samples on their own clock and send them to a computer that stamps their arrival. Olson's passive method combines the two. Write p_i for the sensor's timestamp and q_i for the arrival time. The transport delay is never negative, so every difference p_i − q_i is a lower bound on the sensor's clock offset, and the fastest packets come closest to it. Allowing for a bounded drift rate between the clocks, the offset at sample j is estimated as:

```text
A(p_j) = max over i of [ (p_i - q_i) - f(|p_i - p_j|) ]
f(dp)  = max( a2 * dp / (1 + a2), a1 * dp / (1 - a1) )
t_j    = p_j - A(p_j)
```

Here a1 and a2 bound how slow or fast the sensor clock may run. Computed directly this takes O(N²) time. Olson instead keeps a running maximum, a pass that "is applied once in the forward direction and once in the reverse direction, and yields the same results as the O(N 2 ) algorithm in O(N ) time"; the forward pass alone works online. Olson proves that the method "never over-estimates the clock offset" and "will never produce a result worse than the naive synchronization algorithm" ([Olson, 2010](https://april.eecs.umich.edu/pdfs/olson2010.pdf)). The paper demonstrates this in simulation; how much it helps on your link depends on how often some packets get through with little delay.

### When drift is not constant

A straight line assumes the clock rate stays fixed, and it does not exactly: crystal frequency changes with temperature (see the [chrony FAQ quote](https://egocam.ai/sync/why-sync-matters/#worked-example-drift-from-two-sync-points)). Published systems handle this in two ways:

- **Continuous-time offsets.** For benchmarking consumer XR devices whose drift "can exceed 2 ms per minute", Shu et al. model the time offset as a B-spline that varies over the recording, estimated together with the trajectories and calibration ([Shu et al., 2025](https://arxiv.org/abs/2512.07221)).
- **Online estimation.** Ling et al. treat the camera–IMU offset inside a visual-inertial tracker "as a slowly time-varying quantity and model it as a Gaussian random walk" ([Ling et al., 2018](https://arxiv.org/abs/1810.05456)).

The simpler answer is more sync events, or continuous clock sync. A shared clock fixes less than it seems to. RoboCap's TCXO, a temperature-compensated crystal oscillator, has a "±1.81 ppm worst-case budget, bounding absolute timeline drift to ≈±6.5 ms per hour", but "Because all sensors share this clock, that drift affects the absolute timeline only and not inter-sensor synchronization" ([RoboCap](https://arxiv.org/abs/2610.07217)).

## Proving the streams are in sync

Looking at a clap in two videos is a sanity check, not a measurement. These published tests give numbers. All four RocSync results below come from [Meyer et al. (2025)](https://arxiv.org/abs/2511.14948).

| Test | Setup in the source | Result |
|---|---|---|
| Against a hardware sync cable | Two Azure Kinect DK cameras joined by a sync cable, 1920 × 1080 at 30 fps, 8.33 ms exposure; clock shown to each camera in turn, five 14-minute recordings | RMSE per run 0.38, 1.30, 1.94, 1.73 and 1.37 ms; mean 1.34 ms |
| Moving checkerboard, stereo reprojection error | GoPro Hero 12 and Hero 10, 4K at 60 fps, 1/480 s exposure; checkerboard moved in a circle | Mean error at 30 / 60 fps: RocSync with interpolation 1.02 / 0.95 px; RocSync nearest frame 3.07 / 1.11 px; light toggle 3.09 / 1.11 px; audio 11.34 / 13.91 px; QR timecode 54.60 / 55.14 px |
| Infrared tracker to RGB camera | Atracsys fusionTrack 500 and GoPro Hero 12, multimodal checkerboard with infrared fiducials | Stereo calibration error 1.81 ± 0.17 px over three runs |
| Hand triangulation | Four GoPro Hero 12, 4K at 30 fps, 1/240 s shutter; hands annotated by hand at six moments of motion | Triangulation error 8.80 ± 6.22 px nearest frame, 4.40 ± 1.14 px with interpolation; two camera pairs disagreed by 26.07 mm without interpolation and 7.52 mm with it |

How to use each test on your own rig:

- **Hardware cable as ground truth.** If two of your cameras can be wired together, run your sync method on them anyway and compare. RocSync attributes most of its 1.34 ms residual to the Kinect's [rolling shutter](https://egocam.ai/hardware/global-vs-rolling-shutter/): rows are exposed one after another, so the decoded time depends on where the clock sits in the frame. They suggest holding the clock farther from the camera to reduce it.
- **Moving checkerboard.** Calibrate a camera pair on frames of a moving board. The reprojection error "is minimized when the video streams are perfectly synchronized" (quoted on [sync methods compared](https://egocam.ai/sync/sync-methods-compared/#use-a-moving-target)). See [judging a calibration](https://egocam.ai/calibration/judging-a-calibration/) for what the error means.
- **Task footage.** Triangulate hands from two independent camera pairs and compare the results; the disagreement grows with timing error.
- **Motion on a rigid head.** Every camera on one rigid mount sees the same head rotation. The 6C team used this to find their monos' 4-frame lag (133 ms at 30 fps): "head turns move every camera on the same pulse, and all four line up at zero offset" ([6C capture cap](https://six-cam-samples.pages.dev/)). The same idea between camera and IMU is on [camera–IMU time offset](https://egocam.ai/calibration/camera-imu-time-offset/).

## Correcting the streams

| Method | What it changes | Best for |
|---|---|---|
| Timestamp remapping | Only the timestamps | Every dataset; the default |
| Feature interpolation | Derived signals (keypoints, poses), not images | Triangulation and calibration from unsynchronised cameras |
| Frame synthesis | Creates new images | Dense 3D reconstruction from unsynchronised cameras |
| Resampling, or dropping and repeating frames | The samples or frames themselves | Playback and fixed-rate files |

### Timestamp remapping

Store the corrected time T = α · t + β next to each frame and sample, and leave the media untouched. Nothing is lost, and a later, better fit can replace it. Hardware-triggered rigs can index by trigger pulse instead, as in the 6C's per-pulse `sync.csv`. Robot-learning formats then query by time: LeRobotDataset v3.0 loads temporal windows with `delta_timestamps`, for example `[-0.2, -0.1, 0.0]` seconds for a camera stream relative to the current frame ([Hugging Face LeRobot](https://huggingface.co/docs/lerobot/lerobot-dataset-v3)).

Remapping does not move exposures. Two free-running 30 fps cameras can still be up to half a frame apart ([why synchronisation matters](https://egocam.ai/sync/why-sync-matters/#two-meanings-of-in-sync)), which is what the next two methods address.

### Interpolating features

Interpolate what you extract, not the images. For a 2D keypoint u seen at corrected times T_k and T_k+1 in one camera, the value at a common time T is:

```text
u(T) = u(T_k) + (T - T_k) / (T_k+1 - T_k) * (u(T_k+1) - u(T_k))
```

This is what RocSync did in its hand test, halving the triangulation error. For continuous trajectories, splines (as in Shu et al.) can be evaluated at any corrected time.

### Synthesising frames

When a method needs images, such as dense multi-view reconstruction, frames can be synthesised at the common time. RocSync applied a frame-interpolation method (Jin et al.) and then MASt3R, a 3D reconstruction model; the interpolated frames gave "noticeably higher-quality reconstructions" and recovered a hammer that the nearest-frame version mostly failed to reconstruct ([Meyer et al., 2025](https://arxiv.org/abs/2511.14948)). Synthesised frames are generated images, so to the best of our knowledge they are best kept as a derived product beside the original footage, not in place of it.

### Resampling audio, dropping or repeating video

Fora Soft's guide to drift correction describes two options: continuous resampling, which changes the audio rate by a tiny amount (for a 50 ppm drift, "the receiver resamples the incoming 48,000 Hz audio to roughly 48,002.4 Hz"), and dropping or inserting whole frames, which in audio "produces clicks, gaps, and stutters". Video can only drop or repeat, and media players protect the audio: "In an audio-master design, the audio plays out at its own steady rate and is treated as the reference timeline; the video is then nudged to follow it by dropping or repeating whole frames as needed" ([Fora Soft](https://www.forasoft.com/learn/audio-for-video/articles-audio/drift-correction-resampling-frame-drop)).

That suits a viewer and harms a dataset: a repeated or dropped frame is a 33 ms step at 30 fps against the IMU. For capture data, keep every video frame paired with its own timestamp, and if audio must match, resample the audio to the video's clock.

## Prompts you can give an AI

The [comparison page](https://egocam.ai/sync/sync-methods-compared/#prompts-you-can-give-an-ai) has prompts for QR decoding, camera–IMU offset, two-point drift and jitter checks. These two cover methods from this page.

### Passive synchronisation from arrival times

```text
Write a Python module that implements Olson's (2010) passive synchronisation.
Inputs: numpy arrays p (sensor timestamps, seconds) and q (host arrival
timestamps, seconds) of equal length, and drift bounds a1 and a2 as fractions
(for example 1e-4 for 100 ppm; choose them from the clock specifications).
Define f(dp) = max(a2*dp/(1+a2), a1*dp/(1-a1)). Compute A[j] = max over i of
(p[i]-q[i]) - f(|p[i]-p[j]|) in O(N) with a forward pass
A[i] = max(x[i], A[i-1] - f(p[i]-p[i-1])) and a backward pass
A[i] = max(A[i], A[i+1] - f(p[i+1]-p[i])), where x = p - q. Return corrected
times t = p - A. Add a test that compares the result with the O(N^2) brute force
on 2,000 simulated samples with a known drift and exponential delays, checks
that A never exceeds the true offset, and prints the RMSE before and after.
```

### Frame numbering for drops that keep the phase

```text
Write a Python function that takes one camera's frame timestamps in seconds
(from ffprobe best_effort_timestamp_time, or from the device) and recovers each
frame's exposure number, following Akhmetyanov et al. (2021): shift so the
first timestamp is zero, set tau_init to the smallest positive interval, set
N_i = floor(t_i / tau_init + 0.5), then estimate the period tau by least squares
on the intervals against N_i - N_(i-1). Iterate once with the new tau. Report
tau, the frame rate, every place where N jumps by more than 1 (dropped frames),
any repeated N (duplicated frames), and the residual standard deviation. Test
it on synthetic 30 fps timestamps with Gaussian noise and a few frames removed.
```

## Sources

- The Open Robot Company (2026). [6C capture cap: samples and spec sheet](https://six-cam-samples.pages.dev/). Maker's page.
- Yu et al. (2026). [EgoKit: Towards unified low-cost egocentric data collection with heterogeneous devices](https://arxiv.org/abs/2605.16797). arXiv.
- Meyer, J. et al. (2025). [RocSync: Millisecond-accurate temporal synchronization for heterogeneous camera systems](https://arxiv.org/abs/2511.14948). arXiv.
- dreness. [ffprobe inter-frame delay graphing script (plotframetimes.py)](https://gist.github.com/dreness/916025a5f049c94f2177). GitHub gist.
- Akhmetyanov, A. et al. (2021). [Sub-millisecond video synchronization of multiple Android smartphones](https://arxiv.org/abs/2107.00987). *IEEE Sensors*.
- GoPro. [gpmf-parser and the GPMF specification](https://github.com/gopro/gpmf-parser).
- Olson, E. (2010). [A passive solution to the sensor synchronization problem](https://april.eecs.umich.edu/pdfs/olson2010.pdf). *IEEE/RSJ IROS*.
- MobileRoboticsSkoltech. [OpenCamera Sensors](https://github.com/MobileRoboticsSkoltech/OpenCamera-Sensors).
- Kothe, C. et al. (2025). [The lab streaming layer for synchronized multimodal recording](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC12434378/). *Imaging Neuroscience*.
- Pupil Labs. [Pupil Invisible LSL relay: time synchronization between two devices](https://pupil-invisible-lsl-relay.readthedocs.io/en/latest/guides/device_sync.html).
- Shu, Z., Bei, S., Li, L. and Chen, Z. (2025). [Spatiotemporal calibration and ground truth estimation for high-precision SLAM benchmarking in extended reality](https://arxiv.org/abs/2512.07221). arXiv.
- Ling, Y. et al. (2018). [Modeling varying camera-IMU time offset in optimization-based visual-inertial odometry](https://arxiv.org/abs/1810.05456). *ECCV*.
- Ali et al. (2026). [RoboCap](https://arxiv.org/abs/2610.07217). arXiv.
- Hugging Face. [LeRobotDataset v3.0](https://huggingface.co/docs/lerobot/lerobot-dataset-v3). Documentation.
- Fora Soft. [Drift correction: resampling, frame drop, frame insertion](https://www.forasoft.com/learn/audio-for-video/articles-audio/drift-correction-resampling-frame-drop).
