google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.02k forks source link

Unable to play MPEG2/MPEG-TS samples #785

Closed chammack closed 9 years ago

chammack commented 9 years ago

I attempted to modify Samples.java in the demo app to play two frequently used mpeg2 ts sample files with different failure modes.

The two files are here: http://dveo.com/downloads/TS-sample-files/

One file shows obvious errors in logcat: 09-09 20:26:10.316 19658 19690 E ExoPlayerImplInternal: Caused by: com.google.android.exoplayer.MediaCodecTrackRenderer$DecoderInitializationException: Decoder init failed: [-49999], MediaFormat(audio/mpeg-L2, -1, 4096, -1, -1, -1, -1.0, 2, 48000, null, -1, false, -1, -1)

And the other throws no discernable errors, just never seems to play the file. I copied these files locally and am streaming them from a local http server using TYPE_MISC to eliminate bandwidth issues.

Device is a Nexus 6, similar results on nVidia Shield.

ojw28 commented 9 years ago
ojw28 commented 9 years ago

I filed #793 specifically to track supporting the additional video stream types.

chammack commented 9 years ago

Thanks for the analysis. For some reason, I (incorrectly) assumed that the other video types were being handed off to MediaCodec for decoding.

I'm aware that this format is probably not widespread for mobile use, but HDHomerun devices (such as https://www.silicondust.com/products/hdhomerun/prime) stream mpeg2 video in a ts container via http. I was primarily looking to be able to stream from these boxes over a LAN to android tv boxes.

ojw28 commented 9 years ago

Can they not stream anything else (both for video and for audio)? I don't think H.222 is guaranteed to be supported on any Android devices (see the supported media formats). So whilst support may be present, it's not guaranteed.

ExoPlayer does use MediaCodec, but it still needs to parse the samples from the container and extract decoder initialization data, which we don't currently do for these stream types.

We will look at adding support for this kind of video stream eventually (as tracked by #793), but it remains low priority. For audio, AC3 will probably work for AndroidTV devices, but not for mobile devices.

chammack commented 9 years ago

They have several models. There is an OTA (antenna) model which can do transcoding to h.264 (TV signal is almost always H.222 for both antenna and cable TV), but I specifically was trying to support the cablecard model, which does not offer any transcoding... it simply passes the cable tv video and audio stream (H.222 and AC3).

H.222 decoding is a little bit of a pain, but as far as I know, all of the major Android TV boxes have or will have hardware H.222 decoders. nVidia shield has one as of update 1.2, Nexus Player gets one in Android M, Forge TV shipped with one, and Sony's TVs also shipped with one.

ojw28 commented 9 years ago

Right, so what's missing in ExoPlayer is that we don't have a suitable stream reader here. streamType is 0x02 in this case. The corresponding platform extractor does have support for this streamType value, on L496 of this class.

So to add support, we'd need to add a corresponding reader, probably based on whatever the platform does. You're welcome to have a go at doing this, if you want ;). Either way, let's move discussion to the new issue.