timed-metadata 0.13.0

Convert DPI / timed-metadata signalling between SCTE-35, HLS EXT-X-DATERANGE and DASH emsg. no_std.
Documentation

timed-metadata

crates.io docs.rs License

Convert DPI / timed-metadata signalling between SCTE-35, HLS EXT-X-DATERANGE and DASH emsg losslessly. no_std + alloc, independently versioned.

Built on scte35-splice, isobmff, broadcast-hls, broadcast-common and broadcast-core; used by caption-convert, transmux, hls-runtime and multimux. The crate-root guide has the quickstart, the How do I... task index, the module map, feature flags and spec citations.

[dependencies]
timed-metadata = "0.13"

What it does / what it does not

Ad-insertion and segmentation signalling travels in three formats across an OTT chain: SCTE-35 splice_info_section in MPEG-2 TS, #EXT-X-DATERANGE in an HLS playlist, and an inband emsg box in MP4/CMAF. This crate translates between them. The original splice_info_section bytes travel verbatim (DATERANGE SCTE35-* hex, emsg message_data), so nothing is re-encoded or interpreted away. A stateful Timeline session adds a wall-clock anchor and 33-bit PTS wrap-unrolling.

It does not parse SCTE-35 itself (that is scte35-splice), does not parse or write full HLS playlists (broadcast-hls) or full MP4 files, and does not make ad decisions. It does not convert captions: caption-convert owns the CEA-608/708 and Teletext cue extractors and the WebVTT/SRT writers, over dvb-vbi's page decode.

Standards supported

Standard Edition Scope Status Notes
ANSI/SCTE 35 2023r1 (via scte35-splice) splice_info_section carried verbatim and parsed for id/time/duration Full
IETF RFC 8216 / draft-pantos-hls-rfc8216bis draft -22 (1 May 2026, private/specs-verified/ietf/specs/ietf_draft_pantos_hls_rfc8216bis.txt) §4.4.5.1 EXT-X-DATERANGE attributes incl. SCTE35-CMD/OUT/IN Partial SCTE-35 to DATERANGE and DATERANGE tag-line parse/render; no DATERANGE to SCTE-35 event conversion.
ANSI/SCTE 214-1 2024, private/specs-verified/scte/dash/scte-214-1-2024.md §7.7.1 inband events, §7.7.3 SCTE 35 inband emsg Full for the binary scheme The 214-3 2015 transcription only held the scheme identity; the rules moved into 214-1 2024. MPD EventStream (§7.7.2.1) is not implemented.
ISO/IEC 23009-1 (via isobmff) unverified §5.10.3.3 Event Message Box, v0 <-> v1 re-timing Full emsg_to_v0 / emsg_to_v1

Conversion matrix

From \ To HLS EXT-X-DATERANGE DASH emsg SCTE-35 bytes
SCTE-35 splice_info_section Timeline::to_daterange / convert::scte35_to_daterange Timeline::to_emsg / convert::scte35_to_emsg identity
DASH emsg (SCTE-35 scheme) not provided emsg_to_v0 / emsg_to_v1 (re-time) convert::emsg_to_scte35
HLS EXT-X-DATERANGE tag-line DateRange::parse_tag_line / to_tag_line not provided raw bytes available on the parsed DateRange; no typed conversion

Feature flags

Feature Default Description
std on Enable std in all dependencies. Without it: no_std + alloc, all conversions still available.
serde off Serialize/Deserialize on public types where supported.

serde is opt-in and off by default; enable it explicitly:

timed-metadata = { version = "0.13", features = ["serde"] }

Quick start

use broadcast_core::timescale::Timescale;
use isobmff::emsg::PresentationTime;
use timed_metadata::convert::{EmsgConfig, emsg_to_scte35};
use timed_metadata::{TimeAnchor, Timeline};

// A real Unified Streaming splice_info_section (splice id 2002, 24 s break).
let hex = "FC302100000000000000FFF01005000007D27FEF7F7E0020F580C0000000000088B9661D";
let raw: Vec<u8> = (0..hex.len())
    .step_by(2)
    .map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap())
    .collect();

// Wall-clock anchor: PTS 0 == 2024-01-15T12:00:00 UTC.
let anchor = TimeAnchor { pts_90k: 0, utc_epoch_ms: 1_705_320_000_000 };
let mut timeline = Timeline::new(anchor);
let event = timeline.push_scte35(&raw).unwrap();

// Edge 1: SCTE-35 -> HLS EXT-X-DATERANGE.
let line = timeline.to_daterange(&event).unwrap().to_tag_line().unwrap();
assert!(line.starts_with("#EXT-X-DATERANGE:"));
assert!(line.contains("SCTE35-"));

// Edge 2: SCTE-35 -> DASH emsg, and Edge 3: back to the verbatim section.
let cfg = EmsgConfig::new(
    Timescale::try_new(90_000).expect("a non-zero timescale"),
    PresentationTime::Absolute(90_000),
    Some(2_160_000), // 24 s * 90000
    "34".to_string(),
    event.id.unwrap_or(0),
);
let emsg = timeline.to_emsg(&event, &cfg).unwrap();
assert_eq!(emsg_to_scte35(&emsg).unwrap(), raw);

What is implemented

  • convert: pure functions scte35_to_daterange, scte35_to_emsg, emsg_to_scte35, scte35_event_duration, emsg_to_v0, emsg_to_v1; EmsgConfig, SegmentTiming. SCTE 35 emsg emission is version 1 and an unknown duration is None / 0xFFFFFFFF (214-1 2024 §7.7.1, §7.7.3).
  • Timeline / TimeAnchor: stateful session, PTS to UTC mapping, 33-bit PTS wrap-unroll via broadcast_common::clock33; RFC 3339 output through jiff (out-of-range instants clamp rather than print odd years).
  • DateRange: from broadcast-hls, the workspace's one typed EXT-X-DATERANGE model (checked rendering: to_tag_line returns Result, and an ID/CLASS containing ", CR or LF, or a NaN / negative duration, is rejected). This crate only decides which attributes a SCTE-35 event puts on it.
  • TimedEvent: neutral event (EventKind, id, media time and duration, source payload).
  • PtsUnroller: the 33-bit PTS wrap-unroll Timeline uses, exported so a caption extractor in caption-convert unrolls on the same timeline.

Design notes

  • Lossless carriage: SCTE-35 bytes are never re-encoded.
  • Error is #[non_exhaustive]; the crate is #![forbid(unsafe_code)] and no_std + alloc without std.
  • Hostile-input hardening: checked time arithmetic, a clock33 tripwire test.

Related crates

Depends on broadcast-common, broadcast-core, broadcast-hls, isobmff and scte35-splice. Used by caption-convert, transmux, hls-runtime, media-plane, multimux, media-doctor and compliance-probe.

MSRV and licence

Rust 1.95.0. MIT OR Apache-2.0.