FAILURE MAP
← Case archive

FA-78646 / Broadcast timecode arithmetic / Open access

Programme-relative signed timecode: offset wrap · case 01

Programmes that cross midnight report offsets of almost minus a day.

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

ROOT CAUSE

The raw difference is used without wrapping.

VERIFIED REPAIR

Wrap the difference modulo one day before folding.

Unsuccessful approach: The absolute difference loses the sign of pre-roll offsets.

Case contract

Express label tc relative to programme start as "+HH:MM:SS:FF" or "-HH:MM:SS:FF" along the shorter way round the 24-hour clock (an offset of exactly 12 hours is negative). Zero is "+".

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(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=fr(tc)-fr(start)
    if d>=day//2:
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: offset wrap', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('regression variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('partial repair probe: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('regression variant: offset wrap', ['01:00:01:00', '23:59:00:00', 25], '+01:01:01:00'), ('partial repair probe: offset wrap', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('partial repair variant: offset wrap', ['00:01:00:00', '01:00:00:00', 25], '-00:59:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('normal control', ['12:59:59:24', '01:00:00:00', 30], '+11:59:59:24'), ('normal control', ['00:00:10:00', '00:00:10:00', 30], '+00:00:00:00')], [('regression: offset wrap', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00'), ('regression variant: offset wrap', ['10:01:01:12', '23:59:00:00', 25], '+10:02:01:12'), ('partial repair probe: offset wrap', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '00:00:10:00', 30], '-00:00:10:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:30:01', '01:00:00:00', 30], '+00:00:30:01'), ('normal control', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06')], [('regression: offset wrap', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('regression variant: offset wrap', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01'), ('partial repair probe: offset wrap', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair variant: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['01:29:30:15', '01:00:00:00', 30], '+00:29:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01')], [('regression: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('regression variant: offset wrap', ['01:01:30:12', '23:59:00:00', 25], '+01:02:30:12'), ('partial repair probe: offset wrap', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('normal control', ['23:59:00:00', '23:59:00:00', 30], '+00:00:00:00'), ('normal control', ['00:01:00:29', '00:00:10:00', 30], '+00:00:50:29')]]
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: offset wrap-23:58:00:00+00:02:00:00Failed
regression variant: offset wrap-22:58:29:24+01:01:30:01Failed
partial repair probe: offset wrap-21:59:00:01+02:00:59:29Failed
partial repair variant: offset wrap-01:00:00:00-01:00:00:00Passed
boundary control-00:00:20:00-00:00:20:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control-12:00:00:00-12:00:00:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / cac864f77d6194c034e39744a0a4497d5277d6852456ef6e9e0ddd745c139ff6

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=abs(fr(tc)-fr(start))
    if d>=day//2:
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: offset wrap', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('regression variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('partial repair probe: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('regression variant: offset wrap', ['01:00:01:00', '23:59:00:00', 25], '+01:01:01:00'), ('partial repair probe: offset wrap', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('partial repair variant: offset wrap', ['00:01:00:00', '01:00:00:00', 25], '-00:59:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('normal control', ['12:59:59:24', '01:00:00:00', 30], '+11:59:59:24'), ('normal control', ['00:00:10:00', '00:00:10:00', 30], '+00:00:00:00')], [('regression: offset wrap', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00'), ('regression variant: offset wrap', ['10:01:01:12', '23:59:00:00', 25], '+10:02:01:12'), ('partial repair probe: offset wrap', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '00:00:10:00', 30], '-00:00:10:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:30:01', '01:00:00:00', 30], '+00:00:30:01'), ('normal control', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06')], [('regression: offset wrap', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('regression variant: offset wrap', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01'), ('partial repair probe: offset wrap', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair variant: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['01:29:30:15', '01:00:00:00', 30], '+00:29:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01')], [('regression: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('regression variant: offset wrap', ['01:01:30:12', '23:59:00:00', 25], '+01:02:30:12'), ('partial repair probe: offset wrap', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('normal control', ['23:59:00:00', '23:59:00:00', 30], '+00:00:00:00'), ('normal control', ['00:01:00:29', '00:00:10:00', 30], '+00:00:50:29')]]
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: offset wrap-00:02:00:00+00:02:00:00Failed
regression variant: offset wrap-01:01:30:01+01:01:30:01Failed
partial repair probe: offset wrap-02:00:59:29+02:00:59:29Failed
partial repair variant: offset wrap+01:00:00:00-01:00:00:00Failed
boundary control-00:00:20:00-00:00:20:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control-12:00:00:00-12:00:00:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / 4677622836f65abc776ddcb49495eee703c58320b8107c8319147d869e5d3395

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=(fr(tc)-fr(start))%day
    if d>=day//2:
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: offset wrap', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('regression variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('partial repair probe: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: offset wrap', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('regression variant: offset wrap', ['01:00:01:00', '23:59:00:00', 25], '+01:01:01:00'), ('partial repair probe: offset wrap', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('partial repair variant: offset wrap', ['00:01:00:00', '01:00:00:00', 25], '-00:59:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('normal control', ['12:59:59:24', '01:00:00:00', 30], '+11:59:59:24'), ('normal control', ['00:00:10:00', '00:00:10:00', 30], '+00:00:00:00')], [('regression: offset wrap', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00'), ('regression variant: offset wrap', ['10:01:01:12', '23:59:00:00', 25], '+10:02:01:12'), ('partial repair probe: offset wrap', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('partial repair variant: offset wrap', ['00:00:00:00', '00:00:10:00', 30], '-00:00:10:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:30:01', '01:00:00:00', 30], '+00:00:30:01'), ('normal control', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06')], [('regression: offset wrap', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('regression variant: offset wrap', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01'), ('partial repair probe: offset wrap', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair variant: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('normal control', ['01:29:30:15', '01:00:00:00', 30], '+00:29:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01')], [('regression: offset wrap', ['10:29:01:01', '23:59:00:00', 25], '+10:30:01:01'), ('regression variant: offset wrap', ['01:01:30:12', '23:59:00:00', 25], '+01:02:30:12'), ('partial repair probe: offset wrap', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair variant: offset wrap', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('boundary control', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('normal control', ['23:59:00:00', '23:59:00:00', 30], '+00:00:00:00'), ('normal control', ['00:01:00:29', '00:00:10:00', 30], '+00:00:50:29')]]
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: offset wrap+00:02:00:00+00:02:00:00Passed
regression variant: offset wrap+01:01:30:01+01:01:30:01Passed
partial repair probe: offset wrap+02:00:59:29+02:00:59:29Passed
partial repair variant: offset wrap-01:00:00:00-01:00:00:00Passed
boundary control-00:00:20:00-00:00:20:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control-12:00:00:00-12:00:00:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / ed3377f20a67c142c880cf3bc360a2d2b5f204e127ffe47cbd6740d3bc9bb0b6

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

Case digest / 1d06018630a20dc025eab1c4f40c92a38430fe309e21e05dbf927639e508e5b7