Skip to content

export ts: PCR values are exact and the aggregate rate is right, but the bytes are not distributed across the slots, so the output is not a constant-rate stream #3925

Closed

Description

@t0ms

What this is not

#3334 is closed and
#3351 closed it properly. I verified that here against
#3351's own merge-base, both built from one worktree: PCR packets adjacent to their predecessor went
50.31 % → 0 %, release intervals outside ±10 ms went 491/799 → 0–4/745, worst release error
91.4 ms → 3.9 ms, and all six checks passed. This is not a regression report and not a reopen.

It is the next property along, and #3351's checks do not grade it: not-adjacent is not evenly
spaced.
A PCR seven packets after its predecessor passes an adjacency check and is still 158
packets short of where a constant-rate stream would put it.

Measured on 53f8aa99d

150 s of a 9,945,951 b/s CBR source through a loopback relay, captured from export ts stdout with
the source's stuffing intact so mpegts.muxRate is recorded and #3831's padding is active. Grading
the single PCR-bearing PID (0x006F) — pooling PCRs across PIDs gives a meaningless series, so the
grader names every PCR PID it finds and grades one.

The two things that are right, and they are worth stating first:

source clip export ts
PCR interval — min / median / max 0.151 / 24.65 / 24.95 ms 25.00 / 25.00 / 25.00 ms
intervals over TR 101 290 P1's 40 ms 0 0 of 6,173
intervals under 1 ms 21 (0.09 %) 0
rate over the whole capture 9,945,951 b/s 9,966,922 b/s (+0.21 %)

The PCR values are better than the source's, and #3831's padding lands the aggregate within 0.21 %
of the declared rate. Both of those are real improvements and neither is in question.

The thing that is not right is where the bytes sit between those PCRs:

bytes between consecutive PCRs min p10 p25 median p75 p90 p99 max
export ts, 53f8aa99d 188 940 940 1,316 6,392 66,364 384,460 870,628
what the declared rate needs 31,081 31,081 31,081 31,081 31,081 31,081 31,081 31,081

The mean is 31,147 B, which is correct to 0.21 % and is the same fact as the aggregate rate. The
median is 1,316 B, 4.2 % of the mean. The distribution is bimodal rather than noisy: a mode below
1 kB, an order of magnitude under requirement, and a second mode well above it. Only 205 of 6,173
intervals (3.3 %) carry an instantaneous rate within 1 % of nominal, and the instantaneous rate runs
60,160 b/s to 278,600,960 b/s — 0.6 % to 2,800 % of the declared rate.

So the PCR values are stamped onto a perfect 25 ms grid regardless of the byte position they land at.

Why it matters, concretely

A receiver that recovers its clock from packet arrival cannot use this stream. That is the
ordinary IRD case, and it is what a TR 101 290 P2 accuracy gate models: P2 predicts a PCR's arrival
from its byte position under a constant-rate assumption. Where the instantaneous rate spans four
orders of magnitude there is no byte position that predicts anything, so the gate is not failed by a
small error — it is the wrong kind of stream. That, rather than imprecision, is why every PCR failed
a 481 ns gate in our earlier measurements.

It is also what blocks deterministic 1+1, which surprised me. A groomer can place packets on the
slot each source PCR implies only if the source's PCR byte positions track its PCR values.
mpegts-pacer's stream-clocked mode measures that divergence rather than assuming it, and against
this output it reports 731 overrun intervals and a positional displacement of 5,762 packets
(871 ms at the locked rate)
— identical across two independent cells, so it is a property of the
output and not of the run. The consequence is that content arrives for slots already emitted as
stuffing: 93.1 % of the output is stuffing even at a 1,500 ms cushion, nearly twice the measured
displacement. So the schedule is upstream of the interleave question in
#2829 too.

And it is why I said #3923 should wait. A UDP sink
would put this on a wire, where an IRD would reject what a pipe tolerates. If only one of the two
gets done, it should be this one.

What would close it

Some constraint tying PCR byte position to PCR value, so that the packets between two PCRs are the
number the declared rate implies — the property #3831 already assumes when it pads to a rate. I
don't have a view on where that belongs in the mux, and the two are clearly coupled: padding to a
rate and placing PCRs on the byte grid are the same scheduling decision made once rather than twice.

A check that would catch it: grade the distribution of bytes between consecutive PCRs, not just
adjacency. The adjacency check passes on this capture.

Grader is
pcr-residual.py;
it reads the interval from the carried PCR values and the rate from the packet count over the same
pair, so the two cannot disagree about which stream they describe. Happy to run anything else that
would help, or to re-take this against a different source profile if the clip is doing something I
haven't noticed.

Domain: file, on a capture of export ts stdout — byte position is the quantity of interest, so
the file domain is the right one. Nothing here is graded on a hardware IRD.

Activity

  1. added
    questBeing tracked/planned in a quest. See `quest/`
    on Sep 23, 2026
  2. kixelated commented on Sep 28, 2026

    @kixelated
    Collaborator

    Summary of the planning decision (#3987):

    (Written by Claude Opus 5.5)

  3. added 2 commits that reference this issue on Sep 30, 2026
    b8dee40
    dfad86e
  4. t0ms commented on Oct 9, 2026

    @t0ms
    ContributorAuthor

    Closing: the fixed-delay export merged in #4645 answers this. It lays the multiplex on a 25 ms PCR grid at the mux rate, so the bytes sit where the PCR values say they do. On main at f8215bc47, with CNNiEMEA2.ts looped through a loopback relay at --delay 1s for 35 minutes, every one of the 83,908 PCRs tsp -P pcrverify checked was within ±481 ns of their byte position at the mux rate, and every T-STD buffer was legal in all 1,046 two-second windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questBeing tracked/planned in a quest. See `quest/`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions