FAILURE MAP
← Case archive

FA-78601 / Broadcast timecode arithmetic / Open access

Non-drop label to wall clock at pulled-down rates: ms to frame rounding · case 01

Wall-clock times just before a frame boundary snap to the previous frame.

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

ROOT CAUSE

The frame index is floored instead of rounded to nearest.

VERIFIED REPAIR

Round to the nearest frame, halves up.

Unsuccessful approach: Half-to-even rounding sends exact halves to even frames.

Case contract

Rates "23.976", "29.97", "59.94" run at nominal*1000/1001 frames per second while labels count nominal frames per second (non-drop). mode "to_ms": label to elapsed milliseconds, rounded half up. mode "to_tc": milliseconds to the nearest frame (half up), formatted as a non-drop label wrapping at 24 hours.

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(value, rate, mode):
    nominal={'23.976':24,'29.97':30,'59.94':60,'24':24,'25':25,'30':30}[rate]
    den=1001 if '.' in rate else 1000
    num=nominal*1000
    if mode=='to_ms':
        h,m,s,f=map(int,value.split(':'))
        n=((h*60+m)*60+s)*nominal+f
        return (2*n*1000*den+num)//(2*num)
    n=value*num//(1000*den)
    return '%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ms to frame rounding', [86399999, '25', 'to_tc'], '00:00:00:00'), ('regression variant: ms to frame rounding', [60, '25', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', [1, '24', 'to_tc'], '00:00:00:00'), ('normal control', [3603600, '23.976', 'to_tc'], '01:00:00:00')], [('regression: ms to frame rounding', [250, '59.94', 'to_tc'], '00:00:00:15'), ('regression variant: ms to frame rounding', [86399999, '24', 'to_tc'], '00:00:00:00'), ('partial repair probe: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair variant: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('normal control', ['23:01:00:12', '30', 'to_ms'], 82860400), ('normal control', [86399999, '23.976', 'to_tc'], '23:58:33:16'), ('normal control', ['01:01:01:36', '30', 'to_ms'], 3662200)], [('regression: ms to frame rounding', [33, '30', 'to_tc'], '00:00:00:01'), ('regression variant: ms to frame rounding', [60, '29.97', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', ['23:59:59:15', '59.94', 'to_ms'], 86485649), ('normal control', [3600000, '30', 'to_tc'], '01:00:00:00'), ('normal control', ['01:01:01:15', '23.976', 'to_ms'], 3665287)], [('regression: ms to frame rounding', [150, '23.976', 'to_tc'], '00:00:00:04'), ('regression variant: ms to frame rounding', [20, '29.97', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('normal control', [0, '23.976', 'to_tc'], '00:00:00:00'), ('normal control', [100, '23.976', 'to_tc'], '00:00:00:02'), ('normal control', ['01:01:59:45', '25', 'to_ms'], 3720800)], [('regression: ms to frame rounding', [100, '59.94', 'to_tc'], '00:00:00:06'), ('regression variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', [250, '24', 'to_tc'], '00:00:00:06'), ('normal control', ['23:00:59:00', '29.97', 'to_ms'], 82941859), ('normal control', [0, '24', 'to_tc'], '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 fixtureActualExpectedOutcome
regression: ms to frame rounding23:59:59:2400:00:00:00Failed
regression variant: ms to frame rounding00:00:00:0100:00:00:02Failed
partial repair probe: ms to frame rounding00:00:00:0200:00:00:03Failed
partial repair variant: ms to frame rounding00:00:00:0000:00:00:01Failed
boundary control36036003603600Passed
boundary control4040Passed
normal control4242Passed
normal control00:00:00:0000:00:00:00Passed
normal control01:00:00:0001:00:00:00Passed

SHA-256 / 34261bb44f783f3da90662667d83350aec714bc291dd200c77fc8450d197a194

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(value, rate, mode):
    nominal={'23.976':24,'29.97':30,'59.94':60,'24':24,'25':25,'30':30}[rate]
    den=1001 if '.' in rate else 1000
    num=nominal*1000
    if mode=='to_ms':
        h,m,s,f=map(int,value.split(':'))
        n=((h*60+m)*60+s)*nominal+f
        return (2*n*1000*den+num)//(2*num)
    n=round(value*num/(1000*den))
    return '%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ms to frame rounding', [86399999, '25', 'to_tc'], '00:00:00:00'), ('regression variant: ms to frame rounding', [60, '25', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', [1, '24', 'to_tc'], '00:00:00:00'), ('normal control', [3603600, '23.976', 'to_tc'], '01:00:00:00')], [('regression: ms to frame rounding', [250, '59.94', 'to_tc'], '00:00:00:15'), ('regression variant: ms to frame rounding', [86399999, '24', 'to_tc'], '00:00:00:00'), ('partial repair probe: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair variant: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('normal control', ['23:01:00:12', '30', 'to_ms'], 82860400), ('normal control', [86399999, '23.976', 'to_tc'], '23:58:33:16'), ('normal control', ['01:01:01:36', '30', 'to_ms'], 3662200)], [('regression: ms to frame rounding', [33, '30', 'to_tc'], '00:00:00:01'), ('regression variant: ms to frame rounding', [60, '29.97', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', ['23:59:59:15', '59.94', 'to_ms'], 86485649), ('normal control', [3600000, '30', 'to_tc'], '01:00:00:00'), ('normal control', ['01:01:01:15', '23.976', 'to_ms'], 3665287)], [('regression: ms to frame rounding', [150, '23.976', 'to_tc'], '00:00:00:04'), ('regression variant: ms to frame rounding', [20, '29.97', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('normal control', [0, '23.976', 'to_tc'], '00:00:00:00'), ('normal control', [100, '23.976', 'to_tc'], '00:00:00:02'), ('normal control', ['01:01:59:45', '25', 'to_ms'], 3720800)], [('regression: ms to frame rounding', [100, '59.94', 'to_tc'], '00:00:00:06'), ('regression variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', [250, '24', 'to_tc'], '00:00:00:06'), ('normal control', ['23:00:59:00', '29.97', 'to_ms'], 82941859), ('normal control', [0, '24', 'to_tc'], '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 fixtureActualExpectedOutcome
regression: ms to frame rounding00:00:00:0000:00:00:00Passed
regression variant: ms to frame rounding00:00:00:0200:00:00:02Passed
partial repair probe: ms to frame rounding00:00:00:0200:00:00:03Failed
partial repair variant: ms to frame rounding00:00:00:0000:00:00:01Failed
boundary control36036003603600Passed
boundary control4040Passed
normal control4242Passed
normal control00:00:00:0000:00:00:00Passed
normal control01:00:00:0001:00:00:00Passed

SHA-256 / c368008a69f56eedfd15a29068d1d9445d1d00951f17981bfe21f270628ea79f

3 / The verified repair

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

N = 1
observations = []
def solve(value, rate, mode):
    nominal={'23.976':24,'29.97':30,'59.94':60,'24':24,'25':25,'30':30}[rate]
    den=1001 if '.' in rate else 1000
    num=nominal*1000
    if mode=='to_ms':
        h,m,s,f=map(int,value.split(':'))
        n=((h*60+m)*60+s)*nominal+f
        return (2*n*1000*den+num)//(2*num)
    n=(2*value*num+1000*den)//(2000*den)
    return '%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ms to frame rounding', [86399999, '25', 'to_tc'], '00:00:00:00'), ('regression variant: ms to frame rounding', [60, '25', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', [1, '24', 'to_tc'], '00:00:00:00'), ('normal control', [3603600, '23.976', 'to_tc'], '01:00:00:00')], [('regression: ms to frame rounding', [250, '59.94', 'to_tc'], '00:00:00:15'), ('regression variant: ms to frame rounding', [86399999, '24', 'to_tc'], '00:00:00:00'), ('partial repair probe: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair variant: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('normal control', ['23:01:00:12', '30', 'to_ms'], 82860400), ('normal control', [86399999, '23.976', 'to_tc'], '23:58:33:16'), ('normal control', ['01:01:01:36', '30', 'to_ms'], 3662200)], [('regression: ms to frame rounding', [33, '30', 'to_tc'], '00:00:00:01'), ('regression variant: ms to frame rounding', [60, '29.97', 'to_tc'], '00:00:00:02'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('boundary control', ['00:00:00:01', '23.976', 'to_ms'], 42), ('normal control', ['23:59:59:15', '59.94', 'to_ms'], 86485649), ('normal control', [3600000, '30', 'to_tc'], '01:00:00:00'), ('normal control', ['01:01:01:15', '23.976', 'to_ms'], 3665287)], [('regression: ms to frame rounding', [150, '23.976', 'to_tc'], '00:00:00:04'), ('regression variant: ms to frame rounding', [20, '29.97', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('partial repair variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('boundary control', [3600000, '29.97', 'to_tc'], '00:59:56:12'), ('normal control', [0, '23.976', 'to_tc'], '00:00:00:00'), ('normal control', [100, '23.976', 'to_tc'], '00:00:00:02'), ('normal control', ['01:01:59:45', '25', 'to_ms'], 3720800)], [('regression: ms to frame rounding', [100, '59.94', 'to_tc'], '00:00:00:06'), ('regression variant: ms to frame rounding', [20, '25', 'to_tc'], '00:00:00:01'), ('partial repair probe: ms to frame rounding', [150, '30', 'to_tc'], '00:00:00:05'), ('partial repair variant: ms to frame rounding', [100, '25', 'to_tc'], '00:00:00:03'), ('boundary control', ['01:00:00:00', '29.97', 'to_ms'], 3603600), ('boundary control', ['00:00:00:01', '25', 'to_ms'], 40), ('normal control', [250, '24', 'to_tc'], '00:00:00:06'), ('normal control', ['23:00:59:00', '29.97', 'to_ms'], 82941859), ('normal control', [0, '24', 'to_tc'], '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 fixtureActualExpectedOutcome
regression: ms to frame rounding00:00:00:0000:00:00:00Passed
regression variant: ms to frame rounding00:00:00:0200:00:00:02Passed
partial repair probe: ms to frame rounding00:00:00:0300:00:00:03Passed
partial repair variant: ms to frame rounding00:00:00:0100:00:00:01Passed
boundary control36036003603600Passed
boundary control4040Passed
normal control4242Passed
normal control00:00:00:0000:00:00:00Passed
normal control01:00:00:0001:00:00:00Passed

SHA-256 / 5f84b18e3a843e247d152cf81bba8205090f3dcab4fffaa0e1e62c523605b58f

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

Case digest / 43d7d7ba9424ba7266f7560886fdf845f3f6237a60eafcc0ac4ecb07c41af42d