FAILURE MAP
← Case archive

FA-78141 / Subtitle cue timing / Open access

Shot-change snapping of cue boundaries: snap window · case 01

Boundaries exactly one window away from a cut are left unsnapped.

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

ROOT CAUSE

The snapping window is exclusive at its limit.

VERIFIED REPAIR

Snap when the distance is at most the window.

Unsuccessful approach: Snapping only forward misses cuts that occur just before the cue boundary.

Case contract

For each cue, the start snaps to the nearest shot change within window ms (|shot - start| <= window; ties go to the earlier shot). The end snaps so that it sits gap ms before the nearest shot change within window of end+gap. If snapping leaves end <= start, the original cue is kept unchanged.

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

N = 1
observations = []
def solve(cues, shots, window, gap):
    def near(t):
        best=None
        for sc in shots:
            d=abs(sc-t)
            if d<window and (best is None or d<abs(best-t)):
                best=sc
        return best
    out=[]
    for s0,e0 in cues:
        s,e=s0,e0
        a=near(s)
        if a is not None:
            s=a
        b=near(e+gap)
        if b is not None:
            e=b-gap
        if e<=s:
            s,e=s0,e0
        out.append([s,e])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: snap window', [[[900, 1500]], [1000], 100, 0], [[1000, 1500]]), ('regression variant: snap window', [[[1100, 2100], [2990, 3000], [900, 1800]], [1100, 3040], 200, 0], [[1100, 2100], [2990, 3000], [1100, 1800]]), ('partial repair probe: snap window', [[[2200, 2700]], [2150], 200, 80], [[2150, 2700]]), ('partial repair variant: snap window', [[[1050, 2150]], [1000, 4000], 200, 80], [[1000, 2150]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[1251, 1261], [0, 851]], [0, 1000, 3040], 250, 80], [[1251, 1261], [0, 920]]), ('normal control', [[[4201, 5101], [4201, 5201], [4201, 4701]], [4000], 200, 0], [[4201, 5101], [4201, 5201], [4201, 4701]]), ('normal control', [[[2950, 2980]], [1200, 2150, 3000], 250, 0], [[2950, 2980]])], [('regression: snap window', [[[850, 1890], [3000, 4000]], [1100, 3000], 250, 80], [[1100, 1890], [3000, 4000]]), ('regression variant: snap window', [[[1000, 2000], [3901, 4401]], [1100, 2000, 2150, 4000], 100, 42], [[1100, 1958], [4000, 4401]]), ('partial repair probe: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[899, 1999]], [1000], 100, 80], [[899, 1999]]), ('normal control', [[[1101, 1111], [950, 960], [950, 1850]], [1000, 4000], 100, 0], [[1101, 1111], [950, 960], [1000, 1850]]), ('normal control', [[[2799, 3839]], [1200, 3000], 200, 42], [[2799, 3839]])], [('regression: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('regression variant: snap window', [[[3040, 3070], [2790, 3890], [849, 859]], [1100, 3040], 250, 80], [[3040, 3070], [3040, 3890], [849, 1020]]), ('partial repair probe: snap window', [[[2950, 2980], [4050, 5150]], [2150, 3000, 4000], 250, 0], [[2950, 2980], [4000, 5150]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2990, 3020], [3040, 4140], [3040, 4040]], [0, 2000, 3040], 100, 42], [[2990, 3020], [3040, 4140], [3040, 4040]]), ('normal control', [[[2150, 2650], [2351, 2361]], [2150], 200, 0], [[2150, 2650], [2351, 2361]]), ('normal control', [[[1100, 1600], [3241, 4241]], [0, 1100, 2000, 3040, 4000], 200, 80], [[1100, 1600], [3241, 4241]])], [('regression: snap window', [[[750, 1650]], [1000, 1200, 2150, 3000], 250, 0], [[1000, 1650]]), ('regression variant: snap window', [[[3000, 3900], [900, 930], [3000, 3030]], [0, 1100, 1200, 3000], 200, 80], [[3000, 3900], [900, 930], [3000, 3030]]), ('partial repair probe: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('partial repair variant: snap window', [[[1050, 2150], [0, 1]], [0, 1000, 3000], 200, 0], [[1000, 2150], [0, 1]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3040]], [2000], 250, 0], [[2000, 3040]]), ('normal control', [[[2799, 3899]], [3000], 200, 0], [[2799, 3899]]), ('normal control', [[[4050, 4080], [3950, 4950]], [2000, 4000], 250, 42], [[4050, 4080], [4000, 4950]])], [('regression: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('regression variant: snap window', [[[750, 1850], [951, 1851], [950, 1850]], [1000, 1200], 250, 80], [[1000, 1850], [1000, 1851], [1000, 1850]]), ('partial repair probe: snap window', [[[50, 1150]], [0, 1200, 2000, 2150], 250, 80], [[0, 1120]]), ('partial repair variant: snap window', [[[4201, 5101], [1150, 1650], [2200, 3240]], [1100, 2000, 4000], 200, 0], [[4201, 5101], [1100, 1650], [2000, 3240]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3000]], [2000, 2150], 100, 0], [[2000, 3000]]), ('normal control', [[[3040, 3070], [2990, 3890]], [3040], 100, 80], [[3040, 3070], [3040, 3890]]), ('normal control', [[[2000, 2500], [1949, 2849]], [0, 2000, 2150], 200, 42], [[2000, 2500], [2000, 2849]])]]
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: snap window[[900, 1500]][[1000, 1500]]Failed
regression variant: snap window[[1100, 2100], [2990, 3000], [900, 1800]][[1100, 2100], [2990, 3000], [1100, 1800]]Failed
partial repair probe: snap window[[2150, 2700]][[2150, 2700]]Passed
partial repair variant: snap window[[1000, 2150]][[1000, 2150]]Passed
boundary control[[1200, 1800]][[1200, 1800]]Passed
normal control[[1251, 1261], [0, 920]][[1251, 1261], [0, 920]]Passed
normal control[[4201, 5101], [4201, 5201], [4201, 4701]][[4201, 5101], [4201, 5201], [4201, 4701]]Passed
normal control[[2950, 2980]][[2950, 2980]]Passed

SHA-256 / 83c96009a115471dc1fba69bc5006210e834675e21e464ad0a889e9ce17653fe

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(cues, shots, window, gap):
    def near(t):
        best=None
        for sc in shots:
            d=abs(sc-t)
            if 0<=sc-t<=window and (best is None or d<abs(best-t)):
                best=sc
        return best
    out=[]
    for s0,e0 in cues:
        s,e=s0,e0
        a=near(s)
        if a is not None:
            s=a
        b=near(e+gap)
        if b is not None:
            e=b-gap
        if e<=s:
            s,e=s0,e0
        out.append([s,e])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: snap window', [[[900, 1500]], [1000], 100, 0], [[1000, 1500]]), ('regression variant: snap window', [[[1100, 2100], [2990, 3000], [900, 1800]], [1100, 3040], 200, 0], [[1100, 2100], [2990, 3000], [1100, 1800]]), ('partial repair probe: snap window', [[[2200, 2700]], [2150], 200, 80], [[2150, 2700]]), ('partial repair variant: snap window', [[[1050, 2150]], [1000, 4000], 200, 80], [[1000, 2150]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[1251, 1261], [0, 851]], [0, 1000, 3040], 250, 80], [[1251, 1261], [0, 920]]), ('normal control', [[[4201, 5101], [4201, 5201], [4201, 4701]], [4000], 200, 0], [[4201, 5101], [4201, 5201], [4201, 4701]]), ('normal control', [[[2950, 2980]], [1200, 2150, 3000], 250, 0], [[2950, 2980]])], [('regression: snap window', [[[850, 1890], [3000, 4000]], [1100, 3000], 250, 80], [[1100, 1890], [3000, 4000]]), ('regression variant: snap window', [[[1000, 2000], [3901, 4401]], [1100, 2000, 2150, 4000], 100, 42], [[1100, 1958], [4000, 4401]]), ('partial repair probe: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[899, 1999]], [1000], 100, 80], [[899, 1999]]), ('normal control', [[[1101, 1111], [950, 960], [950, 1850]], [1000, 4000], 100, 0], [[1101, 1111], [950, 960], [1000, 1850]]), ('normal control', [[[2799, 3839]], [1200, 3000], 200, 42], [[2799, 3839]])], [('regression: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('regression variant: snap window', [[[3040, 3070], [2790, 3890], [849, 859]], [1100, 3040], 250, 80], [[3040, 3070], [3040, 3890], [849, 1020]]), ('partial repair probe: snap window', [[[2950, 2980], [4050, 5150]], [2150, 3000, 4000], 250, 0], [[2950, 2980], [4000, 5150]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2990, 3020], [3040, 4140], [3040, 4040]], [0, 2000, 3040], 100, 42], [[2990, 3020], [3040, 4140], [3040, 4040]]), ('normal control', [[[2150, 2650], [2351, 2361]], [2150], 200, 0], [[2150, 2650], [2351, 2361]]), ('normal control', [[[1100, 1600], [3241, 4241]], [0, 1100, 2000, 3040, 4000], 200, 80], [[1100, 1600], [3241, 4241]])], [('regression: snap window', [[[750, 1650]], [1000, 1200, 2150, 3000], 250, 0], [[1000, 1650]]), ('regression variant: snap window', [[[3000, 3900], [900, 930], [3000, 3030]], [0, 1100, 1200, 3000], 200, 80], [[3000, 3900], [900, 930], [3000, 3030]]), ('partial repair probe: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('partial repair variant: snap window', [[[1050, 2150], [0, 1]], [0, 1000, 3000], 200, 0], [[1000, 2150], [0, 1]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3040]], [2000], 250, 0], [[2000, 3040]]), ('normal control', [[[2799, 3899]], [3000], 200, 0], [[2799, 3899]]), ('normal control', [[[4050, 4080], [3950, 4950]], [2000, 4000], 250, 42], [[4050, 4080], [4000, 4950]])], [('regression: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('regression variant: snap window', [[[750, 1850], [951, 1851], [950, 1850]], [1000, 1200], 250, 80], [[1000, 1850], [1000, 1851], [1000, 1850]]), ('partial repair probe: snap window', [[[50, 1150]], [0, 1200, 2000, 2150], 250, 80], [[0, 1120]]), ('partial repair variant: snap window', [[[4201, 5101], [1150, 1650], [2200, 3240]], [1100, 2000, 4000], 200, 0], [[4201, 5101], [1100, 1650], [2000, 3240]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3000]], [2000, 2150], 100, 0], [[2000, 3000]]), ('normal control', [[[3040, 3070], [2990, 3890]], [3040], 100, 80], [[3040, 3070], [3040, 3890]]), ('normal control', [[[2000, 2500], [1949, 2849]], [0, 2000, 2150], 200, 42], [[2000, 2500], [2000, 2849]])]]
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: snap window[[1000, 1500]][[1000, 1500]]Passed
regression variant: snap window[[1100, 2100], [2990, 3000], [1100, 1800]][[1100, 2100], [2990, 3000], [1100, 1800]]Passed
partial repair probe: snap window[[2200, 2700]][[2150, 2700]]Failed
partial repair variant: snap window[[1050, 2150]][[1000, 2150]]Failed
boundary control[[1200, 1800]][[1200, 1800]]Passed
normal control[[1251, 1261], [0, 920]][[1251, 1261], [0, 920]]Passed
normal control[[4201, 5101], [4201, 5201], [4201, 4701]][[4201, 5101], [4201, 5201], [4201, 4701]]Passed
normal control[[2950, 2980]][[2950, 2980]]Passed

SHA-256 / ee0600e69d4215c4bb615a6905d248798a05936f3f6cdc750f7bc0b8e0ba5094

3 / The verified repair

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

N = 1
observations = []
def solve(cues, shots, window, gap):
    def near(t):
        best=None
        for sc in shots:
            d=abs(sc-t)
            if d<=window and (best is None or d<abs(best-t)):
                best=sc
        return best
    out=[]
    for s0,e0 in cues:
        s,e=s0,e0
        a=near(s)
        if a is not None:
            s=a
        b=near(e+gap)
        if b is not None:
            e=b-gap
        if e<=s:
            s,e=s0,e0
        out.append([s,e])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: snap window', [[[900, 1500]], [1000], 100, 0], [[1000, 1500]]), ('regression variant: snap window', [[[1100, 2100], [2990, 3000], [900, 1800]], [1100, 3040], 200, 0], [[1100, 2100], [2990, 3000], [1100, 1800]]), ('partial repair probe: snap window', [[[2200, 2700]], [2150], 200, 80], [[2150, 2700]]), ('partial repair variant: snap window', [[[1050, 2150]], [1000, 4000], 200, 80], [[1000, 2150]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[1251, 1261], [0, 851]], [0, 1000, 3040], 250, 80], [[1251, 1261], [0, 920]]), ('normal control', [[[4201, 5101], [4201, 5201], [4201, 4701]], [4000], 200, 0], [[4201, 5101], [4201, 5201], [4201, 4701]]), ('normal control', [[[2950, 2980]], [1200, 2150, 3000], 250, 0], [[2950, 2980]])], [('regression: snap window', [[[850, 1890], [3000, 4000]], [1100, 3000], 250, 80], [[1100, 1890], [3000, 4000]]), ('regression variant: snap window', [[[1000, 2000], [3901, 4401]], [1100, 2000, 2150, 4000], 100, 42], [[1100, 1958], [4000, 4401]]), ('partial repair probe: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[899, 1999]], [1000], 100, 80], [[899, 1999]]), ('normal control', [[[1101, 1111], [950, 960], [950, 1850]], [1000, 4000], 100, 0], [[1101, 1111], [950, 960], [1000, 1850]]), ('normal control', [[[2799, 3839]], [1200, 3000], 200, 42], [[2799, 3839]])], [('regression: snap window', [[[1200, 1230], [801, 1301], [1050, 1550]], [1000, 2150], 200, 0], [[1000, 1230], [1000, 1301], [1000, 1550]]), ('regression variant: snap window', [[[3040, 3070], [2790, 3890], [849, 859]], [1100, 3040], 250, 80], [[3040, 3070], [3040, 3890], [849, 1020]]), ('partial repair probe: snap window', [[[2950, 2980], [4050, 5150]], [2150, 3000, 4000], 250, 0], [[2950, 2980], [4000, 5150]]), ('partial repair variant: snap window', [[[50, 950]], [0, 1200], 250, 42], [[0, 1158]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2990, 3020], [3040, 4140], [3040, 4040]], [0, 2000, 3040], 100, 42], [[2990, 3020], [3040, 4140], [3040, 4040]]), ('normal control', [[[2150, 2650], [2351, 2361]], [2150], 200, 0], [[2150, 2650], [2351, 2361]]), ('normal control', [[[1100, 1600], [3241, 4241]], [0, 1100, 2000, 3040, 4000], 200, 80], [[1100, 1600], [3241, 4241]])], [('regression: snap window', [[[750, 1650]], [1000, 1200, 2150, 3000], 250, 0], [[1000, 1650]]), ('regression variant: snap window', [[[3000, 3900], [900, 930], [3000, 3030]], [0, 1100, 1200, 3000], 200, 80], [[3000, 3900], [900, 930], [3000, 3030]]), ('partial repair probe: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('partial repair variant: snap window', [[[1050, 2150], [0, 1]], [0, 1000, 3000], 200, 0], [[1000, 2150], [0, 1]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3040]], [2000], 250, 0], [[2000, 3040]]), ('normal control', [[[2799, 3899]], [3000], 200, 0], [[2799, 3899]]), ('normal control', [[[4050, 4080], [3950, 4950]], [2000, 4000], 250, 42], [[4050, 4080], [4000, 4950]])], [('regression: snap window', [[[3900, 3910], [101, 1201], [4050, 4060]], [0, 2150, 3040, 4000], 100, 80], [[3900, 3910], [101, 1201], [4000, 4060]]), ('regression variant: snap window', [[[750, 1850], [951, 1851], [950, 1850]], [1000, 1200], 250, 80], [[1000, 1850], [1000, 1851], [1000, 1850]]), ('partial repair probe: snap window', [[[50, 1150]], [0, 1200, 2000, 2150], 250, 80], [[0, 1120]]), ('partial repair variant: snap window', [[[4201, 5101], [1150, 1650], [2200, 3240]], [1100, 2000, 4000], 200, 0], [[4201, 5101], [1100, 1650], [2000, 3240]]), ('boundary control', [[[1150, 1800]], [1000, 1200, 2000], 100, 80], [[1200, 1800]]), ('normal control', [[[2000, 3000]], [2000, 2150], 100, 0], [[2000, 3000]]), ('normal control', [[[3040, 3070], [2990, 3890]], [3040], 100, 80], [[3040, 3070], [3040, 3890]]), ('normal control', [[[2000, 2500], [1949, 2849]], [0, 2000, 2150], 200, 42], [[2000, 2500], [2000, 2849]])]]
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: snap window[[1000, 1500]][[1000, 1500]]Passed
regression variant: snap window[[1100, 2100], [2990, 3000], [1100, 1800]][[1100, 2100], [2990, 3000], [1100, 1800]]Passed
partial repair probe: snap window[[2150, 2700]][[2150, 2700]]Passed
partial repair variant: snap window[[1000, 2150]][[1000, 2150]]Passed
boundary control[[1200, 1800]][[1200, 1800]]Passed
normal control[[1251, 1261], [0, 920]][[1251, 1261], [0, 920]]Passed
normal control[[4201, 5101], [4201, 5201], [4201, 4701]][[4201, 5101], [4201, 5201], [4201, 4701]]Passed
normal control[[2950, 2980]][[2950, 2980]]Passed

SHA-256 / 92f3206ac25fc234455b758a0f545ac7667779d8bcfe5a2c0acf394589f81f97

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

Case digest / 7c288206c45cb5b1e6a71e035359072e324baf8fe518c96b735da4fb7d1325af