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

Exoplayer crashes when it encounters a unexpected stream in an HLS file #2836

Closed
liuzhen2008 opened this issue May 16, 2017 · 6 comments
Closed
Assignees

Comments

@liuzhen2008
Copy link

liuzhen2008 commented May 16, 2017

The issue occurs for version 2.4.0

I have a HLS file generated from a third party with 3 tracks

Stream #0:0 is video
Stream #0:1 is audio
Stream #0:2 is something custom from the third party.

When I load my HLS into the exoplayer the player crashes with this stacktrace

java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.google.android.exoplayer2.Format.sampleMimeType' on a null object reference
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.buildTracks(HlsSampleStreamWrapper.java:594)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.maybeFinishPrepare(HlsSampleStreamWrapper.java:512)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.access$000(HlsSampleStreamWrapper.java:49)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper$1.run(HlsSampleStreamWrapper.java:136)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)


For some reason the crash above only happens on a fresh install. After if I initialize the player a second time, i ran into this error on the console and the player still won't play anything.

E/ExoPlayerImplInternal: Renderer error.
com.google.android.exoplayer2.ExoPlaybackException
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.java:380)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:336)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:796)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:365)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:494)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:479)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:308)
at android.os.Handler.dispatchMessage(Handler.java:98)
 at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: [-49999], Format(1/21, null, application/id3, -1, null, [-1, -1, -1.0], [-1, -1])
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:336) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:796) 
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCoat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:494) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:479)at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:308) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at android.os.Looper.loop(Looper.java:135) 
at android.os.HandlerThread.run(HandlerThread.java:61) 

Below is the ffprobe analysis for my file with this weird third stream. How can I have exoplayer to ignore stream #2?

Input #0, hls,applehttp, from 'http://some-s3-server/live/test.m3u8':
  Duration: 00:05:02.98, start: 2.320000, bitrate: 0 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 480x320, 250 tbr, 90k tbn, 180k tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 8000 Hz, mono, fltp
    Metadata:
      variant_bitrate : 0
    Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 0
Unsupported codec with id 100358 for input stream 2

This is the code I wrote to have the video player to play my urls. It is taken almost directly from the documents.

    public void onArchiveAddressLoaded(List<String> urls) {
        List<MediaSource> sources = new ArrayList<>();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "geez");

        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(this, trackSelector);
        for (String url : urls) {
            MediaSource source = new HlsMediaSource(Uri.parse(url), dataSourceFactory, null, null);
            sources.add(source);
        }
        ConcatenatingMediaSource concatenatedSource =
                new ConcatenatingMediaSource(sources.toArray(new MediaSource[]{}));
        player.prepare(concatenatedSource);
        player.setPlayWhenReady(true);
        archiveDisplay.setPlayer(player);
    }

@AquilesCanta AquilesCanta self-assigned this May 16, 2017
@liuzhen2008
Copy link
Author

liuzhen2008 commented May 16, 2017

@AquilesCanta
Copy link
Contributor

Thanks! It will probably have to wait until next week, but I will get to it as soon as I have some free time.

@liuzhen2008
Copy link
Author

@AquilesCanta Do you happen to know what i can do to have the exoplayer simply ignore the track?

@AquilesCanta
Copy link
Contributor

Anything not supported should be ignored by default. I'll look into this as soon as possible. Sorry for the inconvenience.

@liuzhen2008
Copy link
Author

When I tested with the sample app, i get a toast saying "The device does not provide a decoder for application/id3"

@AquilesCanta
Copy link
Contributor

The issue here is that the second chunk is not a continuation of the first one. It declares an audio while the first one does not. This is not allowed by the spec unless a discontinuity is signaled.

Each Media Segment MUST carry the continuation of the encoded
bitstream from the end of the segment with the previous Media
Sequence Number, where values in a series such as timestamps and
Continuity Counters MUST continue uninterrupted.

However, even with discontinuities, ExoPlayer does not support changes in the track configuration, like adding a track type that was not there or removing one. The best way to go here is fix the media, particularly because even though the pmt does not declare audio, the audio PES packets are there.

@google google locked and limited conversation to collaborators Sep 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants