From 159b075aa8cbab017ac3cf5ad148040f61929790 Mon Sep 17 00:00:00 2001 From: gravity-zero Date: Sat, 21 Nov 2026 23:25:04 +0100 Subject: [PATCH] docs(streaming): composition offsets and the edit list, when to pass --signed-offsets; the changelog drops its empty Unreleased heading --- CHANGELOG.md | 7 +++---- docs/cli.md | 2 +- docs/library.md | 2 +- docs/streaming.md | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1850cf5..2b88ec0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,9 @@ All notable changes to mkvgo are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/), and the project follows [Semantic Versioning](https://semver.org/). An entry says in a few lines what changes for the user and what to do; the detail lives in the docs. This file -holds the unreleased changes and the latest release; an older version moves to -its series' file in [changelog/](changelog/) when a newer one ships. - -## [Unreleased] +holds the latest release and, above it, the changes not released yet when +there are any; an older version moves to its series' file in +[changelog/](changelog/) when a newer one ships. ## [0.72.0] - 2026-11-21 diff --git a/docs/cli.md b/docs/cli.md index 79bdbc16..8230a751 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -1162,7 +1162,7 @@ Every track the presentation leaves out - a secondary video track (one video ren | `--audio-shift` | Re-base an audio track in presentation (`track=ms`, repeatable; positive = the track's content starts late and is presented earlier - feed it `diagnose`'s per-track delay). The samples are copied verbatim and the media segments are byte-identical with or without the shift: only the init segment's edit list moves, so a constant A/V desync is cancelled in the served stream without touching the source. Over-shifts clamp to the presentation start. The persistent repair remains `mkvgo retime` | | `--chapter-markers` | Opt-in: expose the source's chapters as `EXT-X-DATERANGE` lines in the video media playlist and a chapter `EventStream` in `manifest.mpd` - chapter navigation and ad-insertion cue points, no re-segmentation. See [streaming.md](streaming.md#chapter-markers-and-ad-insertion-points) | | `--no-iframes` | Drop the trick-play I-frame stream: no `EXT-X-I-FRAME-STREAM-INF` in the master, no `iframe.m3u8` nor `iframeNNNNN.m4s` written or served (`hls-segment iframe` refuses it). For players that scrub with their own trickplay images. Segments and the other playlists are unchanged. Also on `hls-segment`, `to-abr`, `abr-segment`. See [streaming.md](streaming.md#trick-play-scrubbing) | -| `--signed-offsets` | Write a reordered video's composition offsets signed, with no composition shift and no video edit list (CMAF `cmf2` form): a player that ignores the edit list presents the picture on time instead of late by the reordering depth. Init and segments both change: use one setting per presentation. Also on `hls-segment`, `serve` and `serve-growing` | +| `--signed-offsets` | Write a reordered video's composition offsets signed, with no composition shift and no video edit list for it: a player that does not apply the edit list presents the picture on time instead of late by the reordering depth. Init and segments both change: one setting per presentation. Also on `hls-segment`, `serve` and `serve-growing`. See [streaming.md](streaming.md#composition-offsets-and-the-edit-list---signed-offsets) | ```bash mkvgo to-hls video.mkv -o stream/ diff --git a/docs/library.md b/docs/library.md index bc909961..f1ce9455 100644 --- a/docs/library.md +++ b/docs/library.md @@ -232,7 +232,7 @@ Memory use scales with the sample count, not the file size: sample data is strea err := mp4.RemuxToHLS(ctx, "in.mkv", "stream/", mp4.Options{SegmentMs: 6000}) ``` -Writes a fragmented-MP4 / CMAF presentation into the output directory, served through two manifests over the same segments: HLS (`master.m3u8` + per-rendition media playlists) and DASH (`manifest.mpd`). Tracks are demuxed - the video rendition (`playlist.m3u8`, `init.mp4`, `seg00001.m4s` …) plus one rendition per audio track (`audio1.m3u8`, `init_a1.mp4`, `seg_a1_00001.m4s` …, an `EXT-X-MEDIA` AUDIO group / one MPD AdaptationSet each) - so multi-audio sources get native language selection. Each `.m4s` is `styp` + `moof` + `mdat`; each init is ftyp + moov with `mvex`/`trex` and empty sample tables (movie metadata - title and tags - rides on the video init; the cover art stays out of it, since a player downloads the init before its first frame). `Options.SignedCompositionOffsets` writes a reordered video's composition offsets signed, with no composition shift and no video edit list (the CMAF `cmf2` form), for players that ignore the edit list and would show the picture late by the reordering depth; the default keeps non-negative offsets and the edit list. No transcoding - samples are copied verbatim, so the codec set matches `RemuxToMP4`. +Writes a fragmented-MP4 / CMAF presentation into the output directory, served through two manifests over the same segments: HLS (`master.m3u8` + per-rendition media playlists) and DASH (`manifest.mpd`). Tracks are demuxed - the video rendition (`playlist.m3u8`, `init.mp4`, `seg00001.m4s` …) plus one rendition per audio track (`audio1.m3u8`, `init_a1.mp4`, `seg_a1_00001.m4s` …, an `EXT-X-MEDIA` AUDIO group / one MPD AdaptationSet each) - so multi-audio sources get native language selection. Each `.m4s` is `styp` + `moof` + `mdat`; each init is ftyp + moov with `mvex`/`trex` and empty sample tables (movie metadata - title and tags - rides on the video init; the cover art stays out of it, since a player downloads the init before its first frame). `Options.SignedCompositionOffsets` writes a reordered video's composition offsets signed, with no composition shift and no video edit list (the CMAF `cmf2` form), for players that do not apply the video edit list and would show the picture late by the reordering depth; the default keeps non-negative offsets and the edit list. See [streaming.md](streaming.md#composition-offsets-and-the-edit-list---signed-offsets). No transcoding - samples are copied verbatim, so the codec set matches `RemuxToMP4`. Segments are cut on video keyframes at roughly `Options.SegmentMs` (default 6 s) and each is independently decodable, so a player seeks by fetching the segment plus `init.mp4`. Text subtitle tracks (SRT, WebVTT, ASS/SSA flattened) become segmented WebVTT renditions declared in the master playlist; bitmap subtitles are dropped (reported via `Options.OnDrop`). This is the CMAF *copy rung* of an HLS ladder - the packaging; bitrate variants (real ABR) remain a transcoder's job. diff --git a/docs/streaming.md b/docs/streaming.md index 66887d7e..7ea7fc74 100644 --- a/docs/streaming.md +++ b/docs/streaming.md @@ -557,6 +557,44 @@ ffmpeg -i frame.h264 -frames:v 1 thumb.jpg --- +## Composition offsets and the edit list - `--signed-offsets` + +A video with B-frames stores its frames in decode order, so each one carries a +composition offset: how long after it decodes it presents. There are two ways +to write them. + +**Default.** The offsets are kept non-negative: every frame's is pushed up by +the composition shift (the reordering depth the parameter sets declare, or the +one the opening frames show), and the video's edit list in the init takes the +shift back out. A player that applies the edit list presents every frame where +the source has it. + +A player that does not apply it presents the picture later than the sound by +the shift (84 ms for a two-frame pyramid at 24 fps). Measured: one Media +Source implementation ignores a video edit list of more than one entry - the +case of a video that starts after zero, whose edit list opens on an empty +edit - and one player library ignores it when it plays DASH. + +**`Options.SignedCompositionOffsets` (`--signed-offsets`).** No shift: the +first frame presents when it decodes, the offsets of the frames reordered +after it go below zero (`trun` version 1), and the init carries no edit for +it. Every player measured - two browser engines, a mobile player library in +HLS and in DASH, and a desktop media framework - then presents every frame +where the source has it. + +Two things to know before turning it on: + +- A reader that answers a negative offset by pulling its decode clock back + shows the picture late by the deepest one under this option, where the + default form is exact for it. +- The init and the segments both change with the option. Use one setting for a + whole presentation, and treat a change of setting like a change of source: + new URLs, or the cached init and segments dropped together. + +The empty edit of a video that starts after zero is written either way. + +--- + ## Playing it in the browser The WebAssembly build runs the same packager client-side. `openHLS(file)` opens