# C101 Lab: Your First Capture

> The hands-on lab of the C101 egocentric capture fundamentals course: record a short first-person session with whatever camera you have, copy and checksum the files, then inspect the container, every frame's timestamp, the sensor streams and the clock with documented tools (ffprobe, gpmfdemo, OpenCamera Sensors' CSV files, the vrs and mcap command-line tools). Every command is as the tools' documentation gives it, with checkpoints.

Page: https://egocam.ai/university/c101/lab/

This lab makes one short recording and then looks at it the way a pipeline's first stages would: are the files complete, did every frame arrive on time, which sensor streams are there and at what rate, and does the clock hold steady across the session. It needs no special hardware. Any camera works; GoPro cameras, Android phones running OpenCamera Sensors, Project Aria (VRS) and ROS 2 rigs (MCAP) each get an extra step.

Every command below is copied from the tool's own documentation, or follows its documented form with your own file names; the source is linked at each step. Square brackets mark values you fill in. The commands were run on FFmpeg 6.1 and on the sample files that ship with GoPro's gpmf-parser repository.

Work through [Lessons 1 to 4](https://egocam.ai/university/c101/) first, and keep the [checklist](https://egocam.ai/university/c101/checklist/) next to you.

## Step 1: Set up and write down the settings

Install FFmpeg, which provides `ffprobe`, and Python 3. Then write down, before you record:

- the camera model and serial number;
- resolution, frame rate and lens or field-of-view mode;
- whether stabilisation is on, and whether audio is recorded.

These settings decide what the footage can be used for later. The serial number ties the footage to one unit's calibration: units of the same model differ (RoboCap's fleet spans 590–630 px in focal length), so footage is processed with its own unit's numbers, never a model-wide default ([Nominal versus per-unit calibration](https://egocam.ai/calibration/factory-and-online-calibration/#nominal-versus-per-unit-calibration)). For SLAM and calibration, stabilisation is a problem: it rotates and crops the image frame by frame, so the camera model changes from frame to frame ([Action Cameras: lens modes](https://egocam.ai/hardware/action-cameras/#lens-modes-and-what-they-do-to-geometry), [Lens Effects That Break a Calibration](https://egocam.ai/lens-physics/lens-effects-that-break-calibration/)). If your camera lets you turn it off, do so and write it down.

**On an Android phone with OpenCamera Sensors**, the app's README notes two settings: audio recording is disabled by default because "When recording video with audio recording enabled, MediaRecorder adds extra frames to the video to match the sound", and it suggests disabling video stabilisation ([OpenCamera Sensors](https://github.com/MobileRoboticsSkoltech/OpenCamera-Sensors); [Smartphones for Capture](https://egocam.ai/hardware/smartphones-for-capture/#opencamera-sensors)).

## Step 2: Plan a short session

