Fix SCC captions out of order when short text followed by longer text#363
Draft
Fix SCC captions out of order when short text followed by longer text#363
Conversation
In PASS 2 of SCCWriter.write(), buffer time calculations could push a longer caption's adjusted start time before the previous shorter caption's start time. Two fixes applied: 1. Also adjust the first caption's start time for buffering (was skipped due to early `continue`) 2. Clamp each caption's adjusted start time to be at least as late as the previous caption's adjusted start time Co-authored-by: lorandvarga <7048551+lorandvarga@users.noreply.github.com>
…omment Co-authored-by: lorandvarga <7048551+lorandvarga@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SCC captions output order issue
Fix SCC captions out of order when short text followed by longer text
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SCCWriterPASS 2 buffer time calculations push each caption's start time back proportional to its code length. When a short caption is followed by a longer one with close start times, the longer caption's adjusted start can precede the shorter caption's — producing out-of-order SCC timestamps.Changes
if index == 0: continueskipped both the previous-caption comparison (correct) and thecodes[index]update (bug). Restructured to always apply the buffer offset.code_start, clamp it tomax(code_start, previous_start)so timestamps never go backwards.Test
Added
test_scc_captions_are_in_order_when_short_text_followed_by_longreproducing the exact scenario from the issue.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.