androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
Apache License 2.0
1.37k stars 322 forks source link

Certain hls videos wait forever for eos in mediaCodec #660

Open PsPLoG opened 9 months ago

PsPLoG commented 9 months ago

Version

ExoPlayer 2.18.1

More version details

No response

Devices that reproduce the issue

Samsung Galaxy S22, Android 12

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No

Reproduction steps

  1. Start broadcasting through apple low latency hls
  2. Stop broadcasting.

Expected result

return Player.STATE_END from onPlayerStateChanged listener and isPlaying() is false

Actual result

return Nothing from onPlayerStateChanged listener and isPlaying() is alway true

Media

[MediaCodecRenderer.drainOutputBuffer:1822]

스크린샷 2023-09-19 오후 4 06 12

If you play it again with the same media link, there is no problem, and problems occur only when the stream is cut off during video playback, making it difficult to attach media files.

Instead, when I checked the MediaCodecRender through debugging, I found that I was checking the infinite loop in the above state

Please let me know if you need any additional information

Bug Report

tianyif commented 9 months ago

Hi @PsPLoG,

Thanks for reporting! Let me try to clarify the problem:

problems occur only when the stream is cut off during video playback

Is the scenario like while the client watching the broadcast and something happens at the provider end so the broadcast cannot continue?

PsPLoG commented 9 months ago

@tianyif There is a glitch when the streamer ends the broadcast or when the transmission shuts off due to an error. When the transmission shuts off, hls endtag is sent to notify that it has been shut off. The exoplayer received the endtag but it gets stuck in an infinite loop due to the problem mentioned above.

ex) hls tags
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:729
#EXT-X-TARGETDURATION:2
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=3.0
#EXT-X-PART-INF:PART-TARGET=1.0
#EXTINF:2.0,
#EXT-X-PROGRAM-DATE-TIME:2023-09-05T05:49:56.866Z
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00730.0.Ibpu1YK9pEKq4aduZ2NnqfO6haHbwnKFhyMh4OvOwd8.ts",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00730.1.Ibpu1YK9pEKq4aduZ2Nnql72IKRyRJQGCHIevPME1MO.ts"
#EXTINF:2.0,
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00731.0.Ibpu1YK9pEKq4aduZ2Nnqmr9wHoF9h49rlfWqFkT1TI.ts",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00731.1.Ibpu1YK9pEKq4aduZ2NnqgkxXAV3tOIRGsll9FMrSRj.ts"
#EXTINF:2.0,
#EXT-X-PROGRAM-DATE-TIME:2023-09-05T05:50:00.582Z
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00732.0.Ibpu1YK9pEKq4aduZ2Nnqh5b0SQRcN35Sil2u1BSarg.ts",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.0,URI="part/0000480.00732.1.Ibpu1YK9pEKq4aduZ2NnqiTk1dY2Ws0sDXBLztCHHoL.ts"
#EXTINF:2.0,
#EXT-X-ENDLIST
tianyif commented 9 months ago

Hi @PsPLoG ,

Thanks for the information! The player which received the EXT_X_ENDLIST tag may not add the BUFFER_FLAG_END_OF_STREAM to the buffer properly, so the media codec is not informed.

However, after the attempt to investigate the issue with barely looking into the code in the absence of a sample media, we still feel difficult in identifying the detailed cause, so we probably need to try some hacky approaches to simulate the scenario. I apologize in advance if it will take longer :)

PsPLoG commented 9 months ago

@tianyif

Does that mean it's not the cause??

If you give me information about how BUFFER_FLAG_END_OF_STREAM is called, I'll analyze the code

PsPLoG commented 6 months ago

@tianyif Is the matter in progress? Please let me know if you need any help