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.7k stars 406 forks source link

Live DAI DASH streaming freezing with multi periods and no closed caption Ad. #1863

Open linhai326 opened 5 days ago

linhai326 commented 5 days ago

Version

Media3 1.4.0 and beyond.

More version details

Issue doesn't happen in 1.3.1. and before

Devices that reproduce the issue

issue can be reproduced on all Android devices we tested: amazon FireTV stick 4K, for example.

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Stream should play without issue

Actual result

streaming will be freezing in a couple of minutes.

Media

will send content in email.

Bug Report

linhai326 commented 5 days ago

We believe this bug was introduced in 1.4.0 when removing "IsDecodeOnly" commits:

https://github.com/androidx/media/commit/0f42dd47526c70e38b1048bb18c994c281800485 https://github.com/androidx/media/commit/6e0f8e3b0d251a06a6af8d03204db2ba0dfd6464

Particularly, it seems this is the bug, in CeaDecoder.java, line 88, in queueInputBuffer(): https://github.com/androidx/media/blob/release/libraries/extractor/src/main/java/androidx/media3/extractor/text/cea/CeaDecoder.java Screenshot 2024-11-07 at 12 54 09 PM

there seems should be a check for ceaInputBuffer.timeUs != C.TIME_END_OF_SOURCE when discarding the ceaInputBuffer. Without this check, the playback could be stuck due to the text render is keeping waiting for end of source.

linhai326 commented 21 hours ago

any update?

icbaker commented 18 hours ago

I think I was able to repro the issue using the media links provided over email. I then added a single log line and went to retry, and now the content is consistently 503ing.

Could you please check to make sure the content is still accessible?

icbaker commented 13 hours ago

The content seems to be working again now.

I've tried with the following code in CeaDecoder and playback no longer seems to hang:

if (ceaInputBuffer.timeUs != C.TIME_END_OF_SOURCE
    && outputStartTimeUs != C.TIME_UNSET
    && ceaInputBuffer.timeUs < outputStartTimeUs) {
  // We can start decoding anywhere in CEA formats, so discarding on the input side is fine.
  releaseInputBuffer(ceaInputBuffer);
} else {

Thanks for reporting! I'll work on getting this fix reviewed internally and merged.

I've also noticed that the subtitles in your content are mixed up/garbled on main (and likely will be in 1.5.0-rc01 too though I haven't checked) - I'm looking into this as well, as it's likely related to some changes after 1.4.1 (we've seen and fixed similar symptoms recently, but this must be a case we haven't fixed yet).

icbaker commented 10 hours ago

The fix for the CeaDecoder is submitted and linked above.

I also investigated the garbled captions. The problem is due to your MP4 container marking every video sample as a keyframe, meaning that we flush our reordering queue of CEA-608 samples here on every sample (which means it can't re-order anything): https://github.com/androidx/media/blob/19b38c83b6ce1d13effc08da834cc8ff284cb969/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java#L1650-L1652

This MP4 metadata is inconsistent with the H.264 bytes contained in each sample (not every H.264 sample is a keyframe).

If I change the if condition to just (trackBundle.getCurrentSampleFlags() & C.BUFFER_FLAG_END_OF_STREAM) != 0 then the subtitles become un-garbled (because the queue is able to correctly re-order the out-of-order samples). However, I'm not sure this is a correct change in general (we should be able to rely on flushing our queue on each keyframe, and we should be able to rely on the MP4 keyframe metadata being correct).

This seems to be an issue with your content muxing, rather than with ExoPlayer's logic - I suggest you report it to whoever is producing your content.

linhai326 commented 9 hours ago

@icbaker Thanks a lot for looking into this issue. We will check with our content provider!!