Skip to content

Fix video offset with "Keep existing time codes" modifying the file (#11637)#11639

Merged
niksedk merged 1 commit into
mainfrom
fix/video-offset-keep-time-codes
Jun 15, 2026
Merged

Fix video offset with "Keep existing time codes" modifying the file (#11637)#11639
niksedk merged 1 commit into
mainfrom
fix/video-offset-keep-time-codes

Conversation

@niksedk

@niksedk niksedk commented Jun 15, 2026

Copy link
Copy Markdown
Member

Fixes #11637

Problem

Using Set video offset with Keep existing time codes modified the subtitle's time codes instead of leaving them alone:

  1. The time codes were altered and the file was marked as changed.
  2. Saving wrote the offset into the file.
  3. Reopening double-applied the offset (e.g. a file starting at 01:00:00:00 reopened at 02:00:00:00 when unsaved, or 00:00:00:00 when saved).

Cause

In the new Avalonia UI the video offset is a non-destructive display offsetTimeSpanToDisplayFullConverter renders time code + offset while the stored time codes stay untouched. The handler in MainViewModel.ShowVideoSetOffset had the logic inverted: checking Keep existing time codes was the branch that subtracted the offset from the paragraphs (and only StartTime, corrupting durations) and dirtied the file.

This is backwards from the legacy Main.cs, where DoNotaddVideoOffsetToTimeCodes (the checked state) is the path that resets the change-hash so the file is not marked dirty.

Fix

  • Checked → leave the time codes alone; only set the display offset. File is not modified and there is no double-apply on reopen.
  • Unchecked → bake the offset delta (new − old) into both StartTime and EndTime, so the displayed values stay put while the underlying codes change (and the file is correctly marked as modified). Using the delta makes re-running the dialog with an existing offset correct.
  • Cast the rounded offset to long to match the long CurrentVideoOffsetInMs field.

🤖 Generated with Claude Code

…11637)

The video offset is a non-destructive display offset (TimeSpanToDisplayFullConverter
shows "time code + offset" while the stored time codes stay untouched). The
"Keep existing time codes" handling was inverted: checking the box mutated the
paragraphs (and only StartTime, corrupting durations), marked the file dirty,
and double-applied the offset on reopen.

Match the legacy semantics where the checkbox is the non-destructive path:
- checked: leave the time codes alone, only set the display offset
- unchecked: bake the offset delta into both StartTime and EndTime so the
  displayed values stay put while the underlying codes change (marks dirty)

Use the offset delta (new - old) so re-running the dialog with an existing
offset is correct. Also cast to long to match CurrentVideoOffsetInMs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 19ac6bf into main Jun 15, 2026
2 of 3 checks passed
@niksedk niksedk deleted the fix/video-offset-keep-time-codes branch June 15, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Offset with Keep existing time codes not working as intended

1 participant