Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add position data to captions #434

Merged
merged 7 commits into from
Jul 21, 2023

Conversation

wseymour15
Copy link
Contributor

@wseymour15 wseymour15 commented Jul 11, 2023

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 wseymour15 marked this pull request as ready for review July 17, 2023 21:16
@@ -35,7 +35,7 @@ var CoalesceStream = function(options) {
this.push = function(output) {
// buffer incoming captions until the associated video segment
// finishes
if (output.text) {
if (output.content || output.text) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe other types of captions (708) could still use text as of now, so both content and text are included.

Copy link
Contributor

@adrums86 adrums86 Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

Copy link
Contributor

@adrums86 adrums86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions about applying the offset and indent to this.displayed_. Also have we tried this with 708? Curious if we get the positioning there as well, I can dig up some media or maybe we can create a unit test to try it out. Overall this looks great though, nice work!

@@ -35,7 +35,7 @@ var CoalesceStream = function(options) {
this.push = function(output) {
// buffer incoming captions until the associated video segment
// finishes
if (output.text) {
if (output.content || output.text) {
Copy link
Contributor

@adrums86 adrums86 Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to exclude lock changes from this PR.

@@ -1231,10 +1233,12 @@ var ROWS = [0x1100, 0x1120, 0x1200, 0x1220, 0x1500, 0x1520, 0x1600, 0x1620,

// CEA-608 captions are rendered onto a 34x15 matrix of character
// cells. The "bottom" row is the last element in the outer array.
// We keep track of positioning infomration as we go by storing the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment spelling

Suggested change
// We keep track of positioning infomration as we go by storing the
// We keep track of positioning information as we go by storing the


this.column_ = indentations * 4;
// add to the number of indentations for positioning
this.nonDisplayed_[this.row_].indent += indentations;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add the indent to the this.displayed_ buffer here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, and I don't believe so. I think the this.nonDisplayed_ buffer is basically where the caption data is manipulated until the end of a caption. At that instance, we swap everything over to this.displayed_.


// For an offest value 1-3, set the offset for that caption
// in the non-displayed array.
this.nonDisplayed_[this.row_].offset = offset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add the offset to the this.displayed_ buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@adrums86 adrums86 added the major label Jul 19, 2023
@wseymour15
Copy link
Contributor Author

wseymour15 commented Jul 19, 2023

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.

Copy link
Contributor

@adrums86 adrums86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@wseymour15 wseymour15 merged commit 30f2132 into main Jul 21, 2023
5 checks passed
@wseymour15 wseymour15 deleted the feat/add-position-data-to-captions branch July 21, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants