MCAP Video ingest in Python
This guide will walk you through the process of downloading a sample MCAP file, inspecting it to find video topics, and ingesting the video into Nominal.
Prerequisites
Make sure you have the following Python packages installed:
- huggingface_hub
- mcap
- nominal
You can install them all using:
Step 1: Download the Sample MCAP File
First, download a sample MCAP file using the huggingface_hub library.
Step 2: Inspect the MCAP File to Find Video Topics
Next, use the mcap library to inspect the MCAP file and identify available video topics.
This script will output the video topics available in the MCAP file, which you’ll use in the next step.
Step 3: Connect to Nominal
Before ingesting the video, ensure you’re connected to Nominal.
Concepts
- Base URL: The URL through which the Nominal API is accessed (typically
https://api.gov.nominal.io/api
; shown under Settings → API keys). - Workspace: A mechanism by which to isolate datasets; each user has one or more workspace, and data in one cannot be seen from another. Note that a token / API key is attached to a user, and may access multiple workspaces.
- Profile: A combination of base URL, API key, and workspace.
There are two primary ways of authenticating the Nominal Client. The first is to use a profile stored on disk, and the second is to use a token directly.
Storing credentials to disk
Run the following in a terminal and follow on-screen prompts to set up a connection profile:
Here, “default” can be any name chosen to represent this profile (reminder: a profile represents a base URL, API key, and workspace).
The profile will be stored in ~/.config/nominal/config.yml
, and can then be used to create a client:
If you have previously used nom
to store credentials, prior to the availability of profiles, you will need to migrate your old configuration file (~/.nominal.yml
) to the new format (~/.config/nominal/config.yml
).
You can do this with the following command:
Directly using credentials in your scripts
NOTE: you should never share your Nominal API key with anyone. We therefore recommend that you not save it in your code and/or scripts.
Step 4: Ingest the Video
Finally, upload the video to Nominal using a topic from the list.