FAILURE MAP
← Case archive

FA-78381 / Broadcast timecode arithmetic / Open access

Frame count to timecode label with frame pairs: pair flag · case 01

The first and second frames of each pair are labelled the wrong way round.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The pair separator is inverted.

VERIFIED REPAIR

Mark odd frames, the second of each pair, with a period.

Unsuccessful approach: Flagging the second half of the second instead of the second frame of each pair mislabels most frames.

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%=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: pair flag', [3, 50], '00:00:00.01'), ('regression variant: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair probe: pair flag', [8640011, 50], '00:00:00.05'), ('partial repair variant: pair flag', [5184005, 60], '00:00:00.02'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [-1, 25], '23:59:59:24'), ('normal control', [1803, 30], '00:01:00:03'), ('normal control', [8166989, 30], '03:37:12:29')], [('regression: pair flag', [2, 50], '00:00:00:01'), ('regression variant: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair probe: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair variant: pair flag', [10368011, 60], '00:00:00.05'), ('boundary control', [-1, 25], '23:59:59:24'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [-1, 30], '23:59:59:29'), ('normal control', [-1, 24], '23:59:59:23'), ('normal control', [0, 24], '00:00:00:00')], [('regression: pair flag', [59, 60], '00:00:00.29'), ('regression variant: pair flag', [4319999, 50], '23:59:59.24'), ('partial repair probe: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair variant: pair flag', [8294411, 48], '00:00:00.05'), ('boundary control', [2160000, 25], '00:00:00:00'), ('boundary control', [-1, 25], '23:59:59:24'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [2073600, 24], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10')], [('regression: pair flag', [216007, 60], '01:00:00.03'), ('regression variant: pair flag', [-5184003, 60], '23:59:59.28'), ('partial repair probe: pair flag', [1, 48], '00:00:00.00'), ('partial repair variant: pair flag', [16335211, 50], '18:45:04.05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2160000, 25], '00:00:00:00'), ('normal control', [23, 24], '00:00:00:23'), ('normal control', [2073605, 24], '00:00:00:05'), ('normal control', [86407, 24], '01:00:00:07')], [('regression: pair flag', [8640011, 50], '00:00:00.05'), ('regression variant: pair flag', [1, 48], '00:00:00.00'), ('partial repair probe: pair flag', [180007, 50], '01:00:00.03'), ('partial repair variant: pair flag', [2364826, 50], '13:08:16:13'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [24, 24], '00:00:01:00'), ('normal control', [90007, 25], '01:00:00:07'), ('normal control', [-24, 24], '23:59:59: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 fixtureActualExpectedOutcome
regression: pair flag00:00:00:0100:00:00.01Failed
regression variant: pair flag21:40:25:1021:40:25.10Failed
partial repair probe: pair flag00:00:00:0500:00:00.05Failed
partial repair variant: pair flag00:00:00:0200:00:00.02Failed
boundary control00:00:00:0000:00:00:00Passed
boundary control00:00:01:0000:00:01:00Passed
normal control23:59:59:2423:59:59:24Passed
normal control00:01:00:0300:01:00:03Passed
normal control03:37:12:2903:37:12:29Passed

SHA-256 / 25486189298165c5d3cace70af16ec9bab0f3124ba8f40d54bb42b78d56ee80b

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%=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>=fps//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: pair flag', [3, 50], '00:00:00.01'), ('regression variant: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair probe: pair flag', [8640011, 50], '00:00:00.05'), ('partial repair variant: pair flag', [5184005, 60], '00:00:00.02'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [-1, 25], '23:59:59:24'), ('normal control', [1803, 30], '00:01:00:03'), ('normal control', [8166989, 30], '03:37:12:29')], [('regression: pair flag', [2, 50], '00:00:00:01'), ('regression variant: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair probe: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair variant: pair flag', [10368011, 60], '00:00:00.05'), ('boundary control', [-1, 25], '23:59:59:24'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [-1, 30], '23:59:59:29'), ('normal control', [-1, 24], '23:59:59:23'), ('normal control', [0, 24], '00:00:00:00')], [('regression: pair flag', [59, 60], '00:00:00.29'), ('regression variant: pair flag', [4319999, 50], '23:59:59.24'), ('partial repair probe: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair variant: pair flag', [8294411, 48], '00:00:00.05'), ('boundary control', [2160000, 25], '00:00:00:00'), ('boundary control', [-1, 25], '23:59:59:24'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [2073600, 24], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10')], [('regression: pair flag', [216007, 60], '01:00:00.03'), ('regression variant: pair flag', [-5184003, 60], '23:59:59.28'), ('partial repair probe: pair flag', [1, 48], '00:00:00.00'), ('partial repair variant: pair flag', [16335211, 50], '18:45:04.05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2160000, 25], '00:00:00:00'), ('normal control', [23, 24], '00:00:00:23'), ('normal control', [2073605, 24], '00:00:00:05'), ('normal control', [86407, 24], '01:00:00:07')], [('regression: pair flag', [8640011, 50], '00:00:00.05'), ('regression variant: pair flag', [1, 48], '00:00:00.00'), ('partial repair probe: pair flag', [180007, 50], '01:00:00.03'), ('partial repair variant: pair flag', [2364826, 50], '13:08:16:13'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [24, 24], '00:00:01:00'), ('normal control', [90007, 25], '01:00:00:07'), ('normal control', [-24, 24], '23:59:59: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 fixtureActualExpectedOutcome
regression: pair flag00:00:00:0100:00:00.01Failed
regression variant: pair flag21:40:25:1021:40:25.10Failed
partial repair probe: pair flag00:00:00:0500:00:00.05Failed
partial repair variant: pair flag00:00:00:0200:00:00.02Failed
boundary control00:00:00:0000:00:00:00Passed
boundary control00:00:01:0000:00:01:00Passed
normal control23:59:59:2423:59:59:24Passed
normal control00:01:00:0300:01:00:03Passed
normal control03:37:12:2903:37:12:29Passed

SHA-256 / 650bf3cd7eae359ebbfdcf5183f80b9e902662e77330e17901e5cb37ba494007

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: pair flag', [3, 50], '00:00:00.01'), ('regression variant: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair probe: pair flag', [8640011, 50], '00:00:00.05'), ('partial repair variant: pair flag', [5184005, 60], '00:00:00.02'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [-1, 25], '23:59:59:24'), ('normal control', [1803, 30], '00:01:00:03'), ('normal control', [8166989, 30], '03:37:12:29')], [('regression: pair flag', [2, 50], '00:00:00:01'), ('regression variant: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair probe: pair flag', [3745221, 48], '21:40:25.10'), ('partial repair variant: pair flag', [10368011, 60], '00:00:00.05'), ('boundary control', [-1, 25], '23:59:59:24'), ('boundary control', [0, 25], '00:00:00:00'), ('normal control', [-1, 30], '23:59:59:29'), ('normal control', [-1, 24], '23:59:59:23'), ('normal control', [0, 24], '00:00:00:00')], [('regression: pair flag', [59, 60], '00:00:00.29'), ('regression variant: pair flag', [4319999, 50], '23:59:59.24'), ('partial repair probe: pair flag', [4147205, 48], '00:00:00.02'), ('partial repair variant: pair flag', [8294411, 48], '00:00:00.05'), ('boundary control', [2160000, 25], '00:00:00:00'), ('boundary control', [-1, 25], '23:59:59:24'), ('normal control', [31, 30], '00:00:01:01'), ('normal control', [2073600, 24], '00:00:00:00'), ('normal control', [954706, 24], '11:02:59:10')], [('regression: pair flag', [216007, 60], '01:00:00.03'), ('regression variant: pair flag', [-5184003, 60], '23:59:59.28'), ('partial repair probe: pair flag', [1, 48], '00:00:00.00'), ('partial repair variant: pair flag', [16335211, 50], '18:45:04.05'), ('boundary control', [30, 30], '00:00:01:00'), ('boundary control', [2160000, 25], '00:00:00:00'), ('normal control', [23, 24], '00:00:00:23'), ('normal control', [2073605, 24], '00:00:00:05'), ('normal control', [86407, 24], '01:00:00:07')], [('regression: pair flag', [8640011, 50], '00:00:00.05'), ('regression variant: pair flag', [1, 48], '00:00:00.00'), ('partial repair probe: pair flag', [180007, 50], '01:00:00.03'), ('partial repair variant: pair flag', [2364826, 50], '13:08:16:13'), ('boundary control', [0, 25], '00:00:00:00'), ('boundary control', [30, 30], '00:00:01:00'), ('normal control', [24, 24], '00:00:01:00'), ('normal control', [90007, 25], '01:00:00:07'), ('normal control', [-24, 24], '23:59:59: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 fixtureActualExpectedOutcome
regression: pair flag00:00:00.0100:00:00.01Passed
regression variant: pair flag21:40:25.1021:40:25.10Passed
partial repair probe: pair flag00:00:00.0500:00:00.05Passed
partial repair variant: pair flag00:00:00.0200:00:00.02Passed
boundary control00:00:00:0000:00:00:00Passed
boundary control00:00:01:0000:00:01:00Passed
normal control23:59:59:2423:59:59:24Passed
normal control00:01:00:0300:01:00:03Passed
normal control03:37:12:2903:37:12:29Passed

SHA-256 / 3b0666210b7c5da9da5988aafa1113dfebc75e914c26271ef8050979960e7b52

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.690729+00:00.

Case digest / 2b63dda56794ad65c0f8d8b2f41db4ca0318435420b0af80b6a109ea0a5959c6