FAILURE MAP
← Case archive

FA-78751 / Broadcast timecode arithmetic / Open access

Decimal seconds to frame label: nearest frame rounding · case 01

Offsets in the second half of a frame snap back to the earlier frame.

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

ROOT CAUSE

The frame position is truncated.

VERIFIED REPAIR

Round half up.

Unsuccessful approach: Round-half-even sends exact halves to the even frame.

Case contract

Convert a decimal seconds string exactly (no binary floating point) at rate [N,D] to the nearest frame, halves rounding up, and a non-drop label using the nominal rate ceil(N/D). Negative input returns None.

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
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        return None
    n=x*num/den
    fr=math.floor(n)
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: nearest frame rounding', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: nearest frame rounding', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: nearest frame rounding', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['1.001', [24, 1]], [24, '00:00:01:00']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02'])], [('regression: nearest frame rounding', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: nearest frame rounding', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair variant: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.1', [50, 1]], [5, '00:00:00:05']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00'])], [('regression: nearest frame rounding', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03']), ('normal control', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('normal control', ['0.06', [24, 1]], [1, '00:00:00:01'])]]
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: nearest frame rounding[1, '00:00:00:01'][2, '00:00:00:02']Failed
regression variant: nearest frame rounding[2, '00:00:00:02'][3, '00:00:00:03']Failed
partial repair probe: nearest frame rounding[4, '00:00:00:04'][5, '00:00:00:05']Failed
partial repair variant: nearest frame rounding[182, '00:00:07:07'][183, '00:00:07:08']Failed
boundary control[30, '00:00:01:00'][30, '00:00:01:00']Passed
boundary controlNoneNonePassed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / 7331605c97e97c18eaaf003872bfdc508119402669120e24a1e1ce52f08568a2

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        return None
    n=x*num/den
    fr=round(n)
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: nearest frame rounding', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: nearest frame rounding', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: nearest frame rounding', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['1.001', [24, 1]], [24, '00:00:01:00']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02'])], [('regression: nearest frame rounding', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: nearest frame rounding', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair variant: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.1', [50, 1]], [5, '00:00:00:05']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00'])], [('regression: nearest frame rounding', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03']), ('normal control', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('normal control', ['0.06', [24, 1]], [1, '00:00:00:01'])]]
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: nearest frame rounding[2, '00:00:00:02'][2, '00:00:00:02']Passed
regression variant: nearest frame rounding[2, '00:00:00:02'][3, '00:00:00:03']Failed
partial repair probe: nearest frame rounding[4, '00:00:00:04'][5, '00:00:00:05']Failed
partial repair variant: nearest frame rounding[182, '00:00:07:07'][183, '00:00:07:08']Failed
boundary control[30, '00:00:01:00'][30, '00:00:01:00']Passed
boundary controlNoneNonePassed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / d3d251ae20a22611f8a1bedcf81318847927dff88049a603528d2f5141665450

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        return None
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: nearest frame rounding', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: nearest frame rounding', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: nearest frame rounding', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame rounding', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['1.001', [24, 1]], [24, '00:00:01:00']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02'])], [('regression: nearest frame rounding', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: nearest frame rounding', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair variant: nearest frame rounding', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.1', [50, 1]], [5, '00:00:00:05']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00'])], [('regression: nearest frame rounding', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame rounding', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: nearest frame rounding', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: nearest frame rounding', ['0.1', [25, 1]], [3, '00:00:00:03']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03']), ('normal control', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('normal control', ['0.06', [24, 1]], [1, '00:00:00:01'])]]
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: nearest frame rounding[2, '00:00:00:02'][2, '00:00:00:02']Passed
regression variant: nearest frame rounding[3, '00:00:00:03'][3, '00:00:00:03']Passed
partial repair probe: nearest frame rounding[5, '00:00:00:05'][5, '00:00:00:05']Passed
partial repair variant: nearest frame rounding[183, '00:00:07:08'][183, '00:00:07:08']Passed
boundary control[30, '00:00:01:00'][30, '00:00:01:00']Passed
boundary controlNoneNonePassed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / 39f141477742e295c612cc9f4e15d162c289d2260a649883da4a0e5f1694c72d

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

Case digest / dcd07b0d1a41b66745036af9d0eeb37697b5afa50a24490d408938c159bb6bbd