v0.5.0 — PGS encoding and round-trip
Highlights
PGS encoding and round-trip support
libpgs is no longer extract-only. This release adds a complete encoding path so you can read, modify, and write PGS data:
DisplaySetBuilder— chainable builder for constructing display sets from structured payloads. Handles RLE encoding and ODS fragmentation automatically.- Payload serialization —
PcsData,WdsData,PdsData, andOdsDataall gainto_bytes()methods.PgsSegmentgainsfrom_pcs/wds/pds/odsfactories and in-placeset_*_payloadmutators. - RLE encoder —
encode_rle(pixels, width, height)complements the existing decoder, enabling full bitmap round-trips. ObjectBitmaptype — represents a complete object bitmap (id, dimensions, pixel buffer) for encoding into ODS segments.
encode CLI command
The new libpgs encode -o <output.sup> subcommand reads NDJSON from stdin (in the same format that libpgs stream produces) and writes a .sup file. This closes the round-trip loop for external scripts in any language:
libpgs stream input.mkv | your-script.py | libpgs encode -o output.supMulti-track input is automatically split into <stem>_track<id>.sup files. See docs/NDJSON.md for the full protocol reference.
Bug fixes
- Cue-path block timestamps were off by the block's cluster-relative offset. When extracting PGS from MKV files via the cue fast path (the default for any MKV with a Cues index),
read_block_at_positionwas computingcue_time + block.relative_timestamp, but per the Matroska specCueTimeis already the absolute timestamp of the block referenced byCueRelativePosition. This caused every extracted display set to have an incorrect PTS, shifted by an amount equal to the block's cluster-relative offset (ranging from 0 to several seconds per block)..supfiles extracted with v0.4.0 and earlier from cue-indexed MKVs are affected and should be re-extracted with v0.5.0 — output is now byte-for-byte identical tomkvextract.
Documentation
STREAMING.mdrenamed todocs/NDJSON.mdand expanded with encode protocol details.- README updated with encoding and round-trip examples.