Video tags & events
Beyond the in-training tag_rendering / mark_rendering_event
helpers, metrana exposes the full video annotation API for working with videos after the fact — from a
notebook, an eval job, or a post-processing script.
There are three concepts:
- Video tag — a workspace-level label (e.g.
"personal-best") you attach to whole videos. - Event type — a workspace-level named condition (e.g.
"collision","goal_reached"). - Event — one occurrence of an event type on a video, over a
[from_frame, to_frame]range.
Tags and event types are workspace-scoped and reusable; events are per-video.
Authentication & resolution
Section titled “Authentication & resolution”Every function resolves the same way as the artifact functions:
workspacedefaults to the active run’s workspace frominit().api_keyfalls back toMETRANA_API_KEY.base_urlfalls back toartifact_api_urlfrominit(), thenMETRANA_ARTIFACT_API_URL, then the built-in default (see Service endpoints).
Errors surface as the shared MetranaArtifact* hierarchy.
create_video_tag is idempotent on (workspace, tag_name) — it creates the tag or returns the existing one:
tag = metrana.create_video_tag("personal-best", description="Best return so far")
tag.tag_id # strtag.tag_name # strtag.description # str | Nonemetrana.list_video_tags() # -> list[VideoTag] (all pages)metrana.update_video_tag(tag.tag_id, tag_name="pb") # patch name and/or descriptionmetrana.delete_video_tag(tag.tag_id) # cascade-detaches from all videosAttach and detach a tag on a specific video (apply_video_tag is idempotent):
metrana.apply_video_tag(video_id, tag.tag_id)metrana.remove_video_tag(video_id, tag.tag_id)Event types
Section titled “Event types”create_video_event_type is idempotent on (workspace, condition_name):
et = metrana.create_video_event_type("collision", description="Agent hit an obstacle")
et.event_type_id # stret.condition_name # stret.description # str | Nonemetrana.list_video_event_types() # -> list[VideoEventType]metrana.update_video_event_type(et.event_type_id, condition_name="crash")metrana.delete_video_event_type(et.event_type_id) # cascade-deletes its occurrencesEvents (occurrences)
Section titled “Events (occurrences)”Mark an occurrence of an event type on a video over an inclusive frame range:
event = metrana.apply_video_event( video_id, event_type_id=et.event_type_id, from_frame=120, to_frame=138,)
event.event_id # strevent.event_type_id # strevent.video_id # strevent.from_frame # intevent.to_frame # intmetrana.list_video_events(video_id) # -> list[VideoEvent], by start framemetrana.update_video_event(event.event_id, to_frame=142) # patch either side of the rangemetrana.delete_video_event(event.event_id)When to use these vs. the in-training helpers
Section titled “When to use these vs. the in-training helpers”Reach for tag_rendering / mark_rendering_event when you’re
generating the video in a training loop and already know what’s happening frame-by-frame — they buffer
against the encoding rendering and apply automatically once it uploads, and drive
upload_renderings="triggered".
Reach for the functions on this page when you’re annotating existing videos — labelling a batch after an eval, correcting an occurrence, or curating tags across a workspace.