Expand description
MPEG-2 TS repair / remux — container-layer operations, no codec parsing.
ts-fix provides a builder-driven streaming engine that feeds 188-byte
TS packets in and emits repaired packets out. Repair operations are opt-in
via builder methods; the engine owns and enforces the canonical ordering.
§Operations
| Operation | Builder method | What it does |
|---|---|---|
| Continuity repair | repair_continuity | Renumber per-PID continuity counters (§2.4.3.3). |
| PID filter / service extract | filter_pids | Keep specified PIDs or extract a single programme by program_number. |
| PAT/PMT regeneration | regen_psi | Rebuild PAT from observed PMT PIDs on flush. |
| PCR restamp | restamp_pcr | Recompute PCR values on the PCR PID (§2.4.3.5). |
| PCR-discontinuity honor | honor_pcr_discontinuity | Set discontinuity_indicator on genuine, unflagged PCR breaks (TR 101 290 §5.2.2 2.3b) without rewriting values. |
| Stuffing | stuffing | Drop null packets or pad to a target packet rate. |
§Forward compatibility
The public API is designed so that adding a new repair operation in a future minor release is a purely additive change:
- There is no public
enum Operation(adding a variant is breaking). - There is no public
trait Operation(locking the contract before all ops’ needs are known). - Operations are exposed exclusively through
TsFixBuildermethods. - All configuration and error enums are
#[non_exhaustive].
§Quick start
use ts_fix::{PcrRestamp, PidFilter, Stuffing, TsFix};
let mut engine = TsFix::builder()
.repair_continuity()
.filter_pids(PidFilter::keep([0x0100, 0x0101]))
.regen_psi()
.restamp_pcr(PcrRestamp::interpolate())
.stuffing(Stuffing::drop_nulls())
.build()
.unwrap();§Spec
ISO/IEC 13818-1 (= ITU-T H.222.0) — §2.4.3.2 (TS packet), §2.4.3.3 (adaptation field / continuity counter), §2.4.3.4 (PCR), §2.4.4 (PSI).
Re-exports§
pub use error::Error;
Modules§
- discontinuity
- PCR-discontinuity detection (#562) — a standalone analysis pass over a buffer of concatenated 188-byte TS packets.
- error
- Error type for the
ts-fixcrate. - pes
- PES access-unit reconstruction from TS payloads — framing only, no codec bitstream parsing (ISO/IEC 13818-1 §2.4.3.6).
Structs§
- TsFix
- A repair / remux engine for MPEG-2 TS byte streams.
- TsFix
Builder - Builder for
TsFix.
Enums§
- PcrRestamp
- PCR restamp mode.
- PidFilter
- Configuration for
TsFixBuilder::filter_pids. - Stuffing
- Configuration for
TsFixBuilder::stuffing.