ExoPlayer does not play audio on devices that use FFMPEG

I've installed ExoPlayer to stream audio and it works great on some devices I have (like my Nexus 5), but on others it just doesn't play anything.

To fix any issues with my app, I modified the demo app by changing the "Dizzy" video to a random MP3 that I am sitting on the server. In the DefaultRendererBuilder I am also returning a null render of the video track and I am only trying to play the audio.

Obviously, each device has its own set of codecs, so I suspected that the wrong one might be loading and breaking. I saw a couple of points in the ExoPlayer source where the decoder is determined from the MIME type, and I think I have narrowed it down to line in FrameworkSampleSource

in the method prepare

.

Once called setDataSource

, on the Huawei Mate 7 device I'm using, all hell breaks loose. Looks like it MediaExtractor

uses FFMPEG to fetch data, which doesn't seem to be compatible. Other devices I've tested with don't seem to do this. Here's a dump from LogCat

11-13 16:30:45.600 30793-30793/com.google.android.exoplayer.demo I/ExoPlayerImpl﹕ Init 1.0.13
11-13 16:30:45.605 30793-30881/com.google.android.exoplayer.demo I/﹕ uri = http://this-is-my-server.com/public/mime-test.mp3
11-13 16:30:45.605 30793-30881/com.google.android.exoplayer.demo I/﹕ after judge whether is youtube , isWidevine = 0
11-13 16:30:45.605 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractor﹕ FFMPEGExractor opened file is [http://this-is-my-server.com/public/mime-test.mp3]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo E/FFMPEGExtractor﹕ Can not find video stream!
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo E/FFMPEGExtractorUtils﹕ Couldn't find MIME by codec id 86017 !
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractor﹕ Unknown MIME,try using ffmpegaudiodecorder to decode
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractor﹕ setAudioMeta MIME = audio/ffmpeg
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractor﹕ audio/ffmpeg set kKeyFFmpegCodecID,codec->codec_id =     86017
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ Audio:
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ {
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ kKeyMIMEType = [audio/ffmpeg]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ kKeyDuration = [00:01:43.42]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ kKeyBitRate = [128000 bps]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ kKeyChannelCount = [1]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ kKeySampleRate = [44100 bps]
11-13 16:30:45.790 30793-30881/com.google.android.exoplayer.demo I/FFMPEGExtractorUtils﹕ }
11-13 16:30:45.790 30793-30883/com.google.android.exoplayer.demo I/OMXClient﹕ Using client-side OMX mux.
11-13 16:30:45.795 30793-30883/com.google.android.exoplayer.demo I/MediaCodec﹕ Found 0 pieces of codec specific data.
11-13 16:30:45.795 30793-30883/com.google.android.exoplayer.demo I/ACodec﹕ allocateBuffersOnPort,isHevc = 0
11-13 16:30:45.795 30793-30883/com.google.android.exoplayer.demo I/ACodec﹕ allocateBuffersOnPort,isHevc = 0
11-13 16:30:47.210 30793-30881/com.google.android.exoplayer.demo W/FFMPEGExtractor﹕ retry to read pakcet
11-13 16:30:47.210 30793-30881/com.google.android.exoplayer.demo W/FFMPEGExtractor﹕ retry to read pakcet
11-13 16:30:47.210 30793-30881/com.google.android.exoplayer.demo W/FFMPEGExtractor﹕ retry to read pakcet
11-13 16:30:47.210 30793-30881/com.google.android.exoplayer.demo W/FFMPEGExtractor﹕ retry to read pakcet
11-13 16:30:47.210 30793-30881/com.google.android.exoplayer.demo E/FFMPEGExtractor﹕ Reaching the end of file! streamId : 0

      

As you can see, it doesn't seem to be able to correctly determine the MIME type. If I go to the EXACT SAME file that's the local version on disk, it plays just fine only if it's on the server. FFMPEG doesn't seem to understand what MIME is and uses its own bastardised "audio / ffmeg" instead. It seems like it got the duration, etc. but just can't play the file.

If I set a listener to ExoPlayer, I can see it moving through each of the states - while cooking, buffered, but NEVER ready. It will move from "buffering" to "complete".

While I'm not sure if this is a particular issue with ExoPlayer, surely someone must have come across something similar to this? This is a pretty simple use case - just playing MP3 using strings -

SampleSource sampleSource = new FrameworkSampleSource(context, uri, headers, RENDERER_COUNT);
audioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource, null, true);

      

Nothing too exciting. What am I doing wrong? What can I do to get around this? I even went through "Content-Type": "audio / mpeg" as a header and doesn't do anything.

+3


source to share


2 answers


Exoplayer now has an app-level tool extractor (currently on the dev branch) that avoids this issue entirely as it doesn't run through the Android media MediaExtractor.



Check out the PlayerActivity and ExtractorRendererBuilder demo app to get an idea of ​​how to use it.

+4


source


To me it looks like an error specific to the Android platform from Huawei Mate 7. The error is that MediaExtractor does not work correctly for server-hosted MP3 files. You can prove it by using the same url that is hosted on the server and play it with another application that uses Android MediaPlayer. You will find countless code examples or APKs that use MediaPlayer on the web.



A quick google search gave http://examples.javacodegeeks.com/android/android-mediaplayer-example/ http://code.tutsplus.com/tutorials/create-a-music-player-on-android-song-playback --mobile-22778

+2


source







All Articles