videojs / mux.js

Lightweight utilities for inspecting and manipulating video container formats.
Apache License 2.0
1.11k stars 210 forks source link

feat: add position data to captions #434

Closed wseymour15 closed 1 year ago

wseymour15 commented 1 year ago

NOTE: This will require a major version update, as this changes how the caption data is sent to VHS. This was necessary, as we were previously combining text that can have different positioning data on these messages. This will require changes in VHS and video.js once this is released.

Previously for CEA-608 captions, we were completely ignoring positioning data and just centering all captions at the bottom of the screen. This change allows us to take advantage of our parsing and including this positioning data. The 'line' field represents the row on which to display the text from 1-15, and the position field represents where the caption should be displayed horizontally on a scale from 1-100 (although the spec states we should lock it between 10-80). See: https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608

Testing instructions will be included once I have a PR out with the VHS changes to consume this change.

wseymour15 commented 1 year ago

Also have we tried this with 708?

@adrums86 Great question! As of now, these changes will not affect the position of 708 captions. I do however think we could add this logic to the flushDisplayed function of the 708 captions following the spec. It looks like we have some of the backbones for determining things like priority and window anchor that the spec needs, so this is definitely doable.

I will add tickets on the Brightcove side to address this work. EDIT: After investigating into how 708 caption positioning would work, according to the spec, these captions depend heavily on the VTTRegion Interface. However, it looks like this interface is not supported by most browsers. If we decide to account for 708 positioning, we would have to most likely go against the spec, so we will discuss further if this is a change we intend to accomplish.