FAILURE MAP
← Case archive

FA-78196 / Subtitle cue timing / Open access

Timed-text time expression evaluation: frame metric scale · case 01

Frame offsets at rates that do not divide 1000 lose their fractional milliseconds before rounding.

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

ROOT CAUSE

The frame offset uses floor division before the final half-up rounding.

VERIFIED REPAIR

Keep the exact quotient and round once at the end.

Unsuccessful approach: Hard-coding 30 frames per second breaks every other frame rate.

Case contract

Evaluate a timed-text time expression to integer ms, rounded half up. Offset form <number><metric> with metric h, m, s, ms, f (frames at frame_rate) or t (ticks at tick_rate). Clock form HH:MM:SS with optional .fraction (any digits) or :FF frames (FF < frame_rate). Minutes/seconds above 59 or malformed text give None.

Why this case matters

Subtitle timing defects shift, hide or overlap captions that viewers depend on for comprehension and accessibility.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import re
from fractions import Fraction
N = 1
observations = []
def solve(expr, frame_rate, tick_rate):
    m=re.fullmatch(r'(\d+(?:\.\d+)?)(h|ms|m|s|f|t)',expr)
    if m:
        v=Fraction(m.group(1))
        unit=m.group(2)
        scale={'h':3600000,'m':60000,'s':1000,'ms':1}
        if unit in scale:
            x=v*scale[unit]
        elif unit=='f':
            x=v*1000//frame_rate
        else:
            x=v*1000/tick_rate
        return math.floor(x+Fraction(1,2))
    m=re.fullmatch(r'(\d{2,}):(\d{2}):(\d{2})(?:\.(\d+)|:(\d{2,}))?',expr)
    if not m:
        return None
    h,mi,se,frac,fr=m.groups()
    if int(mi)>59 or int(se)>59:
        return None
    x=Fraction(int(h)*3600+int(mi)*60+int(se))*1000
    if frac:
        x+=Fraction('0.'+frac)*1000
    if fr:
        if int(fr)>=frame_rate:
            return None
        x+=Fraction(int(fr)*1000,frame_rate)
    return (x*2+1)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame metric scale', ['3f', 16, 1000], 188), ('regression variant: frame metric scale', ['15f', 16, 1000], 938), ('partial repair probe: frame metric scale', ['1.5f', 16, 1000], 94), ('partial repair variant: frame metric scale', ['1f', 40, 90000], 25), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['10:59:59:15', 40, 1000], 39599375), ('normal control', ['01:60:59:30', 50, 10000000], None)], [('regression: frame metric scale', ['1.5f', 16, 1000], 94), ('regression variant: frame metric scale', ['12.25f', 16, 10000000], 766), ('partial repair probe: frame metric scale', ['2f', 24, 3], 83), ('partial repair variant: frame metric scale', ['2f', 16, 1000], 125), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('boundary control', ['10t', 25, 1000], 10), ('normal control', ['0ms', 16, 90000], 0), ('normal control', ['2t', 30, 3], 667), ('normal control', ['0.001t', 24, 1000], 0)], [('regression: frame metric scale', ['7f', 16, 10000000], 438), ('regression variant: frame metric scale', ['2f', 30, 1000], 67), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['7f', 16, 90000], 438), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['0f', 24, 90000], 0), ('normal control', ['10:30:00:25', 16, 10000000], None), ('normal control', ['15t', 30, 3], 5000)], [('regression: frame metric scale', ['17f', 30, 90000], 567), ('regression variant: frame metric scale', ['7f', 16, 3], 438), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['17f', 24, 1000], 708), ('boundary control', ['00:00:00:25', 25, 1000], None), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('normal control', ['01:60:05:12', 16, 10000000], None), ('normal control', ['100:30:05:30', 16, 10000000], None), ('normal control', ['1.5t', 16, 3], 500)], [('regression: frame metric scale', ['7f', 16, 90000], 438), ('regression variant: frame metric scale', ['3f', 16, 1000], 188), ('partial repair probe: frame metric scale', ['1f', 50, 90000], 20), ('partial repair variant: frame metric scale', ['15f', 16, 1000], 938), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['10:00:00.25', 16, 3], 36000250), ('normal control', ['2ms', 40, 90000], 2), ('normal control', ['01:30:05:25', 16, 90000], None)]]
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: frame metric scale187188Failed
regression variant: frame metric scale937938Failed
partial repair probe: frame metric scale9394Failed
partial repair variant: frame metric scale2525Passed
boundary control1010Passed
boundary controlNoneNonePassed
normal control19381938Passed
normal control3959937539599375Passed
normal controlNoneNonePassed

