FA-78371 / Broadcast timecode arithmetic / Open access
Frame count to timecode label with frame pairs: day length · case 01
High frame rate counts wrap at noon instead of midnight.
ROOT CAUSE
The day length is computed from frame pairs rather than frames for high rates.
VERIFIED REPAIR
Use 24*3600*fps frames per day.
Unsuccessful approach: Hard-coding 30 fps wraps every other rate at the wrong count.
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 if fps<=30 else fps//2)
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 length', [3745221, 48], '21:40:25.10'), ('regression variant: day length', [-1, 60], '23:59:59.29'), ('partial repair probe: day length', [8640011, 50], '00:00:00.05'), ('partial repair variant: day length', [-1, 24], '23:59:59:23'), ('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 length', [4319999, 50], '23:59:59.24'), ('regression variant: day length', [16335211, 50], '18:45:04.05'), ('partial repair probe: day length', [3745221, 48], '21:40:25.10'), ('partial repair variant: day length', [7086760, 24], '10:01:21:16'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [8166989, 30], '03:37:12:29'), ('normal control', [2, 48], '00:00:00:01'), ('normal control', [5184000, 60], '00:00:00:00')], [('regression: day length', [-5184003, 60], '23:59:59.28'), ('regression variant: day length', [2364826, 50], '13:08:16:13'), ('partial repair probe: day length', [4147205, 48], '00:00:00.02'), ('partial repair variant: day length', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [1443, 24], '00:01:00:03'), ('normal control', [0, 24], '00:00:00:00'), ('normal control', [180007, 50], '01:00:00.03')], [('regression: day length', [-1, 50], '23:59:59.24'), ('regression variant: day length', [5183999, 60], '23:59:59.29'), ('partial repair probe: day length', [4319999, 50], '23:59:59.24'), ('partial repair variant: day length', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [2592000, 30], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10'), ('normal control', [1754516, 50], '09:44:50:08')], [('regression: day length', [-4147203, 48], '23:59:59.22'), ('regression variant: day length', [15958672, 48], '20:21:12:08'), ('partial repair probe: day length', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day length', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [5184005, 60], '00:00:00.02'), ('normal control', [-2592003, 30], '23:59:59:27'), ('normal control', [0, 48], '00:00:00: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 length | 09:40:25.10 | 21:40:25.10 | Failed |
| regression variant: day length | 11:59:59.29 | 23:59:59.29 | Failed |
| partial repair probe: day length | 00:00:00.05 | 00:00:00.05 | Passed |
| partial repair variant: day length | 23:59:59:23 | 23:59:59:23 | 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 / ba0c32d32fa80354b05792e787fa93b876e1bdbe34b9f69183db65f0afd7bdbe
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*30
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 length', [3745221, 48], '21:40:25.10'), ('regression variant: day length', [-1, 60], '23:59:59.29'), ('partial repair probe: day length', [8640011, 50], '00:00:00.05'), ('partial repair variant: day length', [-1, 24], '23:59:59:23'), ('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 length', [4319999, 50], '23:59:59.24'), ('regression variant: day length', [16335211, 50], '18:45:04.05'), ('partial repair probe: day length', [3745221, 48], '21:40:25.10'), ('partial repair variant: day length', [7086760, 24], '10:01:21:16'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [8166989, 30], '03:37:12:29'), ('normal control', [2, 48], '00:00:00:01'), ('normal control', [5184000, 60], '00:00:00:00')], [('regression: day length', [-5184003, 60], '23:59:59.28'), ('regression variant: day length', [2364826, 50], '13:08:16:13'), ('partial repair probe: day length', [4147205, 48], '00:00:00.02'), ('partial repair variant: day length', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [1443, 24], '00:01:00:03'), ('normal control', [0, 24], '00:00:00:00'), ('normal control', [180007, 50], '01:00:00.03')], [('regression: day length', [-1, 50], '23:59:59.24'), ('regression variant: day length', [5183999, 60], '23:59:59.29'), ('partial repair probe: day length', [4319999, 50], '23:59:59.24'), ('partial repair variant: day length', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [2592000, 30], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10'), ('normal control', [1754516, 50], '09:44:50:08')], [('regression: day length', [-4147203, 48], '23:59:59.22'), ('regression variant: day length', [15958672, 48], '20:21:12:08'), ('partial repair probe: day length', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day length', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [5184005, 60], '00:00:00.02'), ('normal control', [-2592003, 30], '23:59:59:27'), ('normal control', [0, 48], '00:00:00: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 length | 06:40:25.10 | 21:40:25.10 | Failed |
| regression variant: day length | 11:59:59.29 | 23:59:59.29 | Failed |
| partial repair probe: day length | 04:48:00.05 | 00:00:00.05 | Failed |
| partial repair variant: day length | 29:59:59:23 | 23:59:59:23 | 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 / edabc546d8cfdf0dadda8b2e9709a7a36c969f5569a5e1771a30461878cfea6c
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 length', [3745221, 48], '21:40:25.10'), ('regression variant: day length', [-1, 60], '23:59:59.29'), ('partial repair probe: day length', [8640011, 50], '00:00:00.05'), ('partial repair variant: day length', [-1, 24], '23:59:59:23'), ('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 length', [4319999, 50], '23:59:59.24'), ('regression variant: day length', [16335211, 50], '18:45:04.05'), ('partial repair probe: day length', [3745221, 48], '21:40:25.10'), ('partial repair variant: day length', [7086760, 24], '10:01:21:16'), ('boundary control', [3, 50], '00:00:00.01'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [8166989, 30], '03:37:12:29'), ('normal control', [2, 48], '00:00:00:01'), ('normal control', [5184000, 60], '00:00:00:00')], [('regression: day length', [-5184003, 60], '23:59:59.28'), ('regression variant: day length', [2364826, 50], '13:08:16:13'), ('partial repair probe: day length', [4147205, 48], '00:00:00.02'), ('partial repair variant: day length', [2073600, 24], '00:00:00:00'), ('boundary control', [2, 50], '00:00:00:01'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [1443, 24], '00:01:00:03'), ('normal control', [0, 24], '00:00:00:00'), ('normal control', [180007, 50], '01:00:00.03')], [('regression: day length', [-1, 50], '23:59:59.24'), ('regression variant: day length', [5183999, 60], '23:59:59.29'), ('partial repair probe: day length', [4319999, 50], '23:59:59.24'), ('partial repair variant: day length', [4320005, 50], '00:00:00.02'), ('boundary control', [59, 60], '00:00:00.29'), ('boundary control', [3, 50], '00:00:00.01'), ('normal control', [2592000, 30], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10'), ('normal control', [1754516, 50], '09:44:50:08')], [('regression: day length', [-4147203, 48], '23:59:59.22'), ('regression variant: day length', [15958672, 48], '20:21:12:08'), ('partial repair probe: day length', [-5184003, 60], '23:59:59.28'), ('partial repair variant: day length', [2160005, 25], '00:00:00:05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2, 50], '00:00:00:01'), ('normal control', [5184005, 60], '00:00:00.02'), ('normal control', [-2592003, 30], '23:59:59:27'), ('normal control', [0, 48], '00:00:00: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 length | 21:40:25.10 | 21:40:25.10 | Passed |
| regression variant: day length | 23:59:59.29 | 23:59:59.29 | Passed |
| partial repair probe: day length | 00:00:00.05 | 00:00:00.05 | Passed |
| partial repair variant: day length | 23:59:59:23 | 23:59:59:23 | 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 / 62784b113ab1b6d99b83ee75ea7509d57ce6657e53996af8aaec1262bf0bbf18
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.681664+00:00.
Case digest / 5d0304f774ecf50cf04d48f7588259ffb1bc3fca34106e89c85f4aaab30ea70f