Fix WebVTT cue setting preservation#12340
Open
pdjdev wants to merge 1 commit into
Open
Conversation
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.
Problem
WebVTT cue settings could be silently lost or changed after loading and saving a file in Subtitle Edit.
In particular, commonly used settings such as
align:leftwere not preserved. Cue positions that did not exactly correspond to Subtitle Edit's configured ASS alignment presets were inferred from broad coordinate ranges and converted to a nearby{\an1}–{\an9}tag.For example, saving this file again via
Save As...without any changes:could produce:
This both removes
align:leftand changes the author's intended position.Cause & Fix
The previous
GetPositionInfo()logic converted arbitrarypositionandlinevalues to ASS alignment tags based on coordinate ranges. This is a lossy conversion because WebVTT cue positioning is more expressive than the nine discrete ASS alignment positions.This PR replaces that inference with
GetAssAlignmentTagFromCueSettings().{\an1}–{\an9}only when the extracted cue settings exactly match one of the configuredSubtitleSettings.WebVttCueAn1–WebVttCueAn9values.WebVttCueAn*value overrides existing cue settings during WebVTT export.vttcparsing.WebVTT.GetPositionInfo()method.For example, when an editor adds
{\an7}to a cue:and
SubtitleSettings.WebVttCueAn7is configured as:the exported WebVTT cue uses that configured placement:
Test
Added regression coverage for:
align:left;Tested on Windows 11 x64 with a local Release build.
WebVttTest: 14/14 passed.Note
WebVTT and ASS/SSA have different styling and positioning models, so mapping between them has inherent limitations. A dedicated styling system and editor UI for WebVTT could be a useful future improvement.