[{"data":1,"prerenderedAt":534},["ShallowReactive",2],{"blog-\u002Ffield-notes\u002Fwhy-29-97-subtitle-sync-drifts":3},{"id":4,"title":5,"author":6,"body":7,"date":521,"description":522,"extension":523,"meta":524,"navigation":255,"path":525,"seo":526,"stem":527,"tags":528,"__hash__":533},"content\u002Ffield-notes\u002Fwhy-29-97-subtitle-sync-drifts.md","Why Your 29.97 Subtitle Sync Drifts (And How to Fix It)","timecodes team",{"type":8,"value":9,"toc":511},"minimark",[10,14,17,22,25,28,31,42,49,53,56,59,62,68,71,74,80,83,87,90,96,99,105,112,115,121,124,128,131,142,145,157,161,164,167,189,207,422,425,429,432,446,455,459,462,489,497,501,504,507],[11,12,13],"p",{},"You have a two-hour program at 29.97fps. You load the subtitles into your player. The first few cues are fine. By the midpoint, things look slightly off. By the last act, subtitles are arriving a visible beat late — or early. You did not touch the timing. The file validated clean. What happened?",[11,15,16],{},"The answer is baked into the number 29.97 itself.",[18,19,21],"h2",{"id":20},"_2997-is-not-2997","29.97 Is Not 29.97",[11,23,24],{},"When NTSC color television was standardized in 1953, the framerate was shifted from exactly 30 frames per second to 30000\u002F1001 frames per second. This works out to approximately 29.97002997... fps — an infinitely repeating decimal.",[11,26,27],{},"This is not a rounding convention. The exact framerate is the fraction 30000\u002F1001. Every tool that handles NTSC content must use this fraction, not the approximation 29.97.",[11,29,30],{},"One frame at 30000\u002F1001 fps lasts exactly:",[32,33,38],"pre",{"className":34,"code":36,"language":37},[35],"language-text","1001 \u002F 30000 = 0.033366666... seconds = 33.366666... milliseconds\n","text",[39,40,36],"code",{"__ignoreMap":41},"",[11,43,44,45,48],{},"That trailing ",[39,46,47],{},"666..."," is the source of every sync problem in millisecond-based subtitle tools.",[18,50,52],{"id":51},"the-millisecond-truncation-problem","The Millisecond Truncation Problem",[11,54,55],{},"SRT, VTT, and SBV all store timestamps with millisecond precision — three decimal places of seconds. This means every timestamp is rounded to the nearest millisecond.",[11,57,58],{},"One frame at 29.97fps is 33.3667ms. Stored as an SRT timestamp, it becomes either 33ms or 34ms. Neither is correct. The error on a single frame is small — about 0.367ms or 0.633ms. But this error is not random. It is systematic, and it accumulates.",[11,60,61],{},"Here is the math for a two-hour program:",[32,63,66],{"className":64,"code":65,"language":37},[35],"Total frames in 2 hours at 29.97fps:\n  2 * 3600 * 30000\u002F1001 = 215,784.216 frames\n  (rounded: 215,784 frames)\n\nExact duration of 215,784 frames:\n  215,784 * 1001\u002F30000 = 7,199.993... seconds\n\nDuration as stored in ms-based format:\n  Each frame boundary rounded to nearest ms\n  Cumulative rounding over 215,784 frames\n",[39,67,65],{"__ignoreMap":41},[11,69,70],{},"In practice, because rounding errors partially cancel over successive frames, accumulated millisecond rounding over a two-hour program routinely produces drift of 2-4 frames — enough to be visible to viewers and enough to fail broadcast QC.",[11,72,73],{},"The theoretical worst case illustrates why. If the rounding error averaged 0.3ms per frame boundary (because 33.367ms truncates to 33ms more often than it rounds to 34ms), then over 215,784 frames:",[32,75,78],{"className":76,"code":77,"language":37},[35],"Theoretical worst-case drift = 0.3ms * 215,784 \u002F 1000 = ~64.7 seconds\n",[39,79,77],{"__ignoreMap":41},[11,81,82],{},"Real files never hit this bound because rounding errors alternate direction, but the arithmetic shows how much error budget exists in the system. Even a small fraction of this worst case is enough to push subtitles out of sync.",[18,84,86],{"id":85},"a-concrete-example","A Concrete Example",[11,88,89],{},"Consider frame 150,000 in a 29.97fps timeline. Its exact time position:",[32,91,94],{"className":92,"code":93,"language":37},[35],"150,000 * 1001 \u002F 30000 = 5,005.000 seconds exactly\n",[39,95,93],{"__ignoreMap":41},[11,97,98],{},"That one happens to land cleanly. Now consider frame 150,001:",[32,100,103],{"className":101,"code":102,"language":37},[35],"150,001 * 1001 \u002F 30000 = 5,005.033366... seconds\n                       = 5,005 seconds, 33.367ms\n",[39,104,102],{"__ignoreMap":41},[11,106,107,108,111],{},"Stored in SRT: ",[39,109,110],{},"01:23:25,033"," (truncated). The real position is 33.367ms into that second. The stored position is 33.000ms. That is a 0.367ms error on this single cue.",[11,113,114],{},"Now consider what happens when a tool reads that SRT timestamp back and tries to determine what frame it belongs to:",[32,116,119],{"className":117,"code":118,"language":37},[35],"5005.033 seconds * 30000\u002F1001 = 150,000.989...\nFloor → frame 150,000\n",[39,120,118],{"__ignoreMap":41},[11,122,123],{},"The round-trip lost one frame. Frame 150,001 was written to SRT and read back as frame 150,000. This is not a bug in the tool — it is an inherent limitation of millisecond storage for non-integer framerates.",[18,125,127],{"id":126},"drop-frame-timecode-a-related-but-different-problem","Drop-Frame Timecode: A Related But Different Problem",[11,129,130],{},"Drop-frame timecode is often confused with this drift issue, but it solves a different problem.",[11,132,133,134,137,138,141],{},"At exactly 30fps, timecode ",[39,135,136],{},"01:00:00:00"," corresponds to wall-clock time 1:00:00.000 — exactly one hour. At 29.97fps, after one hour of wall-clock time, only 107,892 frames have elapsed, but a non-drop timecode counter would read ",[39,139,140],{},"00:59:56:12",". The timecode is \"slow\" by 3.6 seconds per hour relative to the wall clock.",[11,143,144],{},"Drop-frame timecode compensates by skipping frame numbers 0 and 1 at the start of each minute, except every tenth minute. This makes the timecode display approximate wall-clock time (within ~2 frames per day).",[11,146,147,148,152,153,156],{},"Drop-frame solves the ",[149,150,151],"strong",{},"display"," problem — making timecode readouts match wall clocks and program durations. It does not solve the ",[149,154,155],{},"computation"," problem of millisecond rounding. A drop-frame timecode is still a label for a frame number, and converting that label to milliseconds still introduces the same truncation error.",[18,158,160],{"id":159},"the-solution-frame-number-canonical-computation","The Solution: Frame-Number-Canonical Computation",[11,162,163],{},"The fix is architectural, not algorithmic. Stop treating milliseconds as a source of truth.",[11,165,166],{},"The correct pipeline:",[168,169,170,177,183],"ol",{},[171,172,173,176],"li",{},[149,174,175],{},"Ingest",": Parse the timestamp (milliseconds, timecode, whatever). Immediately convert to a frame number at the known framerate, using the exact fraction (30000\u002F1001, not 29.97).",[171,178,179,182],{},[149,180,181],{},"Compute",": All operations — shifting, scaling, splitting, merging — happen in integer frame space. No floating point. No rounding.",[171,184,185,188],{},[149,186,187],{},"Export",": Convert frame numbers back to the target format's timestamp representation. If the target is SRT, derive milliseconds from the frame number. If the target is SCC, derive SMPTE timecode.",[11,190,191,192,195,196,198,199,202,203,206],{},"This is what the timecodes engine does internally. The ",[39,193,194],{},"Timecode"," class stores a frame number as its canonical value. When you construct a ",[39,197,194],{}," from milliseconds, it immediately resolves to a frame number using the exact framerate fraction. When you read ",[39,200,201],{},".milliseconds"," or ",[39,204,205],{},".timecode"," back out, those values are derived from the frame number — not stored independently.",[32,208,212],{"className":209,"code":210,"language":211,"meta":41,"style":41},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { Timecode } from 'timecodes';\n\n\u002F\u002F Construct from milliseconds — internally resolves to frame number\nconst tc = new Timecode({\n    inputValue: 5005033,\n    valueType: 'milliseconds',\n    framerate: '29.97'\n});\n\nconsole.log(tc.frameNumber); \u002F\u002F Exact frame number\nconsole.log(tc.timecode); \u002F\u002F Derived from frame number\nconsole.log(tc.milliseconds); \u002F\u002F Derived from frame number\n","typescript",[39,213,214,250,257,264,289,306,323,339,350,355,381,402],{"__ignoreMap":41},[215,216,219,223,227,231,234,237,240,244,247],"span",{"class":217,"line":218},"line",1,[215,220,222],{"class":221},"s7zQu","import",[215,224,226],{"class":225},"sMK4o"," {",[215,228,230],{"class":229},"sTEyZ"," Timecode",[215,232,233],{"class":225}," }",[215,235,236],{"class":221}," from",[215,238,239],{"class":225}," '",[215,241,243],{"class":242},"sfazB","timecodes",[215,245,246],{"class":225},"'",[215,248,249],{"class":225},";\n",[215,251,253],{"class":217,"line":252},2,[215,254,256],{"emptyLinePlaceholder":255},true,"\n",[215,258,260],{"class":217,"line":259},3,[215,261,263],{"class":262},"sHwdD","\u002F\u002F Construct from milliseconds — internally resolves to frame number\n",[215,265,267,271,274,277,280,283,286],{"class":217,"line":266},4,[215,268,270],{"class":269},"spNyl","const",[215,272,273],{"class":229}," tc ",[215,275,276],{"class":225},"=",[215,278,279],{"class":225}," new",[215,281,230],{"class":282},"s2Zo4",[215,284,285],{"class":229},"(",[215,287,288],{"class":225},"{\n",[215,290,292,296,299,303],{"class":217,"line":291},5,[215,293,295],{"class":294},"swJcz","    inputValue",[215,297,298],{"class":225},":",[215,300,302],{"class":301},"sbssI"," 5005033",[215,304,305],{"class":225},",\n",[215,307,309,312,314,316,319,321],{"class":217,"line":308},6,[215,310,311],{"class":294},"    valueType",[215,313,298],{"class":225},[215,315,239],{"class":225},[215,317,318],{"class":242},"milliseconds",[215,320,246],{"class":225},[215,322,305],{"class":225},[215,324,326,329,331,333,336],{"class":217,"line":325},7,[215,327,328],{"class":294},"    framerate",[215,330,298],{"class":225},[215,332,239],{"class":225},[215,334,335],{"class":242},"29.97",[215,337,338],{"class":225},"'\n",[215,340,342,345,348],{"class":217,"line":341},8,[215,343,344],{"class":225},"}",[215,346,347],{"class":229},")",[215,349,249],{"class":225},[215,351,353],{"class":217,"line":352},9,[215,354,256],{"emptyLinePlaceholder":255},[215,356,358,361,364,367,370,372,375,378],{"class":217,"line":357},10,[215,359,360],{"class":229},"console",[215,362,363],{"class":225},".",[215,365,366],{"class":282},"log",[215,368,369],{"class":229},"(tc",[215,371,363],{"class":225},[215,373,374],{"class":229},"frameNumber)",[215,376,377],{"class":225},";",[215,379,380],{"class":262}," \u002F\u002F Exact frame number\n",[215,382,384,386,388,390,392,394,397,399],{"class":217,"line":383},11,[215,385,360],{"class":229},[215,387,363],{"class":225},[215,389,366],{"class":282},[215,391,369],{"class":229},[215,393,363],{"class":225},[215,395,396],{"class":229},"timecode)",[215,398,377],{"class":225},[215,400,401],{"class":262}," \u002F\u002F Derived from frame number\n",[215,403,405,407,409,411,413,415,418,420],{"class":217,"line":404},12,[215,406,360],{"class":229},[215,408,363],{"class":225},[215,410,366],{"class":282},[215,412,369],{"class":229},[215,414,363],{"class":225},[215,416,417],{"class":229},"milliseconds)",[215,419,377],{"class":225},[215,421,401],{"class":262},[11,423,424],{},"Because the frame number is an integer, there is no accumulation. Frame 150,001 is always frame 150,001, regardless of how many conversions it passes through.",[18,426,428],{"id":427},"how-to-detect-drift-in-your-subtitles","How to Detect Drift in Your Subtitles",[11,430,431],{},"If you suspect your existing subtitle files have drifted, here is a practical check:",[168,433,434,437,440,443],{},[171,435,436],{},"Determine the exact frame count of your program. Your NLE or media info tool will report this.",[171,438,439],{},"Convert that frame count to a timecode at 29.97fps (drop-frame if applicable).",[171,441,442],{},"Look at the last subtitle's out-cue timestamp in your SRT\u002FVTT file.",[171,444,445],{},"Compare. If the last subtitle's out-cue is more than one frame's duration (33ms) away from where it should be relative to the program duration, you have accumulated drift.",[11,447,448,449,454],{},"You can test this directly in the ",[450,451,453],"a",{"href":452},"\u002Ftools\u002Fplayground","playground",", which lets you convert between frame numbers, timecodes, and milliseconds at any framerate and see the exact values.",[18,456,458],{"id":457},"preventing-drift-in-your-workflow","Preventing Drift in Your Workflow",[11,460,461],{},"The rules are straightforward:",[463,464,465,471,477,483],"ul",{},[171,466,467,470],{},[149,468,469],{},"Never store milliseconds as a source of truth."," If your subtitle database or project file stores timing as milliseconds, you have a drift vector. Store frame numbers and framerate instead.",[171,472,473,476],{},[149,474,475],{},"Never multiply milliseconds by a ratio to change framerates."," Converting 29.97fps subtitles to 25fps requires going through frame numbers, not multiplying timestamps by 25\u002F29.97.",[171,478,479,482],{},[149,480,481],{},"Always know your framerate."," A millisecond value without framerate context is ambiguous. The same millisecond value maps to different frame numbers at different framerates.",[171,484,485,488],{},[149,486,487],{},"Validate after every conversion."," When you export from your subtitle tool, check the last cue against the known program duration.",[11,490,491,492,496],{},"These are not suggestions — they are requirements for frame-accurate work. The ",[450,493,495],{"href":494},"\u002Ftransform","subtitle tool"," enforces framerate context on every operation precisely because a subtitle file without a framerate is an incomplete document.",[18,498,500],{"id":499},"the-takeaway","The Takeaway",[11,502,503],{},"29.97fps drift is not a mystery bug. It is a predictable, mathematical consequence of storing non-terminating repeating decimal frame durations in a fixed-precision decimal format. The solution has been known in broadcast engineering for decades: work in frame numbers, not milliseconds. Every tool in the chain needs to respect this, from ingest through delivery.",[11,505,506],{},"If your subtitles drift, the problem is not your content. The problem is your tools.",[508,509,510],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":41,"searchDepth":252,"depth":252,"links":512},[513,514,515,516,517,518,519,520],{"id":20,"depth":252,"text":21},{"id":51,"depth":252,"text":52},{"id":85,"depth":252,"text":86},{"id":126,"depth":252,"text":127},{"id":159,"depth":252,"text":160},{"id":427,"depth":252,"text":428},{"id":457,"depth":252,"text":458},{"id":499,"depth":252,"text":500},"2026-03-10","The math behind 29.97fps subtitle drift, why millisecond-based tools lose sync over long programs, and how frame-number-canonical computation eliminates the problem.","md",{},"\u002Ffield-notes\u002Fwhy-29-97-subtitle-sync-drifts",{"title":5,"description":522},"field-notes\u002Fwhy-29-97-subtitle-sync-drifts",[529,530,531,532],"timecode","drop-frame","sync","framerate","mvPWnzDCmuwSggxTsvNP9fHy88ck74u5z0yjVGdGpg8",1794869447016]