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

MPEG-TS stream with SCTE subtitle track may fail to start #5330

Closed
okycelt opened this issue Dec 31, 2018 · 10 comments
Closed

MPEG-TS stream with SCTE subtitle track may fail to start #5330

okycelt opened this issue Dec 31, 2018 · 10 comments
Assignees
Labels

Comments

@okycelt
Copy link

okycelt commented Dec 31, 2018

Issue description

When trying to play the .ts file sent via email, the player goes to prepared state but doesn't start playing anything. If we stream the .ts file by tsplay as a UDP multicast, the player won't throw any error. If we try playing the .ts file directly from the device, we get OutOfMemoryError after a few seconds. We've tried setting the FLAG_ALLOW_NON_IDR_KEYFRAMES and FLAG_DETECT_ACCESS_UNITS flags but it didn't have any effect.

12-31 05:27:09.890  5731  5731 E EventLogger: internalError [11.40, 0.00, window=0, period=0, loadError]
12-31 05:27:09.890  5731  5731 E EventLogger: com.google.android.exoplayer2.upstream.Loader$UnexpectedLoaderException: Unexpected OutOfMemoryError: Failed to allocate a 65548 byte allocation with 1904 free bytes and 1904B until OOM
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:409)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at java.lang.Thread.run(Thread.java:818)
12-31 05:27:09.890  5731  5731 E EventLogger: Caused by: java.lang.OutOfMemoryError: Failed to allocate a 65548 byte allocation with 1904 free bytes and 1904B until OOM
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.source.SampleQueue.preAppend(SampleQueue.java:626)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:562)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.extractor.ts.MpegAudioReader.readHeaderRemainder(MpegAudioReader.java:192)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.extractor.ts.MpegAudioReader.consume(MpegAudioReader.java:98)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.extractor.ts.PesReader.consume(PesReader.java:136)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.extractor.ts.TsExtractor.read(TsExtractor.java:325)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:898)
12-31 05:27:09.890  5731  5731 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:379)
12-31 05:27:09.890  5731  5731 E EventLogger: 	... 3 more

Also, regarding MPEG-TS content in general, we've been having issues with playing some content. From our experience, ExoPlayer is usually able to play about 90% of streams we encounter but we're often not sure why the problematic streams are problematic. Do you have any advice on what to pay attention to when debugging this or on what is ExoPlayer sensitive to?

Thank you.

Reproduction steps

Either play the .ts file directly using FileDataSource and ExtractorMediaSource or stream the .ts file using tsplay and play the stream using UdpDataSource and ExtractorMediaSource.

Link to test content

Sent via email

Version of ExoPlayer being used

ExoPlayer 2.9.0

Device(s) and version(s) of Android being used

Amlogic S905X, 1GB RAM, Android 6.0.1
HiSillicon Hi3798M V200, 2GB RAM, Android 8.0

A full bug report captured from the device

Sent via email (both when using FileDataSource and when using UdpDataSource)

@ojw28 ojw28 assigned ojw28 and andrewlewis and unassigned ojw28 Jan 2, 2019
@ojw28 ojw28 added the bug label Jan 2, 2019
@ojw28 ojw28 changed the title Player goes to prepared state but doesn't actually start playing (MPEG-TS) MPEG-TS stream with SCTE subtitle track may fail to start Jan 2, 2019
@ojw28
Copy link
Contributor

ojw28 commented Jan 2, 2019

@andrewlewis - This looks related to addition of DTS support [internal cr ref: 112774678]. There's a stream with type 0x82 (TS_STREAM_TYPE_HDMV_DTS) in this piece of content, but I think it's probably an SCTE subtitle track instead. As a result we don't ever get a format for the track, so end up stuck preparing. According to https://en.wikipedia.org/wiki/Program-specific_information 0x82 can be:

SCTE subtitle or DTS 6 channel audio for Blu-ray in a packetized stream",

however we currently assume the latter. This might not be easy to fix, unfortunately.

@andrewlewis
Copy link
Collaborator

@AquilesCanta Any ideas if there's some signaling that we can use to distinguish these?

@okycelt
Copy link
Author

okycelt commented Jan 3, 2019

In theory, would it be possible to do something temporary on our end? Either signal the player manually that it should treat the 0x82 stream as SCTE subtitle or tell the player to skip the 0x82 stream completely? Thank you.

@andrewlewis
Copy link
Collaborator

TsExtractor can take a custom TsPayloadReaderFactory where you implement your own behavior, like delegating to a DefaultTsPayloadReaderFactory except when the stream type is 0x82. When creating ExtractorMediaSource you can pass a custom ExtractorsFactory that creates the TsExtractor with the custom payload reader factory.

@whyvas

This comment has been minimized.

@okycelt

This comment has been minimized.

@ojw28

This comment has been minimized.

@whyvas

This comment has been minimized.

@AquilesCanta
Copy link
Contributor

I think using a custom TsPayloadReaderFactory is the way to go. I'd just wrap the default implementation and intercept the 0x82 stream type.

As a library-side fix, I think sniffing the PES packets is the only way to go. Unfortunately, I cannot allocate time to do this. For the time being, I have added a flag to the DefaultTsPayloadReaderFactory: FLAG_IGNORE_HDMV_DTS_STREAM, which will be available in the next push. Setting this flag should save you the factory customization.

ojw28 pushed a commit that referenced this issue Jan 21, 2019
Prevents collisions with SCTE-35 subtitles.

Issue:#5330
PiperOrigin-RevId: 230195494
ojw28 pushed a commit that referenced this issue Jan 30, 2019
Prevents collisions with SCTE-35 subtitles.

Issue:#5330
PiperOrigin-RevId: 230195494
@ojw28
Copy link
Contributor

ojw28 commented Mar 31, 2019

@andrewlewis - Given we can't reliably disambiguate between SCTE and DTS at the moment, should we consider disabling DTS support by default, and flipping the flag so that we only enable support if a flag is set?

The issue ref'd above contains more streams that are affected by this issue.

@ojw28 ojw28 assigned andrewlewis and unassigned AquilesCanta Mar 31, 2019
ojw28 pushed a commit that referenced this issue Apr 1, 2019
Issue: #5330
PiperOrigin-RevId: 241381723
@ojw28 ojw28 closed this as completed Apr 1, 2019
@google google locked and limited conversation to collaborators Aug 5, 2019
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

5 participants