fix(subtitles): Correction for subtitle shifts when transcoding #7414
+44
−1
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.



Fixed #7413 submitted by me
Cause
The problem was that the native video player did not follow the changes made to the initial PTS while playing an HLS stream. This caused a desync in the original subtitle timings and the HLS library's current time and the subtitles were display a few seconds off. This usually only happened while playing transcoded content after a seek was made.
Changes
Hooked up a listener to the INIT_PTS_FOUND event of the HLS library, that fires, when the initial PTS value changes. I keep track of the shift overtime and apply a correctional offset to the start and end times of the current text track's cues each time. Now when loading a new text track, it auto-adjusts the start times for the cues. This implementation does not interfere with the existing manual subtitle shifting mechanism.
Note
I attempted a fix for my current instance, while testing in multiple browsers, tho I'm not sure if I covered all possible scenarios for on-client subtitle displaying. Further testing might be needed.
Issues
#7413