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

Error when playing SmoothStreaming with subtitles #1779

Closed
1 task
marekl-ag opened this issue Oct 4, 2024 · 1 comment
Closed
1 task

Error when playing SmoothStreaming with subtitles #1779

marekl-ag opened this issue Oct 4, 2024 · 1 comment
Assignees
Labels

Comments

@marekl-ag
Copy link

Version

Media3 1.4.1

More version details

No response

Devices that reproduce the issue

AndroidTV STB with AndroidTV 12

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Play SmoothStreaming media with subtitles in demo application.

Problem exists only in case of extraction phase subtitle parsing path - which is now default.
SmoothStreaming media source (DefaultSsChunkSource) uses FragmentedMp4Extractor with non-null sideloadedTrack which seems to be incorrecly handled in FragmentedMp4Extractor.init() which in turn causes subtitles to be decoded by CueDecoder without being first encoded.

Following change causes stream to play correctly:

diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java
--- a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java	
+++ b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java	(date 1728030664226)
@@ -417,7 +417,7 @@
     if (sideloadedTrack != null) {
       TrackBundle bundle =
           new TrackBundle(
-              output.track(0, sideloadedTrack.type),
+              extractorOutput.track(0, sideloadedTrack.type),
               new TrackSampleTable(
                   sideloadedTrack,
                   /* offsets= */ new long[0],

Expected result

Media plays with subtitles rendered

Actual result

Playback error with following exception:

  playerFailed [eventTime=1.12, mediaPos=0.00, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK
    androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
    Caused by: java.lang.IllegalStateException: Bad magic number for Bundle: 0x6576206c
      at android.os.BaseBundle.readFromParcelInner(BaseBundle.java:1659)
      at android.os.BaseBundle.<init>(BaseBundle.java:143)
      at android.os.Bundle.<init>(Bundle.java:96)
      at android.os.Parcel.readBundle(Parcel.java:2658)
      at androidx.media3.extractor.text.CueDecoder.decode(CueDecoder.java:63)
      at androidx.media3.exoplayer.text.TextRenderer.readAndDecodeCuesWithTiming(TextRenderer.java:336)
      at androidx.media3.exoplayer.text.TextRenderer.renderFromCuesWithTiming(TextRenderer.java:295)
      at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:263)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)

Media

https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel-multiple-subtitles.ism/Manifest

Bug Report

@icbaker
Copy link
Collaborator

icbaker commented Oct 8, 2024

Thanks for the report and the suggested fix, it looks like this 'direct' usage of the output parameter was missed in da724c8 - I'll send a fix internally and it will be linked here when it's published.

copybara-service bot pushed a commit that referenced this issue Oct 8, 2024
This change is a no-op, because
`SubtitleTranscodingExtractorOutput.seekMap` forwards directly to the
delegate implementation, but it seems clearer to always use the
wrapper.

Also remove a no-op assignment in `MatroskaExtractor`.

This is a follow-up to Issue: #1779 where I manually checked every
implementation of `Extractor.init` for a similar mistake.

#cherrypick

PiperOrigin-RevId: 683607090
copybara-service bot pushed a commit that referenced this issue Oct 8, 2024
This was missed in da724c8

I tried to write a test for this, but got stuck crafting valid test
data. I was able to create a new fragmented MP4 file containing only a
TTML track:

```shell
$ MP4Box -add simple.ttml -frag 2000 sample_fragmented_ttml.mp4
```

Then I tried naively removing the `ftyp` and `moov` boxes with a hex
editor, but using this in `FragmentedMp4ExtractorNoSniffingTest` gave
me an `EOFException` that I didn't get to the root cause of.

Issue: #1779

#cherrypick

PiperOrigin-RevId: 683667850
@icbaker icbaker closed this as completed Oct 9, 2024
@androidx androidx locked and limited conversation to collaborators Dec 9, 2024
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

2 participants