SHA-256 / 3a1e7278ab726f17eddcff98196957ce70f92d557b092f73a9ad591982abfc4a

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import re
from fractions import Fraction
N = 1
observations = []
def solve(expr, frame_rate, tick_rate):
    m=re.fullmatch(r'(\d+(?:\.\d+)?)(h|ms|m|s|f|t)',expr)
    if m:
        v=Fraction(m.group(1))
        unit=m.group(2)
        scale={'h':3600000,'m':60000,'s':1000,'ms':1}
        if unit in scale:
            x=v*scale[unit]
        elif unit=='f':
            x=v*1000/30
        else:
            x=v*1000/tick_rate
        return math.floor(x+Fraction(1,2))
    m=re.fullmatch(r'(\d{2,}):(\d{2}):(\d{2})(?:\.(\d+)|:(\d{2,}))?',expr)
    if not m:
        return None
    h,mi,se,frac,fr=m.groups()
    if int(mi)>59 or int(se)>59:
        return None
    x=Fraction(int(h)*3600+int(mi)*60+int(se))*1000
    if frac:
        x+=Fraction('0.'+frac)*1000
    if fr:
        if int(fr)>=frame_rate:
            return None
        x+=Fraction(int(fr)*1000,frame_rate)
    return (x*2+1)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame metric scale', ['3f', 16, 1000], 188), ('regression variant: frame metric scale', ['15f', 16, 1000], 938), ('partial repair probe: frame metric scale', ['1.5f', 16, 1000], 94), ('partial repair variant: frame metric scale', ['1f', 40, 90000], 25), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['10:59:59:15', 40, 1000], 39599375), ('normal control', ['01:60:59:30', 50, 10000000], None)], [('regression: frame metric scale', ['1.5f', 16, 1000], 94), ('regression variant: frame metric scale', ['12.25f', 16, 10000000], 766), ('partial repair probe: frame metric scale', ['2f', 24, 3], 83), ('partial repair variant: frame metric scale', ['2f', 16, 1000], 125), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('boundary control', ['10t', 25, 1000], 10), ('normal control', ['0ms', 16, 90000], 0), ('normal control', ['2t', 30, 3], 667), ('normal control', ['0.001t', 24, 1000], 0)], [('regression: frame metric scale', ['7f', 16, 10000000], 438), ('regression variant: frame metric scale', ['2f', 30, 1000], 67), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['7f', 16, 90000], 438), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['0f', 24, 90000], 0), ('normal control', ['10:30:00:25', 16, 10000000], None), ('normal control', ['15t', 30, 3], 5000)], [('regression: frame metric scale', ['17f', 30, 90000], 567), ('regression variant: frame metric scale', ['7f', 16, 3], 438), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['17f', 24, 1000], 708), ('boundary control', ['00:00:00:25', 25, 1000], None), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('normal control', ['01:60:05:12', 16, 10000000], None), ('normal control', ['100:30:05:30', 16, 10000000], None), ('normal control', ['1.5t', 16, 3], 500)], [('regression: frame metric scale', ['7f', 16, 90000], 438), ('regression variant: frame metric scale', ['3f', 16, 1000], 188), ('partial repair probe: frame metric scale', ['1f', 50, 90000], 20), ('partial repair variant: frame metric scale', ['15f', 16, 1000], 938), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['10:00:00.25', 16, 3], 36000250), ('normal control', ['2ms', 40, 90000], 2), ('normal control', ['01:30:05:25', 16, 90000], None)]]
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: frame metric scale100188Failed
regression variant: frame metric scale500938Failed
partial repair probe: frame metric scale5094Failed
partial repair variant: frame metric scale3325Failed
boundary control1010Passed
boundary controlNoneNonePassed
normal control19381938Passed
normal control3959937539599375Passed
normal controlNoneNonePassed

