Expand description
Lossless conversion of DPI / timed-metadata signalling between SCTE-35,
HLS #EXT-X-DATERANGE and DASH emsg (ISO/IEC 23009-1 §5.10.3.3,
ANSI/SCTE 214-1:2024 §7.7). no_std + alloc; it depends on
broadcast-common, broadcast-core, broadcast-hls, isobmff, jiff
and scte35-splice. caption-convert, transmux, hls-runtime,
media-plane, multimux, media-doctor and compliance-probe use it.
The original splice_info_section bytes are carried verbatim, so an
event can always be rendered back to its source form.
§Quickstart
Take one real SCTE-35 cue, render it as an HLS date range and a DASH
emsg, then recover the original bytes from the emsg.
use broadcast_core::timescale::Timescale;
use isobmff::emsg::PresentationTime;
use timed_metadata::convert::{EmsgConfig, emsg_to_scte35};
use timed_metadata::{TimeAnchor, Timeline};
let hex = "FC302100000000000000FFF01005000007D27FEF7F7E0020F580C0000000000088B9661D";
let raw: Vec<u8> = (0..hex.len())
.step_by(2)
.map(|index| u8::from_str_radix(&hex[index..index + 2], 16).unwrap())
.collect();
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();
let line = timeline.to_daterange(&event).unwrap().to_tag_line().unwrap();
assert!(line.starts_with("#EXT-X-DATERANGE:"));
let config = EmsgConfig::new(
Timescale::try_new(90_000).expect("a non-zero timescale"),
PresentationTime::Absolute(90_000),
Some(24 * 90_000),
"34".to_string(),
event.id.unwrap_or(0),
);
let emsg = timeline.to_emsg(&event, &config).unwrap();
assert_eq!(emsg_to_scte35(&emsg).unwrap(), raw);§How do I…
- Convert SCTE-35 to a date range:
convert::scte35_to_daterangeorTimeline::to_daterange,examples/scte35_to_hls.rs. - Convert SCTE-35 to a DASH
emsg:convert::scte35_to_emsgorTimeline::to_emsg,examples/scte35_to_dash.rs. - Recover SCTE-35 bytes from an
emsg:convert::emsg_to_scte35,examples/scte35_to_dash.rs. - Re-time an
emsgbetween versions 0 and 1:convert::emsg_to_v0andconvert::emsg_to_v1,examples/scte35_to_dash.rs. - Map PTS to UTC and unwrap 33-bit timestamps:
TimelineandTimeAnchor,examples/scte35_to_hls.rs. - Unroll PTS outside a session:
PtsUnroller,examples/scte35_to_hls.rs. - Read a neutral event’s id, kind and source:
TimedEventandSourcePayload,examples/scte35_to_hls.rs. - Handle typed conversion failures:
Error,examples/scte35_to_hls.rs.
§Modules
Session: timeline (PTS/UTC timeline and event session), anchor
(PTS-to-wall-clock anchor).
Conversion: convert (pure format conversions and their configuration),
event (neutral event model).
Shared vocabulary: error (typed conversion failures).
§Feature flags
std(default):std::error::Errorimpls andstdin dependencies.serde:Serialize/Deserializeon supported public types.
§Spec citations
ANSI/SCTE 35 §7.7 (splice_info_section), ANSI/SCTE 214-1:2024 §7.7.1(2),
§7.7.3 (private/specs-verified/scte/dash/scte-214-1-2024.md); RFC 8216bis
§4.4.5.1 (EXT-X-DATERANGE); ISO/IEC 23009-1 §5.10.3.3 (emsg).
Re-exports§
pub use anchor::TimeAnchor;pub use error::Error;pub use error::Result;pub use event::EventKind;pub use event::MediaDuration;pub use event::MediaTime;pub use event::SourcePayload;pub use event::TimedEvent;pub use timeline::PtsUnroller;pub use timeline::Timeline;
Modules§
- anchor
- Media-time ↔ wall-clock mapping for conversions that cross into UTC.
- convert
- Pure conversion functions (the foundation layer).
- error
- Crate error type.
- event
- Canonical timed-metadata event (the hub of the hub-and-spoke model).
- timeline
- Stateful conversion session: holds the wall-clock anchor and unrolls 33-bit PTS wrap across a stream of events.