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

Level label formatting issue #76

Open
kslimani opened this issue Jan 30, 2020 · 11 comments
Open

Level label formatting issue #76

kslimani opened this issue Jan 30, 2020 · 11 comments

Comments

@kslimani
Copy link
Contributor

kslimani commented Jan 30, 2020

i have done some tests with the "angel" dash source url (Star Trek) from demo page and as described in this issue, sometimes the mafinest expose several video representation with the same height but for different language, which result in duplicated labels.

This could be fixed by changing label formatting, maybe add language when available ?

Currently it result in 576p, 480p, ...

Maybe we could change to 576p (en), 480p (en), 576p (de), 480p (de), ... ?

I could push a fix proposition, but i would like first some feedbacks/ideas on potential new label string format. /ping @leandromoreira @jhonatangomes

EDIT: another issue is when levels elements count is high, the select ui is overflow hidden by player container. (maybe find a way to display on higher z-index and maybe display on bottom of button instead of top depending if enough space : not sure how to do that my css is terrible ;-) )

@leandromoreira
Copy link
Member

I think your proposed solution is great!!! add (context) language will help! let me bring @joaopaulovieira @towerz to the discussion as well, btw thanks once again man, you're on 🔥 👏 👏 👏 👏 👏 👏 👏 👏

@kslimani
Copy link
Contributor Author

kslimani commented Jan 31, 2020

My proposition is to add these modifications (not added yet to current pr #75) :

_hasDuplicateValue(objArray, key) {
      let hash = Object.create(null)

      for (let i = 0; i < objArray.length; ++i) {
        let v = objArray[i][key]
        if (v && v in hash)
          return true

        hash[v] = true
      }

      return false
  }

  _fillLevels () {
    if (this._levels.length === 0) {
      // Check if some video tracks have same height to avoid duplicated labels
      let hasDupeHeight = this._hasDuplicateValue(this.videoTracks, 'height')

      this._levels = this.videoTracks.map((videoTrack) => {
        return {
          id: videoTrack.id,
          level: videoTrack,
          label: hasDupeHeight ? `${videoTrack.height}p - ${videoTrack.language}` : `${videoTrack.height}p`
        }
      }).reverse()

      this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this.levels)
    }
  }

image

It is a workaround, because level selector plugin (and playbacks) does not have audio language switch mechanism yet.

@leandromoreira
Copy link
Member

Cool, what do you think of renaming _hasDuplicateValue to _mightHaveMultipleLanguages ... I'm not sure if it makes it clear or not because the function really just check duplicated values.

One solution to that could be:

let mightHaveMultipleLanguages = this._hasDuplicateValue(this.videoTracks, 'height')

@kslimani
Copy link
Contributor Author

Maybe rename method _hasDuplicateValue to _hasDuplicateObjectValue (method expects an array of object as first parameter, and second parameter is the name of object property to check for duplicate value)

Yes, we could rename hasDupeHeight variable to mightHaveMultipleLanguages to make it clearer.

@kslimani
Copy link
Contributor Author

In future version of Clappr i think we could remove completly label formatting logic from playback plugins, and normalize array of object provided by PLAYBACK_LEVELS_AVAILABLE event; and move all the formatting logic inside the level selector plugin ? (still providing formatting callback to allow developper customize labels)

It would also bring consistency because currently, labels for hls is are displaying bitrates and dash are displaying height(p).

@leandromoreira
Copy link
Member

100% in favor of creating a new component for that, great idea ! 👍

@kslimani
Copy link
Contributor Author

awww, the previous provided solution does not work in all case. There are some manifest with multiple time the same height, with the same language, but different bitrate...

I am starting to think that the hls.js playback default approach for label formatting using the bitrates might be a better.

@leandromoreira
Copy link
Member

I am starting to think that the hls.js playback default approach for label formatting using the bitrates might be a better.

Yeah and let it open for the custom personalization by the user

@kslimani
Copy link
Contributor Author

kslimani commented Feb 3, 2020

currently, i see 2 solutions :

First solution is to always use bitrate for label and check if video tracks has multiple audio languages. If this is the case, then use bitrate with language code for label.

Second solution is same as previous, but also check if no video track "height" duplication. If no duplication, then use height for label (same as current version), otherwise use bitrate (with/without language code).

Any thoughts ?

@leandromoreira
Copy link
Member

First solution is to always use bitrate for label and check if video tracks has multiple audio languages. If this is the case, then use bitrate with language code for label.

I'd like this one... not relying on duplicate height with different bitrates

@kslimani
Copy link
Contributor Author

kslimani commented Feb 4, 2020

@leandromoreira i added a commit in #75 which change the default label formatting to be the same as hls playback (ie: using bitrates).

When multiple languages are available, it append the language code to label.

It also sort the tracks in bandwidth DESC order. (previous code was wrongly assuming that tracks were already sorted and it was only reversing order).

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

No branches or pull requests

2 participants