# MCAP video ingest

Upload a video topic from an [MCAP](https://mcap.dev/) file with [`add_mcap_video()`](https://dev.nominal.io/python/ref/generated/nominal.core.Dataset.md#nominal.core.Dataset.add_mcap_video "nominal.core.Dataset.add_mcap_video").
The topic must use the `foxglove.CompressedVideo` schema with H.264 frames. Frame times come from the file.

The examples also need `pip install mcap huggingface_hub`.

## Connect the client

This guide assumes you have [installed](https://dev.nominal.io/python/guides/install.md) the client and setup your [API keys](https://dev.nominal.io/python/guides/api-keys-setup.md).

```python
from nominal.core import NominalClient

client = NominalClient.from_profile("default")
```

## Find the video topics

This example downloads a sample flight simulator recording and lists its video topics with the `mcap` library:

```python
from huggingface_hub import hf_hub_download
from mcap.reader import make_reader

path = hf_hub_download(repo_id="nominal-io/xplane", filename="xplane.mcap", repo_type="dataset")

with open(path, "rb") as f:
    summary = make_reader(f).get_summary()
    video_topics = [
        channel.topic
        for channel in summary.channels.values()
        if summary.schemas[channel.schema_id].name == "foxglove.CompressedVideo"
    ]
print(video_topics)
```

## Upload a topic

```python
dataset = client.create_dataset("X-Plane simulation")
file = dataset.add_mcap_video(path, channel="cockpit_cam", topic="video")
file.poll_until_ingestion_completed()
```

To review it, attach the dataset to a run as in [Video ingest](https://dev.nominal.io/python/guides/video/video-ingest.md#review-it-in-a-run).
For the file’s protobuf-encoded topics, use [`add_mcap()`](https://dev.nominal.io/python/ref/generated/nominal.core.Dataset.md#nominal.core.Dataset.add_mcap "nominal.core.Dataset.add_mcap").
