androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.63k stars 385 forks source link

HLS stream is not showing all audio tracks #1043

Open skogl opened 8 months ago

skogl commented 8 months ago

So I'm having a scenario with a HLS stream that doesn't show all of the audio tracks and my guess is that this is according to specs but either I can't figure out what I can do about it.

I've searched this github as well as the old exoplayer github for answers but it's difficult to sort out anything that can be of interest for this topic.

What I have is:

What I get is:

If I extract one of the streams from the adaptive HLS I get a mpeg-ts stream and if I try to play that I get all the tracks. There is no definition of the tracks in the HLS using any metadata keywords. Is this what is lacking, and if so can it be fixed?

I have followed the code all the way from TsExtractor where it doesn't store the track pid but instead gets the stream type using int trackId = false && mode == MODE_HLS ? streamType : elementaryPid; Fast forward into HlsSampleStreamWrapper it seem to filter the tracks using 'sampleQueues' and basically group the audio tracks together so even if I override the code in TsExtractor to output all the tracks it doesn't get past this.

So I stopped debugging and seeing how it is grouped together I figured there might be a flag or something else I missed? Or maybe most likely the HLS is not well formed and will not work. The question is: how can I then make the HLS well formed?

FongMi commented 8 months ago

Please provide test url let me test.

tianyif commented 8 months ago

Hi @skogl,

Thanks for reporting! Could you please provide a sample url so that we can debug from it? Thanks in advance!

skogl commented 8 months ago

Hi, thank you for responding. Should I take this as "it doesn't sound right"?

I can't share this stream directly with you but I can setup a test stream just for a section/window or the stream. Would that be enough for debugging?

tianyif commented 8 months ago

Hi @skogl,

Should I take this as "it doesn't sound right"

I haven't been sure to be honest, but a test stream should be helpful to identify it.

skogl commented 8 months ago

I uploaded a test stream to android-media-github@google.com. I was wrong in assuming that it was adaptive though, not sure if that changes anything. I'm obviously not familiar with the different formats a hls stream can have. Playing the hls directly results in only 1 audio track being found where's playing any of the sections as progressive stream finds 4 tracks.

tianyif commented 8 months ago

Hi @skogl,

Thank you for the test stream! However, later I've looked at the previous issue, and found that it had been discussed widely before (https://github.com/google/ExoPlayer/issues/2014). The ExoPlayer doesn't show multiple tracks muxed is an intended behavior, and it remains as low-priority enhancement per the HLS spec:

9.7. If you have alternative audio content (languages/commentary/DVS), you MUST use separate audio streams.

I'm seeing the other people provided their solution and they said it was working, so you can probably try them. Some examples:

skogl commented 8 months ago

Thank you for looking this up. I must have browsed for hours in order to find related questions and didn't find the one you link. Sorry about that.

The specs you reference indicates a multivariant playlist though and the one I'm trying to use seem to be a media playlist. I'm going over the specs as we speek to see if I can find something.

I appreciate the links to the workarounds as well but personally I feel they are too intrusive and will break compatibility with main branch too much. Maybe I can continue the path I was into before giving up to start this issue.

I'm not finished reading the specs and you may be correct in that it is not allowed, but then other players does allow this use case and according to that other thread even the apple player that you refer to does.

So, I'll see what the specs say and possibly form a workaround on my own. Either way I appreciate that you've taken your time.

FongMi commented 8 months ago

It's like my problem https://github.com/androidx/media/issues/999

FongMi commented 8 months ago

I can provide solution, please give me your mail.

skogl commented 8 months ago

If you have a solution I'd rather see that you provide it here so more users can take part of it.