Skip to content

Metadata

This document specifies the metadata associated with video fragments, where it is stored, and how it is synchronized.

See Terminology for the distinction between fragments and join fragments.

Metadata Locations

Metadata exists in two locations:

LocationContentsPurpose
In-streamTimestamps, durationRequired for browser playback
ApplicationSentinel ID, sequence, framerate, file pathsServer/Proctor coordination

In-Stream Metadata

This metadata is embedded in the fMP4 container by the Sentinel encoder. The Server does not modify it.

Initialization Segment

FieldLocationDescription
TimescalemoovmdhdTime units per second (e.g., 90000)
ResolutionmoovtkhdWidth and height in pixels
Codec infomoovstsdH.264 SPS/PPS

Media Fragment

In this spec, this refers to a media fragment (moof + mdat).

FieldLocationDescription
Base decode timemooftfdtTimestamp of first frame in fragment
Sample durationsmooftrunDuration of each frame
Sample sizesmooftrunByte size of each frame
The in-stream metadata is sufficient for a browser to decode and display the video at correct timing. The application metadata provides additional context for stream management.

Application Metadata

This metadata is managed by the Server and stored in memory, with periodic persistence to the database.

Per-Session Metadata

FieldTypeDescription
sentinelIdstringUnique identifier for the Sentinel
sessionIdstringUnique identifier for this session
startTimetimestampWhen the session started
resolutionobjectWidth and height
initSegmentPathstringPath to initialization segment on disk

Example:

{
  "sentinelId": "sentinel-a1b2c3",
  "sessionId": "2026-02-05T14-30-00Z",
  "startTime": "2026-02-05T14:30:00.000Z",
  "resolution": {
    "width": 1920,
    "height": 1080
  },
  "initSegmentPath": "/var/franklyn/video/sentinel-a1b2c3/2026-02-05T14-30-00Z/init.mp4"
}

Per-Fragment Metadata

This spec uses the term fragment for the live-delivery unit.

FieldTypeDescription
sequenceintegerFragment sequence number
startTimetimestampWall-clock time of first frame
durationintegerDuration in milliseconds
frameratenumberFrames per second during this fragment
filePathstringPath to fragment file on disk
isJoinbooleanTrue if this fragment starts with an IDR keyframe

Example:

{
  "sequence": 142,
  "startTime": "2026-02-05T14:35:42.000Z",
  "duration": 4800,
  "framerate": 5,
  "filePath": "/var/franklyn/video/sentinel-a1b2c3/2026-02-05T14-30-00Z/000142.m4s",
  "isJoin": false
}

Memory Storage

During active streaming, all application metadata is held in memory for fast access.

Data Structure (Conceptual)

Server Memory
├── Active Sessions
│   └── {sentinelId}
│       ├── Session Metadata
│       ├── Init Segment (bytes)
│       └── Fragment Buffer
│           ├── Fragment 140: { metadata, bytes }
│           ├── Fragment 141: { metadata, bytes }
│           ├── Fragment 142: { metadata, bytes }
│           └── ...

Access Patterns

OperationData Source
Proctor joins streamMemory (initialization segment + buffered fragments)
New fragment arrivesMemory (add to buffer, update metadata)
Proctor requests historical fragmentDisk (metadata points to file path)

Database Persistence

Application metadata is periodically synced to the database for durability.

Sync Strategy

AspectBehavior
TriggerPeriodic (e.g., every 5-10 seconds)
ScopeAll new/updated fragment metadata since last sync
BlockingNon-blocking (sync happens asynchronously)
Failure handlingRetry on next sync interval
The sync interval is an implementation detail. The key requirement is that real-time operations (live streaming) never block on database writes.

What is Persisted

DataPersisted
Session metadataYes
Fragment metadataYes
Fragment bytesNo (stored as files on disk)
Init segment bytesNo (stored as file on disk)

Recovery

On Server restart:

  1. Load session and fragment metadata from database
  2. Locate fragment files on disk using stored paths
  3. Resume streaming for any Sentinels that reconnect

Metadata for Historical Access

When a Proctor requests historical fragments (via HTTP), the Server uses the persisted metadata to:

  1. Identify which fragments exist for a Sentinel/session
  2. Locate the fragment files on disk
  3. Serve the requested fragment bytes

The Proctor needs to know:

  • sentinelId and sessionId to identify the stream
  • sequence to request specific fragments

The exact API for querying available fragments is implementation-defined. The metadata structure above provides the necessary information.

Last updated on • J.H.F.