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

fix: ensure vtt tracks language is set correctly #181

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

wseymour15
Copy link
Contributor

@wseymour15 wseymour15 commented Oct 8, 2024

Description

In DASH, the language property we set on VTT tracks should be accurate. As of now, this value is the label when it exists, THEN the language.

This change sets the language to the lang property if it exists, then the label, and then en by default.

src/toM3u8.js Outdated
@@ -246,10 +246,11 @@ export const organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly
export const organizeVttPlaylists = (playlists, sidxMapping = {}) => {
return playlists.reduce((a, playlist) => {
const label = playlist.attributes.label || playlist.attributes.lang || 'text';
const language = playlist.attributes.lang || playlist.attributes.label || 'en';
Copy link
Member

Choose a reason for hiding this comment

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

It's more correct to default to und rather than en because we don't want to mark something as en when it isn't.

From dash spec 5.3.3.2 and IETF RFC 5646 section 4.1 step 5 https://datatracker.ietf.org/doc/html/rfc5646#section-4.1

Copy link
Member

Choose a reason for hiding this comment

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

Actually, should we even bother trying to set it to label? We're more likely to have a language set than a label based on mpd files I've seen. So, might be better to do playlist.attributes.lang || 'und'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the documentation! Just made that change so we fallback to und

Copy link
Member

Choose a reason for hiding this comment

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

you're welcome!


if (!a[label]) {
a[label] = {
language: label,
Copy link
Member

Choose a reason for hiding this comment

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

oof, seems like a huge oversight of us not to have it set to the language, heh. Good catch!

src/toM3u8.js Outdated Show resolved Hide resolved
@gkatsev
Copy link
Member

gkatsev commented Oct 8, 2024

Just thought about it, and the change of the default from text to und is potentially a breaking change. Though, given that the language previously didn't make any sense, I think we should proceed anyway and call it a soft breakage. If it breaks anyone, we can then revert it for v4 and do a major version bump.

@wseymour15
Copy link
Contributor Author

Just thought about it, and the change of the default from text to und is potentially a breaking change. Though, given that the language previously didn't make any sense, I think we should proceed anyway and call it a soft breakage. If it breaks anyone, we can then revert it for v4 and do a major version bump.

Totally agree. It seems unlikely people are using a language value of text for anything, but I agree with moving forward and then bumping afterwards worst case.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.68%. Comparing base (5ea10f5) to head (8688dcd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #181   +/-   ##
=======================================
  Coverage   94.68%   94.68%           
=======================================
  Files          19       19           
  Lines         846      847    +1     
  Branches      258      259    +1     
=======================================
+ Hits          801      802    +1     
  Misses         45       45           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wseymour15 wseymour15 merged commit b48d2a5 into main Oct 9, 2024
8 checks passed
@wseymour15 wseymour15 deleted the fix/vtt-tracks-language branch October 9, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants