This document is the current maintainer reference for tidemark.
tidemark is a Go CLI for watching live streaming inputs and emitting ad-marker or metadata events. It supports:
- HLS playlists with SCTE-35 manifest tags.
- HLS media segments containing SCTE-35 or timed ID3.
- Raw MPEGTS over HTTP.
- UDP multicast MPEGTS.
- Icecast and SHOUTcast streams with ICY metadata.
The public module path is:
github.com/keithah/tidemark
tidemark <url> [flags]
Flags:
--json Emit newline-delimited JSON to stdout
--quiet Emit human summary lines only
--json-out FILE Write all markers as newline-delimited JSON to FILE
--timeout N Stop after N seconds; 0 means run until cancelled
--filter TYPE Show only scte35, id3, or icy markers
--no-color Disable ANSI color in human-readable output
--json and --quiet are mutually exclusive. --json-out is independent of stdout mode.
Default stdout is a compact table:
TIME TYPE CLASS SEG FRAME VALUE
2026-06-16T14:50:00Z SCTE35 AD_START 42 #EXT-X-CUE-OUT break=90.023s seg=42
2026-06-16T14:50:02Z ID3 METADATA 43 TIT2 Song Title
--quiet prints one summary line per marker. --json prints one compact JSON object per marker. --json-out always writes the same compact JSON shape as newline-delimited JSON.
Canonical marker JSON:
{
"Type": "SCTE35",
"Classification": "AD_START",
"Source": "hls_manifest",
"Tag": "#EXT-X-CUE-OUT",
"PTS": 38113.135,
"Segment": 42,
"RawBase64": "...",
"Tags": {"TIT2": "Song Title"},
"Fields": {"StreamTitle": "Promo Spot"},
"Timestamp": "2026-06-16T14:50:00Z"
}Empty fields are omitted. Internal SCTE-35 details are used for classification and display, but are not serialized directly.
Startup detection combines URL patterns and response metadata:
| Signal | Detected stream |
|---|---|
udp:// URL |
UDP |
.m3u8 URL or /hls/ path |
HLS |
.ts URL |
MPEGTS |
icy-metaint response header |
ICY |
| MPEGURL content type | HLS |
video/mp2t content type |
MPEGTS |
audio/mpeg or audio/aac content type |
ICY fallback |
HTTP probes send Icy-Metadata: 1 so ICY streams can identify themselves.
Classification values are:
AD_STARTAD_ENDMETADATA
METADATA means a marker or tag was found, but no ad boundary signal was identified.
SCTE-35 rules:
| Input | Classification |
|---|---|
| Splice Insert with OutOfNetworkIndicator=true | AD_START |
| Splice Insert with OutOfNetworkIndicator=false | AD_END |
| Time Signal segmentation type 0x22, 0x30, or 0x34 | AD_START |
| Time Signal segmentation type 0x23, 0x31, or 0x35 | AD_END |
| Anything else | METADATA |
ICY and ID3 rules:
ad,spot,promo, orcommercialas a word producesAD_START.ad_endorcontent_startin ID3 producesAD_END.- ICY emits
AD_ENDwhen the stream title changes from ad-like content back to non-ad content.
The HLS path handles both manifests and media segments.
- Master playlists are resolved to a media playlist.
- Live playlists are polled at an interval derived from target duration.
- Conditional GETs use ETag and Last-Modified validators when available.
- HTTP 304 responses are treated as no-change polls.
- Permanent 4xx manifest errors fail fast, except 429.
- Segment marker output is kept in segment order.
- Segment dedupe and URL tracking are bounded for long-running streams.
Supported manifest marker tags:
#EXT-X-SCTE35:CUE=<base64>#EXT-OATCLS-SCTE35:<base64>#EXT-X-DATERANGEwithSCTE35-OUTorSCTE35-IN#EXT-X-CUE-OUT#EXT-X-CUE-IN
ID3 parsing supports ID3v2.3 and ID3v2.4. It parses standard text frames, user text frames, comments, links, URL frames, private data, general encapsulated objects, and best-effort text from other structurally valid frames.
ParseFromMPEGTS returns grouped tag events:
func ParseFromMPEGTS(data []byte) ([][]Tag, error)Each inner slice is one timed-ID3 event. This matters for HLS segments that contain multiple PES payloads with duplicate frame IDs; the segment decoder emits one marker per event instead of flattening the segment into one map.
HLS playlists with #EXT-X-MAP are decoded as CMAF/fMP4 instead of MPEG-TS. The init segment provides track ID, handler, and timescale. Each media fragment's moof boxes provide timing from tfhd, tfdt, and trun.
Fragment timing emits one FMP4 marker per track with Tag:"timeline", PTS in seconds, and fields for track ID, timescale, decode-time range, duration, sample count, and handler. In-band emsg boxes emit FMP4 markers with Tag:"emsg" and event fields such as scheme ID URI, value, event ID, presentation time, duration, and message data.
- HLS manifest reads are capped at 1 MiB.
- HLS segment reads are capped at 32 MiB.
- Oversized ID3 tags are skipped instead of allocating unbounded memory.
- ICY and direct MPEGTS streams use a 30 second idle-read timeout.
- MPEGTS decoder panics are recovered and returned as errors.
- UDP reads close the socket on cancellation so shutdown does not block.
- JSON file output flushes, syncs, and closes explicitly, and reports those errors.
- Table output sanitizes control characters from metadata values.
make build # build ./tidemark
make test # cached go test ./...
make test-fresh # verbose uncached go test ./... -count=1
make vet # go vet ./...
make clean # remove ./tidemarkUse these checks before committing:
git diff --check
go test ./...
go vet ./...Releases are created from v* tags. The release workflow runs tests and GoReleaser, then publishes assets under the canonical GitHub repository keithah/tidemark.