Plan about ten minutes of a simple task at a table that you can see clearly, alone in a private space. Recording anyone else needs their consent: see [Consent for Wearers](https://egocam.ai/privacy/consent-for-wearers/) and [Bystanders](https://egocam.ai/privacy/bystanders/).

Plan two **sync events**: switch a light on and off in clear view of the camera, once at the very start and once at the very end, and note the wall-clock time of each. A light is a visual event every camera that sees it records at once, with no travel delay, unlike sound ([LED and light-flash sync](https://egocam.ai/sync/software-and-visual-sync/#led-and-light-flash-sync)). If you have a second recording device, such as a phone, show the light to both: step 8 then measures the offset and drift between them.

## Step 3: Record

Put the camera on (a head strap, cap or glasses, whatever you have) and check in its preview that your hands and the task are in view. Then:

1. Start recording.
2. Make the first sync event.
3. Do the task for about ten minutes. Turn your head at normal speed a few times, so the footage includes the head motion a pipeline has to handle.
4. Make the second sync event.
5. Stop recording.

**Write down** the start and stop times, anything that went wrong, and the file names the camera shows.

## Step 4: Copy and checksum the files

Copy the files from the camera to your computer, then compute a checksum of the original and of the copy and compare them before you delete anything from the camera. The field guide's rule is to check every file before you delete the rig's copy ([Storage: integrity checks after copying](https://egocam.ai/capture-ops/storage-and-data-volume/#integrity-checks-after-copying)). With GNU coreutils:

```bash
sha256sum [your_file.mp4] > [your_file.mp4].sha256
sha256sum -c [your_file.mp4].sha256
```

`-c` (`--check`) reads file names and checksums from the file you give it and reports "whether the checksums match the contents of the named files" ([GNU coreutils: cksum common options](https://www.gnu.org/software/coreutils/manual/html_node/cksum-common-options.html)). Run the first line in the camera's folder and the second in the copy's folder.

Why compare checksums: once the camera is cleared, the copy is the only one left, so it has to be shown identical to the original before the original goes. A matching SHA-256 shows the copy holds the same bytes as the original; any difference, even one byte, changes the checksum.

**You should see** `[your_file.mp4]: OK`.

**For VRS files** (Project Aria), the field guide lists `vrs checksum-verbatim file.vrs` for a byte-for-byte comparison and `vrs check file.vrs`, which "decodes every record in the VRS file and prints how many records were decoded successfully" ([VRS CLI tool](https://facebookresearch.github.io/vrs/docs/VrsCliTool)).

## Step 5: Inspect the container

`ffprobe` reads any video file and reports its container and streams. These options are all from the [ffprobe documentation](https://ffmpeg.org/ffprobe.html): `-v` sets the log level, `-show_format` and `-show_streams` print the container and each stream, and `-of` (`-output_format`) chooses the output format.

```bash
ffprobe -v error -show_format -show_streams -of json [your_file.mp4]
```

To see only the metadata tags, use the documentation's own example argument for `-show_entries`:

```bash
ffprobe -v error -show_entries "stream_tags : format_tags" [your_file.mp4]
```

**You should see** one entry per stream with its `codec_type` (video, audio, data), `r_frame_rate` and `avg_frame_rate`, the duration, and tags such as `creation_time`. A tag like `creation_time` is one time for the whole file; the per-frame timestamps come in step 6.

**On a GoPro**, expect more than video and audio. GoPro's documentation states: "Telemetry carrying MP4 files will have a minimum of four tracks: Video, audio, timecode and telemetry (GPMF)." The telemetry stream shows as `codec_type=data` with `codec_tag_string=gpmd` ([Action Cameras: the GPMF track](https://egocam.ai/hardware/action-cameras/#getting-imu-and-gps-data-out-of-a-gopro-the-gpmf-track)). The `hero8.mp4` sample in GoPro's repository shows video, audio, a `tmcd` timecode stream, the `gpmd` telemetry stream and one more data stream.

> **Diagram:** What is inside each file, top to bottom. MCAP batches timestamped messages into compressed chunks and writes indexes in a summary at the end. VRS keeps one stream per device, each with configuration, state and data records, and writes its index last, so a cut-off file can be repaired. A GoPro MP4 carries telemetry as a fourth track of nested key-length-value items. From the MCAP spec, the VRS docs and the gpmf-parser README.

**For VRS and MCAP files**, use their own tools instead:

- `vrs [file.vrs]` with no sub-command prints the streams, record counts, the time range of the data records and records per second ([VRS CLI tool](https://facebookresearch.github.io/vrs/docs/VrsCliTool)).
- `mcap info [file.mcap]` "Report statistics about an MCAP file", and `mcap doctor [file.mcap]` "Check an MCAP file structure" ([MCAP CLI guide](https://github.com/foxglove/mcap/blob/main/website/docs/guides/cli.md)). In a ROS 2 install, `ros2 bag info [my_bag]` also summarises a bag ([Recording Formats](https://egocam.ai/capture-ops/recording-formats-vrs-mcap-gpmf/#mcap-ros2-bag-and-the-mcap-libraries)).

## Step 6: Read every frame's timestamp

A file can report 30 fps on average and still have frozen or skipped frames; the way to see this is to read every frame's timestamp ([Quality Control: dropped frames and frame timing](https://egocam.ai/capture-ops/quality-control/#dropped-frames-and-frame-timing)). The field guide's QC page describes a published script that does this with `ffprobe` and reports the mean gap, the 99th-percentile gap and the maximum gap against the target `1000 / fps` milliseconds. It also warns that recent FFmpeg releases report `pts_time` in the frame section, not `pkt_pts_time`. FFmpeg 6.1 does: its frame section lists `pts_time`, `pkt_dts_time`, `best_effort_timestamp_time` and `duration_time`.

Save this as `frame_gaps.py`. It asks `ffprobe` for the video stream's frame rate and every frame's `pts_time`, then prints the gap statistics and how often each gap occurs:

```python

from collections import Counter
from fractions import Fraction

path = sys.argv[1]

def probe(entries):
    out = subprocess.run(
        ["ffprobe", "-v", "error", "-select_streams", "v:0",
         "-show_entries", entries, "-of", "json", path],
        capture_output=True, text=True, check=True).stdout
    return json.loads(out)

stream = probe("stream=r_frame_rate,avg_frame_rate")["streams"][0]
fps = float(sys.argv[2]) if len(sys.argv) > 2 else float(Fraction(stream["r_frame_rate"]))
t = sorted(float(f["pts_time"]) for f in probe("frame=pts_time")["frames"] if "pts_time" in f)
gaps = [(b - a) * 1000 for a, b in zip(t, t[1:])]
s = sorted(gaps)

r, avg = stream['r_frame_rate'], stream['avg_frame_rate']
p99 = s[int(0.99 * (len(s) - 1))]
print(f'frames: {len(t)}, first {t[0]:.3f} s, last {t[-1]:.3f} s')
print(f'r_frame_rate {r}, avg_frame_rate {avg}')
print(f'target gap: {1000 / fps:.3f} ms')
print(f'mean {sum(s) / len(s):.3f} ms, p99 {p99:.3f} ms, max {s[-1]:.3f} ms')
print('gap in ms, rounded to 0.1, and its count:')
for g, n in sorted(Counter(round(g, 1) for g in gaps).items()):
    print(f'  {g:8.1f} : {n}')
```

Run it, optionally with the frame rate you set on the camera:

```bash
python3 frame_gaps.py [your_file.mp4] [your_fps]
```

`-select_streams v:0` picks the first video stream, and `-show_entries frame=pts_time` decodes the stream and prints each frame's presentation time ([ffprobe documentation](https://ffmpeg.org/ffprobe.html)). On a long file this takes a while.

**You should see** almost every gap at the target. On GoPro's `hero8.mp4` sample, all 378 gaps are 33.4 ms at 29.97 fps.

**Reading it.** A mean on target with a large maximum is a freeze; a high 99th percentile is recurring stutter ([Quality Control](https://egocam.ai/capture-ops/quality-control/#dropped-frames-and-frame-timing)). A gap of about twice the target is one missing frame interval. Some recorders hide drops by repeating frames instead: on Android, MediaRecorder's audio-matching frames mean that frame index × (1/30 s) is not a reliable time ([Smartphones: variable frame timing](https://egocam.ai/hardware/smartphones-for-capture/#variable-frame-timing-and-dropped-frames)), and from HERO9 a GoPro logs `MSKP`, the "Number frames skips or duplicated from sensor image captured to encoded frame. Normally 0." ([GPMF keys](https://egocam.ai/hardware/action-cameras/#gpmf-keys-that-matter-for-capture-pipelines)).

## Step 7: Check the motion data

What you can check depends on the camera.

**GoPro: the GPMF telemetry track.** Build GoPro's demo tool as the [gpmf-parser README](https://github.com/gopro/gpmf-parser) gives it, then run it on your file:

```bash
git clone https://github.com/gopro/gpmf-parser
cd gpmf-parser/demo/
make
./gpmfdemo [path/to/your_file.mp4]
```

The README says this "will return a brief overview of what metadata is stored in the given video file". In the demo's source (`demo/GPMF_demo.c`), computed sample rates are shown by default; `-h` lists the other switches.

**You should see** the video frame rate and frame count, then a line per stream such as `ACCL sampling rate = …Hz` and `GYRO sampling rate = …Hz`. On the `hero8.mp4` sample, ACCL and GYRO both compute to about 202.47 Hz and GPS5 to about 18.17 Hz. That the measured rates differ from the nominal ones is expected: GPMF stores no sample rate per sensor because "Camera internal sensors or data via a connected Bluetooth device, will have timing errors in the range ±1%", and the clock is worked out after capture against the MP4's own timing ([Action Cameras: timestamping IMU samples](https://egocam.ai/hardware/action-cameras/#timestamping-imu-samples-correctly)).

**Android with OpenCamera Sensors.** Each recording writes CSV files next to the video in `DCIM/OpenCamera`: `{VIDEO_NAME}_gyro.csv` and `{VIDEO_NAME}_accel.csv` with a `timestamp (ns)` per sample, and `{VIDEO_NAME}_timestamps.csv` with the timestamp of every video frame ([Smartphones for Capture](https://egocam.ai/hardware/smartphones-for-capture/#opencamera-sensors)). Compare the number of rows in `_timestamps.csv` with the frame count from step 6, and compute the gyroscope's rate from its first and last timestamps. Frame and IMU timestamps are only comparable if the camera's `SENSOR_INFO_TIMESTAMP_SOURCE` is `REALTIME`; the app's README says this can be checked on the preview message when RecSync is enabled: "Timestamp source" should read "realtime" ([Camera and IMU timestamps on Android](https://egocam.ai/hardware/smartphones-for-capture/#camera-and-imu-timestamps-on-android)).

**Other cameras.** If the camera records no motion data, note that. A pipeline that needs head pose from SLAM will want an IMU on the same clock as the camera (Lesson 3).

> **Diagram:** Camera frames are tens of milliseconds apart. The IMU reports many times in between, so it carries the motion across each gap, and through blur.

## Step 8: Find the sync events and measure the clock

Step through the video around each light event, for example in a player that shows frame times, and note the time of the first frame in which the light has changed. To find the frame times, use the `pts_time` list from step 6.

1. **One device.** Compare the time between the two light events in the video with the time between them on your wall-clock notes. Hand-written times are far coarser than a frame, so this checks the file's timeline for gross errors, not the clock's drift.
2. **Two devices.** Find both events in both recordings. The offset at each event is the difference between the two devices' times for it. Drift is the change in offset divided by the time between the events. The field guide's worked example: an offset of 1240 ms at the start and 1312 ms sixty minutes later is (1312 − 1240) ms ÷ 3,600,000 ms = 20 × 10⁻⁶, or 20 ppm ([Why Synchronisation Matters](https://egocam.ai/sync/why-sync-matters/#worked-example-how-far-50-ppm-drifts)).

> **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.

A single event only syncs to the nearest frame, so expect each offset to be uncertain by up to one frame unless the exposures are synchronised ([Why Synchronisation Matters](https://egocam.ai/sync/why-sync-matters/#two-meanings-of-in-sync)). At 50 ppm, ten minutes give 30 ms of drift, about one frame at 30 fps, so a short session shows little of it; course C203 measures drift properly.

## Step 9: Write the session record

Write a short record for the session, as a pipeline's ingest stage would expect. A JSON file next to the video works. Include:

- date, operator, location type, task description;
- camera model, serial number and settings from step 1;
- file names and their SHA-256 checksums from step 4;
- streams found in step 5 and sensor rates from step 7;
- frame-gap results from step 6;
- sync-event times, and offset and drift if you measured them in step 8;
- anything that went wrong.

The fields mirror what published pipelines record: EgoVerse tags every upload with fields such as `operator`, `lab`, `task`, `embodiment`, `scene` and `objects`, and Egocentric-10K pairs each clip with a `.json` holding `duration_sec`, `width`, `height`, `fps`, `size_bytes` and `codec` ([Anatomy of a Capture Pipeline, stage 5](https://egocam.ai/basics/anatomy-of-a-capture-pipeline/#stage-5-upload-ingestion-and-quality-control); [Quality Control: manifests](https://egocam.ai/capture-ops/quality-control/#manifests-and-hour-counting)). An ingest script can then check each field against the file itself.

**You are done** when you have the files, matching checksums, a frame-gap report, a list of the streams and their rates, and the session record. Keep them: the [prompts page](https://egocam.ai/university/c101/prompts/) has prompts that review each one.

## Sources

- FFmpeg. [ffprobe documentation](https://ffmpeg.org/ffprobe.html).
- GoPro. [gpmf-parser README and demo source](https://github.com/gopro/gpmf-parser) (commit `9a71506`; the `hero8.mp4` sample).
- GNU coreutils manual: [sha2 utilities](https://www.gnu.org/software/coreutils/manual/html_node/sha2-utilities.html) and [cksum common options](https://www.gnu.org/software/coreutils/manual/html_node/cksum-common-options.html).
- Meta. [The vrs command line tool](https://facebookresearch.github.io/vrs/docs/VrsCliTool).
- Foxglove. [MCAP CLI guide](https://github.com/foxglove/mcap/blob/main/website/docs/guides/cli.md).
- MobileRoboticsSkoltech. [OpenCamera Sensors README](https://github.com/MobileRoboticsSkoltech/OpenCamera-Sensors).
- Field guide: [Quality Control for Egocentric Footage](https://egocam.ai/capture-ops/quality-control/), [Storage, Upload and Data Volume](https://egocam.ai/capture-ops/storage-and-data-volume/), [Recording Formats](https://egocam.ai/capture-ops/recording-formats-vrs-mcap-gpmf/), [Action Cameras](https://egocam.ai/hardware/action-cameras/), [Smartphones for Capture](https://egocam.ai/hardware/smartphones-for-capture/), [Why Synchronisation Matters](https://egocam.ai/sync/why-sync-matters/), [Software and Visual Sync](https://egocam.ai/sync/software-and-visual-sync/), [Anatomy of a Capture Pipeline](https://egocam.ai/basics/anatomy-of-a-capture-pipeline/), [Factory, On-Device and Online Calibration](https://egocam.ai/calibration/factory-and-online-calibration/).
