0

I've written a very simple application that loops through a list of videos and streams them from a nodejs server.

I'm just doing your basic video streaming set up with the Android MediaPlayer API, and everything works great, except for surround sound.

With Dolby Digital (ac3), I don't get any audio at all. I tried aac 5.1 and got audio, but it was downconverter to stereo.

public void setupVideoView(Uri videoAddress) {
    emVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            // Prepared Listener
        }
    });
    emVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            // Error Listener
        }
    });
    emVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            setupVideoView(Uri.parse(video_url));
        }
    });
    emVideoView.setVideoURI(videoAddress);
}

I've searched for hours and haven't been able to find a solution. I would expect that Android, if the audio codec isn't supported, would simply pass it through so that something else down the chain could decode it. Maybe I don't fully understand how it works? Any help is greatly appreciated.

Euroclydon37
  • 667
  • 7
  • 20

1 Answers1

0

If the audio codec isn't available on the device then there's no way for Android MediaPlayer to decode it. LibVLC can convert audio to LPCM. Also, I believe ExoPlayer supports recoding audio but requires a lot more effort.

Redshirt
  • 664
  • 7
  • 25
  • I know that the device supports it because I tested with VLC. Ac3 played fine with that. – Euroclydon37 Sep 26 '16 at 17:53
  • What is the device? – Redshirt Sep 26 '16 at 17:54
  • It's a Sony Bravia TV. I've got it connected to a Sony Receiver. Also, aac is listed on Android's developer site as natively supported up to 5.1 surround, but only getting stereo confused me. Ffmpeg confirms the file is 5.1. – Euroclydon37 Sep 26 '16 at 17:59
  • The AC3 track playing with VLC isn't a good indication of what the device supports. VLC more than likely output the audio as LPCM rather than passthrough the AC3. Did your receiver show the audio format it was processing? – Redshirt Sep 26 '16 at 18:15
  • For ac3, it doesn't say. With aac, it says linear PCM. Not sure why it's being converted if Android natively supports it up to 5.1. – Euroclydon37 Sep 26 '16 at 18:24
  • I misunderstood your question. When testing with VLC, it said Dolby Digital. With my application, is was as described in my comment above. – Euroclydon37 Sep 26 '16 at 18:58
  • Actually, I was incorrect. VLC plays ac3 5.1 on the NVidia Shield... NOT the TV. It converts to LPCM on the Tv. But the TV's stock player doesn't convert it. It plays it correctly. – Euroclydon37 Sep 26 '16 at 20:27