# Operavue video timestamp inspector

Version 1.0, October 18, 2026. Python 3.9 or later, standard library only. MIT terms are included in the script.

Guide: https://operavue.com/insights/planning-2k-stereoscopic-surgical-capture#timestamp-check

This tool inspects a local JSON export of one video stream's frame timestamps. It does not open recordings, upload files, measure stereo alignment, or certify dataset quality. Use only files you are authorized to inspect.

## Run the synthetic example first

Download these files to one folder:

- https://operavue.com/downloads/audit-video-timestamps.py
- https://operavue.com/downloads/video-timestamps-example.json
- https://operavue.com/downloads/video-timestamps-expected.json

Run from that folder:

```sh
python3 audit-video-timestamps.py video-timestamps-example.json --max-gap-ms 50
```

The eight invented records contain seven valid timestamps and one missing value. Of seven adjacent pairs, five are compared and two skipped. Findings: one interval above 50 ms, one repeated timestamp, one backward step, and one missing value. Positive intervals have minimum/median/maximum values of 33/33/100 ms. The missing record prevents comparison across that point.

The example intentionally exits with code 1. Compare its JSON with video-timestamps-expected.json. The 50 ms threshold demonstrates the check; it is not a capture recommendation.

## Export a real file's timestamps

Install FFprobe separately using the FFmpeg project's official download guidance: https://ffmpeg.org/download.html. It is not bundled with this tool. Record your FFprobe version and preserve the selected stream, source/export identity, and error log with the report.

This POSIX-shell command reads a local file and selects the first ordinary video stream, excluding attached artwork. Confirm that this is the view you intend to inspect. Use a fresh output folder so the redirections do not overwrite earlier reports.

```sh
ffprobe -v error -protocol_whitelist file -select_streams V:0 \
  -show_frames \
  -show_entries frame=media_type,stream_index,best_effort_timestamp_time \
  -show_optional_fields always -of json -i "./recording.mp4" \
  > "./frame-times.json" 2> "./frame-times-errors.log"
```

The best_effort_timestamp_time field contains decimal seconds. The inspector reports intervals and accepts its threshold in milliseconds.

Only proceed after FFprobe finishes successfully. Inspect the error log before treating its output as complete. Then run with a project-specific positive threshold in milliseconds:

```sh
python3 audit-video-timestamps.py frame-times.json --max-gap-ms 50
```

## Reproduce the export with generated media

The eight-record example above tests the inspector's arithmetic. For an optional check through encoded media and FFprobe, download this recipe beside the inspector:

- https://operavue.com/downloads/verify-video-timing-media.py

It requires Python 3.9 or later, FFmpeg with libx264, and FFprobe on your PATH. It does not install packages, download recordings, or use clinical data. Use an output directory that does not exist:

```sh
python3 verify-video-timing-media.py --output timing-verification
```

The recipe generates a 60-frame, 30 fps test pattern; a version with the same images and a deliberate 100 ms timeline shift from zero-based frame index 30 onward; and an audio-first, two-video-stream file. It checks every exported timestamp against the known input sequence. The shift should create one approximately 133.333 ms interval from index 29 to 30, rather than a 100 ms interval, because the ordinary 33.333 ms step remains. Ordered decoded image hashes are compared separately from timestamps.

A fourth case supplies invalid text with an MP4 extension. A failed FFprobe export must prevent the inspector from running. For valid cases, a nonzero FFprobe exit or a nonempty error log stops the check. Generated media, version records, logs, exports, reports, and the summary remain in the output directory for inspection.

This check covers these controlled files and the installed toolchain. It does not establish camera-clock synchronization, stereo exposure alignment, attached-cover-art exclusion, recovery from damaged video, or compatibility with every codec or build. The 50 ms threshold is an illustrative test setting.

Recorded execution: all four cases passed with FFmpeg and FFprobe 9.0.2 on macOS arm64 on October 18, 2026 (America/New_York). The deliberate shifted interval was 133.333 ms. All 60 ordered decoded image hashes matched between the regular and shifted files. Results, tool versions, script hashes, counts, and scope: https://operavue.com/downloads/video-timing-media-verification.json.

## Interpret the inspector result

These exit codes belong to audit-video-timestamps.py:

- Exit 0: no timestamp findings under the chosen threshold. This is not a quality pass.
- Exit 1: missing/invalid timestamps or interval findings. Investigate them in context.
- Exit 2: malformed input or invalid invocation prevented inspection.

Frame indices are zero-based positions in the supplied array. The tool retains that order and does not sort, interpolate, or compare across missing/invalid values. Negative absolute timestamps are allowed. The report includes full finding counts, at most 20 issue details, and statistics for positive adjacent intervals. Input must represent one video stream; stream/media metadata is checked when present. The stream_metadata field records observed indices and how many frame records supplied each identity field; missing metadata does not verify stream selection. No comparable adjacent pairs produces an insufficient_adjacent_pairs finding, not exit 0.

A large interval can reflect variable timing or an export transformation; it does not prove a dropped image. A repeated timestamp does not prove repeated image content. Best-effort timestamps describe a decoder-estimated presentation timeline, not a verified exposure clock. Two clean timelines do not prove simultaneous capture.

Preserve this report as supporting evidence alongside the recording specification, clock mapping, capture logs, and independent synchronization measurements. Do not repair the source merely to remove findings without documenting the transformation.

## References

- FFprobe options and stream selection: https://ffmpeg.org/ffprobe.html
- FFmpeg frame timestamp definitions: https://ffmpeg.org/doxygen/trunk/structAVFrame.html

The synthetic example demonstrates inspector behavior. It is not clinical data or a validation of any camera, robot, or FFprobe build. Operavue's public website accepts business inquiries, not recording uploads.
