> ## Documentation Index
> Fetch the complete documentation index at: https://docs.efference.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MCAP Replay

> Replay a recorded session through the same API as a live device

Set `InitParameters::input_type` to `MCAP` and provide a recording path. The
normal `grab()` and retrieval loop remains unchanged.

```cpp theme={null}
InitParameters init;
init.input_type = INPUT_TYPE::MCAP;
init.mcap_path  = "session.mcap";

Device dev;
if (dev.open(init) != ERROR_CODE::SUCCESS) return 1;

Mat image;
SensorsData sensors;
for (;;) {
    ERROR_CODE ec = dev.grab();
    if (ec == ERROR_CODE::END_OF_BUFFER) break;   // file exhausted
    if (ec != ERROR_CODE::SUCCESS)       continue;
    dev.retrieve_image(image);
    dev.retrieve_imu(sensors);
}
dev.close();
```

Replay differs from a live session in four ways:

* `grab()` returns `END_OF_BUFFER` when the file is exhausted, the one loop-exit
  condition unique to replay.
* The recording's codec overrides `InitParameters::compression`; the SDK
  decodes the format stored in the file.
* Control-plane calls (health, WiFi, recording management) return
  `INVALID_FUNCTION_CALL`, since there is no device.
* Timestamps are the original capture timestamps from the recording.

Both host-file and device-local recordings replay identically, since they
share one schema. Recordings also open directly in Foxglove. To extract the raw
H.264/H.265 elementary stream from a session, use the bundled script:

```sh theme={null}
python3 sdk/linux/tools/mcap_to_video.py session.mcap session.h265
```

The script writes an elementary stream, not a container. Wrap it in a container
to produce a playable file, for example
`ffmpeg -i session.h265 -c copy session.mp4`.
