# Are the media-processing steps deterministic?

**182.C.35.09.** The item asks for "deterministic media-processing tests", which
assumes the steps are deterministic. So the first thing to do is check, and the
second is to notice that determinism is not the property that was actually at
risk.

## Method

`measure.sh`, ffmpeg 6.1.1 on the Linux dev server, 2026-09-11. Each of the
eight operations the item names runs **twice**, from identical inputs with
identical flags, and the outputs are compared byte for byte (`sha256sum`, and
`cmp -l` to count differing bytes where they differ). `determinism.json` is its
output. Then a four-step chain runs in the order a delivery pipeline would use.

## Result 1 — all eight are byte-identical

| operation                                | byte-identical | bytes   | output duration |
| ---------------------------------------- | -------------- | ------- | --------------- |
| trim (`-t 1.5`, stream copy)             | yes            | 149,709 | **1.520000 s**  |
| timestamp (`-itsoffset 0.1`)             | yes            | 194,679 | **2.023991 s**  |
| concat (two 2.0 s files)                 | yes            | 388,107 | **4.023220 s**  |
| mux (video from one, audio from another) | yes            | 194,747 | 2.000000 s      |
| loudness (`loudnorm`, audio re-encoded)  | yes            | 195,096 | **2.020000 s**  |
| captions (`mov_text` sidecar muxed in)   | yes            | 195,194 | 2.000000 s      |
| rendition (scale to 160×120, CRF 28)     | yes            | 63,720  | 2.000000 s      |
| provenance (a metadata key)              | yes            | 194,655 | 2.000000 s      |

Zero differing bytes in every case. That is a clean positive and worth having: a
rebuild produces the same object, so a digest is a stable identity for a
processing step's output.

## Result 2 — and four of them change the duration anyway

Determinism was not the property at risk. **A DETERMINISTIC OPERATION THAT
RELIABLY ADDS 23 ms IS RELIABLY WRONG**, and four of the eight move the duration
while none of them is called a timing operation:

- **trim overshoots by 20 ms.** A stream copy cannot cut mid-GOP, so `-t 1.5`
  yields 1.520 s. The request was not honoured and nothing said so.
- **`-itsoffset 0.1` yields +23.991 ms**, not 100 ms — the same AAC frame
  quantisation this phase measured in `2026-09-11-negative-fixtures`.
- **concat of two 2.000 s files yields 4.023220 s.** Concatenation _adds_ 23.22
  ms, which is **52% of the 45 ms ATSC sync window**, from an operation whose
  whole promise is that it joins things without re-encoding them.
- **loudness adds 20 ms**, because the audio is re-encoded and AAC pads.

## Result 3 — and they compound past the window

The same four, applied in pipeline order to a 2.000 s source:

| step                       | duration       |
| -------------------------- | -------------- |
| source                     | 2.000000 s     |
| after loudness             | 2.020000 s     |
| after captions             | 2.020000 s     |
| after concat of two copies | 4.050667 s     |
| after rendition            | 4.050667 s     |
| **expected**               | **4.000000 s** |

**50.667 ms of drift, which exceeds the 45 ms ATSC window on its own**, before
the model has contributed anything, from four perfectly deterministic steps none
of which is a timing operation. A sync measurement taken on the master and
trusted for the delivered rendition is measuring a different file.

## What this does not show

Determinism was checked across two runs on one machine with one ffmpeg build. It
says nothing about a different build, a different CPU, or a threaded encoder
with a non-fixed thread count — `-preset ultrafast` with default threading was
stable here, which is a result about this configuration.

## Reproducing

```bash
bash docs/domains/isis/human-video/evidence/2026-09-11-processing-determinism/measure.sh /tmp/det
```
