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

Hooking up a MediaSource for specific subtitles when a video does not have them causes looping to fail after the 2nd play through #7590

Closed
Ste-RH opened this issue Jul 3, 2020 · 4 comments
Assignees
Labels

Comments

@Ste-RH
Copy link

Ste-RH commented Jul 3, 2020

[REQUIRED] Issue description

Defining a subtitle media source of specific type/language (via createTextSampleFormat) causes a video to not loop a second time. If I pass NULL into the 'sampleMimeType and 'language' the video will loop perfectly over and over and over again as it should do.

[REQUIRED] Reproduction steps

I changed the demo code to loop and added the following video to media.exolist.json:
{ "name": "test", "uri": "https://html5demos.com/assets/dizzy.mp4", "subtitle_uri": "https://html5demos.com/assets/dizzy.mp4", "subtitle_mime_type": "text/vtt", "subtitle_language": "en" }

[REQUIRED] Link to test content

Using: https://html5demos.com/assets/dizzy.mp4

[REQUIRED] A full bug report captured from the device

testreport.txt The important part of the log can be seen by searching for 'TextRenderer' I think.

[REQUIRED] Version of ExoPlayer being used

2.11.5

[REQUIRED] Device(s) and version(s) of Android being used

Nexus 7 (2nd gen), Android Version: 6.0.1

@icbaker
Copy link
Collaborator

icbaker commented Jul 3, 2020

I can't reproduce the problem. I added player.setRepeatMode(Player.REPEAT_MODE_ALL); here:

player.addAnalyticsListener(new EventLogger(trackSelector));

I tried with both REPEAT_MODE_ALL and REPEAT_MODE_ONE.

I see the video play (with no visible subtitles, as expected). When it reaches the end it plays again.

Aside: I'm not sure passing an MP4 file with embedded WebVTT subtitles to subtitle_uri is supported - that option is designed for side-loading of subtitle text files as described here:
https://exoplayer.dev/media-sources.html#side-loading-a-subtitle-file

The error you see in the log seems like ExoPlayer is trying to decode 'random' bytes as a WebVTT file and is upset that it doesn't start with the WEBVTT magic string. That may happen if it tries to decode a full MP4 file as a WebVTT file

Would you be able to clarify your reproduction steps to help me understand the problem?

@Ste-RH
Copy link
Author

Ste-RH commented Jul 3, 2020

It is the end of the second play-through that then does not loop.

So let the mp4 play through once, loop, play again...it's at the end of that loop where it fails to loop again.

I originally came across this issue loading an HLS stream that did not include a subtitle track (I was told it did)...the MP4 shown is just a quicker (shorter) was of reproducing the same issue.

@icbaker
Copy link
Collaborator

icbaker commented Jul 6, 2020

Ah thanks - I'd misunderstood "loop a second time".

I can now reproduce. I can also reproduce the same behaviour without changing the repeat mode by seeking during the first playback.

I also noticed that at the end of the playback it doesn't fail/crash, the position keeps counting up beyond the end of the video suggesting it thinks there's still subtitle data to decoder.

I worked out it's related to this change (before this playback would fail immediately at the start of the first playback):
4107375

And specifically the fact that we set SimpleDecoder#exception = null in SimpleDecoder#flush() but if we've seen an error then the decoderThread has already exited, so all future calls to SimpleDecoder#queueInputBuffer() (and most other methods) don't throw an exception but also don't trigger any concrete decoding work. This means we never receive an end-of-stream signal, so the TextRenderer keeps playback alive (which is why the counter keeps counting up at the end).

I'll work on fixing this - thanks for reporting.

icbaker added a commit that referenced this issue Jul 6, 2020
Clearing the exception puts the SimpleDecoder into a silent failure
state - the decoder thread is dead (because decode() has returned
false) but it's still possible to queue buffers to the decoder (they
just never get decoded). This partially reverts
4107375

Also always recreate the decoder when handling an error in TextRenderer

This ensures we can try and decode a later subtitle sample after
encountering a decode error. This behaviour is what nulling out the
exception in SimpleDecoder.flush() was trying to achieve. We need to
ensure we don't start passing data to the new decoder until we've
hit the next key frame, so we throw away any non-keyframe samples
inside TextRenderer#render().

Issue: #7590
PiperOrigin-RevId: 319785908
@icbaker
Copy link
Collaborator

icbaker commented Jul 6, 2020

This should now be fixed on dev-v2.

@icbaker icbaker closed this as completed Jul 6, 2020
@google google locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants