diff --git a/src/ui/Features/Main/MainViewModel.cs b/src/ui/Features/Main/MainViewModel.cs index a49e5a08883..fa49d4b160c 100644 --- a/src/ui/Features/Main/MainViewModel.cs +++ b/src/ui/Features/Main/MainViewModel.cs @@ -6087,6 +6087,8 @@ private async Task ShowVideoSetOffset() return; } + var oldOffsetMs = Se.Settings.General.CurrentVideoOffsetInMs; + var result = await ShowDialogAsync(); if (result.ResetPressed) @@ -6111,14 +6113,23 @@ private async Task ShowVideoSetOffset() offset = offset - TimeSpan.FromSeconds(vp.Position); } - Se.Settings.General.CurrentVideoOffsetInMs = (int)Math.Round(offset.TotalMilliseconds, MidpointRounding.AwayFromZero); + Se.Settings.General.CurrentVideoOffsetInMs = (long)Math.Round(offset.TotalMilliseconds, MidpointRounding.AwayFromZero); } - if (result.KeepTimeCodes) + // The video offset is a non-destructive display offset (see TimeSpanToDisplayFullConverter): + // the listview shows "time code + offset" while the underlying time codes stay untouched. + // "Keep existing time codes" therefore leaves the time codes alone. When it is NOT checked, + // we bake the offset change into the time codes so the displayed values stay the same. + if (!result.KeepTimeCodes) { - foreach (var s in Subtitles) + var delta = TimeSpan.FromMilliseconds(Se.Settings.General.CurrentVideoOffsetInMs - oldOffsetMs); + if (delta != TimeSpan.Zero) { - s.StartTime = s.StartTime - offset; + foreach (var s in Subtitles) + { + s.StartTime -= delta; + s.EndTime -= delta; + } } } diff --git a/src/ui/Features/Shared/SetVideoOffset/SetVideoOffsetViewModel.cs b/src/ui/Features/Shared/SetVideoOffset/SetVideoOffsetViewModel.cs index 0c834307f87..86171353901 100644 --- a/src/ui/Features/Shared/SetVideoOffset/SetVideoOffsetViewModel.cs +++ b/src/ui/Features/Shared/SetVideoOffset/SetVideoOffsetViewModel.cs @@ -42,7 +42,7 @@ private void Ok() return; } - Se.Settings.General.CurrentVideoOffsetInMs = (int)Math.Round(TimeOffset.Value.TotalMilliseconds, MidpointRounding.AwayFromZero); + Se.Settings.General.CurrentVideoOffsetInMs = (long)Math.Round(TimeOffset.Value.TotalMilliseconds, MidpointRounding.AwayFromZero); OkPressed = true; Window?.Close(); }