FAILURE MAP
← Case archive

FA-78746 / Broadcast timecode arithmetic / Open access

Decimal seconds to frame label: rate scaling · case 01

Half-frame offsets are always rounded as if they were whole frames.

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

ROOT CAUSE

The frame position is floored before the half-up rounding step.

VERIFIED REPAIR

Keep the exact frame position until the final rounding.

Unsuccessful approach: Truncating the rate to 29 or 23 fps drifts NTSC positions.

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+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: rate scaling', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: rate scaling', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('partial repair variant: rate scaling', ['3600', [24000, 1001]], [86314, '00:59:56:10']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['-1', [24, 1]], None), ('normal control', ['0.14', [24000, 1001]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['7.3', [30000, 1001]], [219, '00:00:07:09']), ('partial repair variant: rate scaling', ['1.5', [24000, 1001]], [36, '00:00:01:12']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.02', [24000, 1001]], [0, '00:00:00:00'])], [('regression: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: rate scaling', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('partial repair variant: rate scaling', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-0.5', [50, 1]], None), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: rate scaling', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: rate scaling', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: rate scaling', ['12.345', [30000, 1001]], [370, '00:00:12:10']), ('partial repair variant: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.22', [50, 1]], [11, '00:00:00:11']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['0.22', [30000, 1001]], [7, '00:00:00:07']), ('partial repair variant: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['12.345', [50, 1]], [617, '00:00:12:17']), ('normal control', ['0', [50, 1]], [0, '00:00:00:00']), ('normal control', ['0.0166', [25, 1]], [0, '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: rate scaling[1, '00:00:00:01'][2, '00:00:00:02']Failed
regression variant: rate scaling[2, '00:00:00:02'][3, '00:00:00:03']Failed
partial repair probe: rate scaling[107892, '00:59:56:12'][107892, '00:59:56:12']Passed
partial repair variant: rate scaling[86313, '00:59:56:09'][86314, '00:59:56:10']Failed
boundary controlNoneNonePassed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal controlNoneNonePassed
normal control[3, '00:00:00:03'][3, '00:00:00:03']Passed

SHA-256 / c57f4b47064f72cee725a2beb1bd30f36d9fa4aa32d83957242632732833654e

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=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: rate scaling', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: rate scaling', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('partial repair variant: rate scaling', ['3600', [24000, 1001]], [86314, '00:59:56:10']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['-1', [24, 1]], None), ('normal control', ['0.14', [24000, 1001]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['7.3', [30000, 1001]], [219, '00:00:07:09']), ('partial repair variant: rate scaling', ['1.5', [24000, 1001]], [36, '00:00:01:12']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.02', [24000, 1001]], [0, '00:00:00:00'])], [('regression: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: rate scaling', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('partial repair variant: rate scaling', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-0.5', [50, 1]], None), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: rate scaling', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: rate scaling', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: rate scaling', ['12.345', [30000, 1001]], [370, '00:00:12:10']), ('partial repair variant: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.22', [50, 1]], [11, '00:00:00:11']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['0.22', [30000, 1001]], [7, '00:00:00:07']), ('partial repair variant: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['12.345', [50, 1]], [617, '00:00:12:17']), ('normal control', ['0', [50, 1]], [0, '00:00:00:00']), ('normal control', ['0.0166', [25, 1]], [0, '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: rate scaling[2, '00:00:00:02'][2, '00:00:00:02']Passed
regression variant: rate scaling[3, '00:00:00:03'][3, '00:00:00:03']Passed
partial repair probe: rate scaling[104400, '00:58:00:00'][107892, '00:59:56:12']Failed
partial repair variant: rate scaling[82800, '00:57:30:00'][86314, '00:59:56:10']Failed
boundary controlNoneNonePassed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal controlNoneNonePassed
normal control[3, '00:00:00:03'][3, '00:00:00:03']Passed

SHA-256 / 55a52291870619ed47c8681b5f6548d254057f838b7d3dc34e614a47f93c9816

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: rate scaling', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: rate scaling', ['0.1', [25, 1]], [3, '00:00:00:03']), ('partial repair probe: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('partial repair variant: rate scaling', ['3600', [24000, 1001]], [86314, '00:59:56:10']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['-1', [24, 1]], None), ('normal control', ['0.14', [24000, 1001]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.02', [25, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.02', [30000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['7.3', [30000, 1001]], [219, '00:00:07:09']), ('partial repair variant: rate scaling', ['1.5', [24000, 1001]], [36, '00:00:01:12']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.02', [24000, 1001]], [0, '00:00:00:00'])], [('regression: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('regression variant: rate scaling', ['0.04', [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['1.001', [24000, 1001]], [24, '00:00:01:00']), ('partial repair variant: rate scaling', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['-0.5', [50, 1]], None), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: rate scaling', ['1.5', [25, 1]], [38, '00:00:01:13']), ('regression variant: rate scaling', ['0.14', [25, 1]], [4, '00:00:00:04']), ('partial repair probe: rate scaling', ['12.345', [30000, 1001]], [370, '00:00:12:10']), ('partial repair variant: rate scaling', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.22', [50, 1]], [11, '00:00:00:11']), ('normal control', ['0.0166', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['0.06', [50, 1]], [3, '00:00:00:03'])], [('regression: rate scaling', ['0.04', [24, 1]], [1, '00:00:00:01']), ('regression variant: rate scaling', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('partial repair probe: rate scaling', ['0.22', [30000, 1001]], [7, '00:00:00:07']), ('partial repair variant: rate scaling', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['12.345', [50, 1]], [617, '00:00:12:17']), ('normal control', ['0', [50, 1]], [0, '00:00:00:00']), ('normal control', ['0.0166', [25, 1]], [0, '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: rate scaling[2, '00:00:00:02'][2, '00:00:00:02']Passed
regression variant: rate scaling[3, '00:00:00:03'][3, '00:00:00:03']Passed
partial repair probe: rate scaling[107892, '00:59:56:12'][107892, '00:59:56:12']Passed
partial repair variant: rate scaling[86314, '00:59:56:10'][86314, '00:59:56:10']Passed
boundary controlNoneNonePassed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal controlNoneNonePassed
normal controlNoneNonePassed
normal control[3, '00:00:00:03'][3, '00:00:00:03']Passed

SHA-256 / 87e1c6a05ca2f410a388c722b9dd243633c467c808abcfc94fa21dc0efe6917b

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

Case digest / ca94d1527ab2fa796020678f4bd34d6aa3440d4004d3eb5c7ed3f03ca3ee706c