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

Parse CHANNELS Attribute in EXT-X-MEDIA #2527

Closed
kickermeister opened this issue Feb 13, 2020 · 8 comments
Closed

Parse CHANNELS Attribute in EXT-X-MEDIA #2527

kickermeister opened this issue Feb 13, 2020 · 8 comments

Comments

@kickermeister
Copy link

Is your feature request related to a problem? Please describe.
I need to know the channel number of streams for certain applications. See e.g. https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8

Describe the solution you'd like
Parse the CHANNEL attribute in EXT-X-MEDIA and provide the information in the audioTracks object for every audioTrack.

Describe alternatives you've considered
As there is no simple way to detect the channel number from a HTML5 media element, I would need to write or use a separate HLS parser.

@itsjamie
Copy link
Collaborator

It would be good to provide this information, however, like you mentioned the audioTracks API doesn't have a standard property to include the channel count.

I would definitely think that it would be a good idea however to include the ability to be able to connect an audio track to its source track in the HLS manifest and retrieve this metadata.

Perhaps an API that takes the id property of the audio track and retrieves this?

@kickermeister
Copy link
Author

kickermeister commented Feb 17, 2020

Perhaps an API that takes the id property of the audio track and retrieves this?

I don't have strong feelings about the implementation, the existence of the functionality is more important to me. It would be handy, however, if the audioTracks API could be extended with the channel count information (if that's easily possible).

@kickermeister
Copy link
Author

I just realized that RFC 8216 is pretty strict regarding the CHANNELS attribute (see https://tools.ietf.org/html/rfc8216#section-4.3.4.1):

  All audio EXT-X-MEDIA tags SHOULD have a CHANNELS attribute.  If a
  Master Playlist contains two Renditions encoded with the same
  codec but a different number of channels, then the CHANNELS
  attribute is REQUIRED; otherwise, it is OPTIONAL.

The CHANNELS attribute would be, however, also very useful for other use cases where more than two audio channels are used.

@robwalch
Copy link
Collaborator

@kickermeister The ticket title and description read CHANNEL, but you're referring to the CHANNELS attribute correct?

I think we should include EXT-X-MEDIA attributes (attrs) on track objects the same we include EXT-X-STREAM-INF attributes on level objects:

hlsManifestParsed ({
    "levels": [
        {
            "attrs": {
                "BANDWIDTH": "827972",
                "AVERAGE-BANDWIDTH": "482170",
                "CODECS": "avc1.42c01e,mp4a.40.2",
                "RESOLUTION": "192x144",
                "AUDIO": "default-audio-group",
                "SUBTITLES": "default-text-group"
            },

No reason we don't other than it hasn't been implemented.

    "audioTracks": [
        {
            "groupId": "default-audio-group",
            "name": "stream_5",
            "type": "AUDIO",
            "default": true,
            "autoselect": true,
            "forced": false,
            "url": "https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/playlist_a-eng-0128k-aac-2c.mp4.m3u8",
            "lang": "en",
            "audioCodec": "mp4a.40.2",
            "id": 0,

😢

@robwalch robwalch added this to the 1.0.0 milestone Feb 28, 2020
@robwalch
Copy link
Collaborator

This feature is already implemented in feature/v1.0.0

@kickermeister Have you tried the v1 branch?

       {
            "attrs": {
                "TYPE": "AUDIO",
                "URI": "playlist_a-deu-0128k-aac-2c.mp4.m3u8",
                "GROUP-ID": "default-audio-group",
                "LANGUAGE": "de",
                "NAME": "stream_4",
                "AUTOSELECT": "YES",
                "CHANNELS": "2"
            },
            "bitrate": 0,
            "id": 1,
            "groupId": "default-audio-group",
            "name": "stream_4",
            "type": "AUDIO",
            "default": false,
            "autoselect": true,
            "forced": false,
            "lang": "de",
            "url": "https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/playlist_a-deu-0128k-aac-2c.mp4.m3u8",
            "audioCodec": "mp4a.40.2"
        },

@kickermeister kickermeister changed the title Parse CHANNEL Attribute in EXT-X-MEDIA Parse CHANNELS Attribute in EXT-X-MEDIA Mar 2, 2020
@kickermeister
Copy link
Author

@robwalch Thanks for your reply, I was of course referring to the CHANNELS attribute (changed accordingly the title of this issue). The implementation in v1.0.0 branch seems to work properly. You may have good reasons but I'm still wondering whether the channels information which is in attrs object could be also added to the audioTrack object, like:

{
            "attrs": {
                "TYPE": "AUDIO",
                "URI": "playlist_a-deu-0128k-aac-2c.mp4.m3u8",
                "GROUP-ID": "default-audio-group",
                "LANGUAGE": "de",
                "NAME": "stream_4",
                "AUTOSELECT": "YES",
                "CHANNELS": "2"
            },
            "bitrate": 0,
            "id": 1,
            "groupId": "default-audio-group",
            "name": "stream_4",
            "type": "AUDIO",
            "default": false,
            "autoselect": true,
            "forced": false,
            "lang": "de",
            "channels": 2,
            "url": "https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/playlist_a-deu-0128k-aac-2c.mp4.m3u8",
            "audioCodec": "mp4a.40.2"
        },

@robwalch
Copy link
Collaborator

robwalch commented Mar 3, 2020

You may have good reasons but I'm still wondering whether the channels information which is in attrs object could be also added to the audioTrack object

@kickermeister Because it's an optional attribute, and hls.js does not use channels internally, we haven't added it on the audioTrack objects. If we did, that could create the expectation for us to populate channels even when not present in the manifest (based on audio data like adtsChanelConfig for example). So best reason I can give is that I'm hoping to avoid that.

@robwalch
Copy link
Collaborator

robwalch commented Mar 3, 2020

I'm closing this one based on the comments above. If you have trouble working off feature/v1.0.0 let me know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants