FA-78366 / Broadcast timecode arithmetic / Open access
Frame count to timecode label with frame pairs: day wrap · case 01
Pre-roll frames before midnight are labelled as if they were after midnight.
ROOT CAUSE
Negative counts are mirrored with abs() before wrapping.
VERIFIED REPAIR
Wrap with a true modulo so negative counts land before midnight.
Unsuccessful approach: Adding one day to negatives neither wraps counts beyond a day nor multi-day negatives.
Case contract
Convert a frame count (any integer, wrapped modulo 24 hours) to HH:MM:SS:FF. For fps above 30 the frame field counts frame pairs (frame//2) and the last separator is "." for the second frame of a pair and ":" otherwise.
Why this case matters
Timecode arithmetic errors misplace edits, commercial breaks and captions against the broadcast clock.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(frames, fps):
day=24*3600*fps
frames=abs(frames)%day
fr=frames%fps
s=frames//fps
hh,mm,ss=s//3600,s//60%60,s%60
if fps>30:
return '%02d:%02d:%02d%s%02d'%(hh,mm,ss,'.' if fr%2 else ':',fr//2)
return '%02d:%02d:%02d:%02d'%(hh,mm,ss,fr)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day wrap', [-1, 25], '23:59:59:24'), ('regression variant: day wrap', [-4622105, 30], '05:12:09:25'), ('partial repair probe: day wrap', [8640011, 50], '00:00:00.05'), ('partial repair variant: day wrap', [7086760, 24], '10:01:21:16'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [59, 60], '00:00:00.29'), ('normal control', [3, 50], '00:00:00.01'), ('normal control', [30, 30], '00:00:01:00'), ('normal control', [216007, 60], '01:00:00.03')], [('regression: day wrap', [-5184003, 60], '23:59:59.28'), ('regression variant: day wrap', [-1, 24], '23:59:59:23'), ('partial repair probe: day wrap', [4147205, 48], '00:00:00.02'), ('partial repair variant: day wrap', [2592000, 30], '00:00:00:00'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [3745221, 48], '21:40:25.10'), ('normal control', [49, 50], '00:00:00.24'), ('normal control', [2, 24], '00:00:00:02')], [('regression: day wrap', [-1, 50], '23:59:59.24'), ('regression variant: day wrap', [-1, 60], '23:59:59.29'), ('partial repair probe: day wrap', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day wrap', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [2, 30], '00:00:00:02'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [1, 25], '00:00:00:01')], [('regression: day wrap', [-4147203, 48], '23:59:59.22'), ('regression variant: day wrap', [-2592003, 30], '23:59:59:27'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [48, 48], '00:00:01:00'), ('normal control', [2591999, 30], '23:59:59:29'), ('normal control', [0, 48], '00:00:00:00')], [('regression: day wrap', [-1, 30], '23:59:59:29'), ('regression variant: day wrap', [-1, 48], '23:59:59.23'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [50, 50], '00:00:01:00'), ('normal control', [29, 30], '00:00:00:29'), ('normal control', [24, 24], '00:00:01:00')]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: day wrap | 00:00:00:01 | 23:59:59:24 | Failed |
| regression variant: day wrap | 18:47:50:05 | 05:12:09:25 | Failed |
| partial repair probe: day wrap | 00:00:00.05 | 00:00:00.05 | Passed |
| partial repair variant: day wrap | 10:01:21:16 | 10:01:21:16 | Passed |
| boundary control | 00:00:00:00 | 00:00:00:00 | Passed |
| boundary control | 00:00:00.29 | 00:00:00.29 | Passed |
| normal control | 00:00:00.01 | 00:00:00.01 | Passed |
| normal control | 00:00:01:00 | 00:00:01:00 | Passed |
| normal control | 01:00:00.03 | 01:00:00.03 | Passed |
SHA-256 / d8059abdc483a590d940c31b18244dc574a73745e04bdb64f53f79e24793558e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(frames, fps):
day=24*3600*fps
frames=frames+day if frames<0 else frames
fr=frames%fps
s=frames//fps
hh,mm,ss=s//3600,s//60%60,s%60
if fps>30:
return '%02d:%02d:%02d%s%02d'%(hh,mm,ss,'.' if fr%2 else ':',fr//2)
return '%02d:%02d:%02d:%02d'%(hh,mm,ss,fr)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day wrap', [-1, 25], '23:59:59:24'), ('regression variant: day wrap', [-4622105, 30], '05:12:09:25'), ('partial repair probe: day wrap', [8640011, 50], '00:00:00.05'), ('partial repair variant: day wrap', [7086760, 24], '10:01:21:16'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [59, 60], '00:00:00.29'), ('normal control', [3, 50], '00:00:00.01'), ('normal control', [30, 30], '00:00:01:00'), ('normal control', [216007, 60], '01:00:00.03')], [('regression: day wrap', [-5184003, 60], '23:59:59.28'), ('regression variant: day wrap', [-1, 24], '23:59:59:23'), ('partial repair probe: day wrap', [4147205, 48], '00:00:00.02'), ('partial repair variant: day wrap', [2592000, 30], '00:00:00:00'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [3745221, 48], '21:40:25.10'), ('normal control', [49, 50], '00:00:00.24'), ('normal control', [2, 24], '00:00:00:02')], [('regression: day wrap', [-1, 50], '23:59:59.24'), ('regression variant: day wrap', [-1, 60], '23:59:59.29'), ('partial repair probe: day wrap', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day wrap', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [2, 30], '00:00:00:02'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [1, 25], '00:00:00:01')], [('regression: day wrap', [-4147203, 48], '23:59:59.22'), ('regression variant: day wrap', [-2592003, 30], '23:59:59:27'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [48, 48], '00:00:01:00'), ('normal control', [2591999, 30], '23:59:59:29'), ('normal control', [0, 48], '00:00:00:00')], [('regression: day wrap', [-1, 30], '23:59:59:29'), ('regression variant: day wrap', [-1, 48], '23:59:59.23'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [50, 50], '00:00:01:00'), ('normal control', [29, 30], '00:00:00:29'), ('normal control', [24, 24], '00:00:01:00')]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: day wrap | 23:59:59:24 | 23:59:59:24 | Passed |
| regression variant: day wrap | -19:12:09:25 | 05:12:09:25 | Failed |
| partial repair probe: day wrap | 48:00:00.05 | 00:00:00.05 | Failed |
| partial repair variant: day wrap | 82:01:21:16 | 10:01:21:16 | Failed |
| boundary control | 00:00:00:00 | 00:00:00:00 | Passed |
| boundary control | 00:00:00.29 | 00:00:00.29 | Passed |
| normal control | 00:00:00.01 | 00:00:00.01 | Passed |
| normal control | 00:00:01:00 | 00:00:01:00 | Passed |
| normal control | 01:00:00.03 | 01:00:00.03 | Passed |
SHA-256 / 0f3db88a8a5c7e73f48badaad606b14e745d709f9e1bdd57fe9a2b37eb99e5aa
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(frames, fps):
day=24*3600*fps
frames%=day
fr=frames%fps
s=frames//fps
hh,mm,ss=s//3600,s//60%60,s%60
if fps>30:
return '%02d:%02d:%02d%s%02d'%(hh,mm,ss,'.' if fr%2 else ':',fr//2)
return '%02d:%02d:%02d:%02d'%(hh,mm,ss,fr)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day wrap', [-1, 25], '23:59:59:24'), ('regression variant: day wrap', [-4622105, 30], '05:12:09:25'), ('partial repair probe: day wrap', [8640011, 50], '00:00:00.05'), ('partial repair variant: day wrap', [7086760, 24], '10:01:21:16'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [59, 60], '00:00:00.29'), ('normal control', [3, 50], '00:00:00.01'), ('normal control', [30, 30], '00:00:01:00'), ('normal control', [216007, 60], '01:00:00.03')], [('regression: day wrap', [-5184003, 60], '23:59:59.28'), ('regression variant: day wrap', [-1, 24], '23:59:59:23'), ('partial repair probe: day wrap', [4147205, 48], '00:00:00.02'), ('partial repair variant: day wrap', [2592000, 30], '00:00:00:00'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [3745221, 48], '21:40:25.10'), ('normal control', [49, 50], '00:00:00.24'), ('normal control', [2, 24], '00:00:00:02')], [('regression: day wrap', [-1, 50], '23:59:59.24'), ('regression variant: day wrap', [-1, 60], '23:59:59.29'), ('partial repair probe: day wrap', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day wrap', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [2, 30], '00:00:00:02'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [1, 25], '00:00:00:01')], [('regression: day wrap', [-4147203, 48], '23:59:59.22'), ('regression variant: day wrap', [-2592003, 30], '23:59:59:27'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [48, 48], '00:00:01:00'), ('normal control', [2591999, 30], '23:59:59:29'), ('normal control', [0, 48], '00:00:00:00')], [('regression: day wrap', [-1, 30], '23:59:59:29'), ('regression variant: day wrap', [-1, 48], '23:59:59.23'), ('partial repair probe: day wrap', [5184000, 60], '00:00:00:00'), ('partial repair variant: day wrap', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [50, 50], '00:00:01:00'), ('normal control', [29, 30], '00:00:00:29'), ('normal control', [24, 24], '00:00:01:00')]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: day wrap | 23:59:59:24 | 23:59:59:24 | Passed |
| regression variant: day wrap | 05:12:09:25 | 05:12:09:25 | Passed |
| partial repair probe: day wrap | 00:00:00.05 | 00:00:00.05 | Passed |
| partial repair variant: day wrap | 10:01:21:16 | 10:01:21:16 | Passed |
| boundary control | 00:00:00:00 | 00:00:00:00 | Passed |
| boundary control | 00:00:00.29 | 00:00:00.29 | Passed |
| normal control | 00:00:00.01 | 00:00:00.01 | Passed |
| normal control | 00:00:01:00 | 00:00:01:00 | Passed |
| normal control | 01:00:00.03 | 01:00:00.03 | Passed |
SHA-256 / 5bdd4e365c9adb269c6fbdb9922680d875099a732502ce96d9d1aaeec6fb7c81
Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to SMPTE or any broadcast standard. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:34.681658+00:00.
Case digest / 3e4ffe78a2c9655ec225833671879f0d757af00b8655fd6140e9b4a7d74e2fcd