SHA-256 / 75768c30ef458b48763ca08a001b5ba3e5911c652ffc0754b5c7626787f40c43

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import re
from fractions import Fraction
N = 1
observations = []
def solve(expr, frame_rate, tick_rate):
    m=re.fullmatch(r'(\d+(?:\.\d+)?)(h|ms|m|s|f|t)',expr)
    if m:
        v=Fraction(m.group(1))
        unit=m.group(2)
        scale={'h':3600000,'m':60000,'s':1000,'ms':1}
        if unit in scale:
            x=v*scale[unit]
        elif unit=='f':
            x=v*1000/frame_rate
        else:
            x=v*1000/tick_rate
        return math.floor(x+Fraction(1,2))
    m=re.fullmatch(r'(\d{2,}):(\d{2}):(\d{2})(?:\.(\d+)|:(\d{2,}))?',expr)
    if not m:
        return None
    h,mi,se,frac,fr=m.groups()
    if int(mi)>59 or int(se)>59:
        return None
    x=Fraction(int(h)*3600+int(mi)*60+int(se))*1000
    if frac:
        x+=Fraction('0.'+frac)*1000
    if fr:
        if int(fr)>=frame_rate:
            return None
        x+=Fraction(int(fr)*1000,frame_rate)
    return (x*2+1)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame metric scale', ['3f', 16, 1000], 188), ('regression variant: frame metric scale', ['15f', 16, 1000], 938), ('partial repair probe: frame metric scale', ['1.5f', 16, 1000], 94), ('partial repair variant: frame metric scale', ['1f', 40, 90000], 25), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['10:59:59:15', 40, 1000], 39599375), ('normal control', ['01:60:59:30', 50, 10000000], None)], [('regression: frame metric scale', ['1.5f', 16, 1000], 94), ('regression variant: frame metric scale', ['12.25f', 16, 10000000], 766), ('partial repair probe: frame metric scale', ['2f', 24, 3], 83), ('partial repair variant: frame metric scale', ['2f', 16, 1000], 125), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('boundary control', ['10t', 25, 1000], 10), ('normal control', ['0ms', 16, 90000], 0), ('normal control', ['2t', 30, 3], 667), ('normal control', ['0.001t', 24, 1000], 0)], [('regression: frame metric scale', ['7f', 16, 10000000], 438), ('regression variant: frame metric scale', ['2f', 30, 1000], 67), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['7f', 16, 90000], 438), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('boundary control', ['00:00:01:15', 16, 1000], 1938), ('normal control', ['0f', 24, 90000], 0), ('normal control', ['10:30:00:25', 16, 10000000], None), ('normal control', ['15t', 30, 3], 5000)], [('regression: frame metric scale', ['17f', 30, 90000], 567), ('regression variant: frame metric scale', ['7f', 16, 3], 438), ('partial repair probe: frame metric scale', ['3f', 50, 3], 60), ('partial repair variant: frame metric scale', ['17f', 24, 1000], 708), ('boundary control', ['00:00:00:25', 25, 1000], None), ('boundary control', ['00:00:01.0005', 25, 1000], 1001), ('normal control', ['01:60:05:12', 16, 10000000], None), ('normal control', ['100:30:05:30', 16, 10000000], None), ('normal control', ['1.5t', 16, 3], 500)], [('regression: frame metric scale', ['7f', 16, 90000], 438), ('regression variant: frame metric scale', ['3f', 16, 1000], 188), ('partial repair probe: frame metric scale', ['1f', 50, 90000], 20), ('partial repair variant: frame metric scale', ['15f', 16, 1000], 938), ('boundary control', ['10t', 25, 1000], 10), ('boundary control', ['00:00:00:25', 25, 1000], None), ('normal control', ['10:00:00.25', 16, 3], 36000250), ('normal control', ['2ms', 40, 90000], 2), ('normal control', ['01:30:05:25', 16, 90000], None)]]
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: frame metric scale188188Passed
regression variant: frame metric scale938938Passed
partial repair probe: frame metric scale9494Passed
partial repair variant: frame metric scale2525Passed
boundary control1010Passed
boundary controlNoneNonePassed
normal control19381938Passed
normal control3959937539599375Passed
normal controlNoneNonePassed

SHA-256 / a551cd5895fe5f60213b3c77ce1422b9dcb65c21471bf00ae197ffb86cd8d12a

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to any subtitle 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:33.063988+00:00.

Case digest / f2eae7ddcfd7d9ad58d5fcddd6e498056396bb7711a459cbc9341bdaa834e6c1