ExoPlayer doesn't play mp4 with AC-3 audio track
Hello,
This media
http://pmd307538tn.download.theplatform.com.edgesuite.net/PDK_(VMS)/641/646/The_Amazing_Spider-Man_2_Trailer_1_5.1-480p-HDTN.mp4
has 5.1 channel audio, ExoPlayer crashes while trying to play it with this exception
W/AudioPolicyManager( 184): getOutput() could not find output for stream 3, samplingRate 48000,format 150994944, channels 3f, flags 1
E/AudioTrack( 766): Could not get audio output for stream type -1, usage 1, sample rate 48000, format 0x9000000, channel mask 0x3f, flags 0x1
E/AudioTrack-JNI( 766): Error -22 initializing AudioTrack
E/android.media.AudioTrack( 766): Error code -20 when initializing AudioTrack.
E/ExoPlayerImplInternal( 766): Internal track renderer error.
E/ExoPlayerImplInternal( 766): com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.audio.AudioTrack$InitializationException: AudioTrack init failed: 0, Config(48000, 252, 144000)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.MediaCodecAudioTrackRenderer.processOutputBuffer(MediaCodecAudioTrackRenderer.java:274)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.drainOutputBuffer(MediaCodecTrackRenderer.java:846)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:502)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:401)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203)
E/ExoPlayerImplInternal( 766): at android.os.Handler.dispatchMessage(Handler.java:98)
E/ExoPlayerImplInternal( 766): at android.os.Looper.loop(Looper.java:135)
E/ExoPlayerImplInternal( 766): at android.os.HandlerThread.run(HandlerThread.java:61)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
E/ExoPlayerImplInternal( 766): Caused by: com.google.android.exoplayer.audio.AudioTrack$InitializationException: AudioTrack init failed: 0, Config(48000, 252, 144000)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.audio.AudioTrack.checkAudioTrackInitialized(AudioTrack.java:721)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:289)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:263)
E/ExoPlayerImplInternal( 766): at com.google.android.exoplayer.MediaCodecAudioTrackRenderer.processOutputBuffer(MediaCodecAudioTrackRenderer.java:269)
E/ExoPlayerImplInternal( 766): ... 8 more
E/ExoEventLogger( 766): internalError [0.39, audioTrackInitializationError]
E/ExoEventLogger( 766): com.google.android.exoplayer.audio.AudioTrack$InitializationException: AudioTrack init failed: 0, Config(48000, 252, 144000)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.checkAudioTrackInitialized(AudioTrack.java:721)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:289)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:263)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecAudioTrackRenderer.processOutputBuffer(MediaCodecAudioTrackRenderer.java:269)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.drainOutputBuffer(MediaCodecTrackRenderer.java:846)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:502)
E/ExoEventLogger( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:401)
E/ExoEventLogger( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203)
E/ExoEventLogger( 766): at android.os.Handler.dispatchMessage(Handler.java:98)
E/ExoEventLogger( 766): at android.os.Looper.loop(Looper.java:135)
E/ExoEventLogger( 766): at android.os.HandlerThread.run(HandlerThread.java:61)
E/ExoEventLogger( 766): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
E/ExoEventLogger( 766): playerFailed [0.39]
E/ExoEventLogger( 766): com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.audio.AudioTrack$InitializationException: AudioTrack init failed: 0, Config(48000, 252, 144000)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecAudioTrackRenderer.processOutputBuffer(MediaCodecAudioTrackRenderer.java:274)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.drainOutputBuffer(MediaCodecTrackRenderer.java:846)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:502)
E/ExoEventLogger( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:401)
E/ExoEventLogger( 766): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203)
E/ExoEventLogger( 766): at android.os.Handler.dispatchMessage(Handler.java:98)
E/ExoEventLogger( 766): at android.os.Looper.loop(Looper.java:135)
E/ExoEventLogger( 766): at android.os.HandlerThread.run(HandlerThread.java:61)
E/ExoEventLogger( 766): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
E/ExoEventLogger( 766): Caused by: com.google.android.exoplayer.audio.AudioTrack$InitializationException: AudioTrack init failed: 0, Config(48000, 252, 144000)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.checkAudioTrackInitialized(AudioTrack.java:721)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:289)
E/ExoEventLogger( 766): at com.google.android.exoplayer.audio.AudioTrack.initialize(AudioTrack.java:263)
E/ExoEventLogger( 766): at com.google.android.exoplayer.MediaCodecAudioTrackRenderer.processOutputBuffer(MediaCodecAudioTrackRenderer.java:269)
E/ExoEventLogger( 766): ... 8 more
D/ExoEventLogger( 766): state [0.40, false, I]
The same media plays in Android standard MediaPlayer but with no audio. Is there any way to mix channels into stereo (or whatever is supported by device) or at least don't let ExoPlayer to fail and play video only like MediaPlayer does.
Thanks.
Doesn't really matter device to device (haven't been able to play this media on any device I have) but still providing some device details Build: LMY48I Build fingerprint: 'google/razor/flo:5.1.1/LMY48I/2074855:user/release-keys' Bootloader: FLO-04.05
ExoPlayerVersion 1.3.3
The audio track is AC-3, which most Android devices don't support for on-device playback. See Andrew's reply to #620 for a description of the scenarios in which AC-3 is expected to work. AndroidTV devices also commonly provide AC-3 support. I tested your media on a Sony AndroidTV I had and playback is good there.
If you control the formats on the server side, then for mobile devices not connected to an A/V receiver you'd be best off fetching a version of the stream with a regular stereo audio track. If you deliver multi-channel audio it'll just get down-mixed to stereo anyway for output, wasting bandwidth and CPU. If you really want to deliver multi-channel for some other reason, multi-channel AAC should work.
Thanks for the quick answer, Is there any way so player at least doesn't crash? It seems like its nothing I can do about.
Thanks.
Hi @ojw28. I agree with your comments 100%, and would say the same thing if I could. However we enable customers to deliver what they want, and we're hoping to have a better experience than crashing when they do something that isn't supported, e.g. throw an error so we can put up a message that the media isn't supported because the current device doesn't support 5.1 audio.
And ideally it's up to us whether we play the file w/out audio in that scenario, or surface the error to the end user.
Also, i think the title change is little misleading. if calling an API method cause an app to crash, that's more significant than the API method failing w/out crashing.
- A stack trace appearing in the logs doesn't mean that anything crashed. The application isn't crashing in this case, because ExoPlayer is handling the exception internally. If you have a listener registered on your ExoPlayer instance, you should see an exception being propagated to the listener's onPlayerError method to tell you that something went wrong. If you call getCause() on the ExoPlaybackException that you receive, you should get a somewhat specific exception object (AudioTrack.InitializationException) that will give you a clue as to what went wrong and allow you to display an error message. So I don't think things are as bad as claimed above. Please clarify if you disagree or don't see this behavior. If you actually see the application crashing then the logs should look different to those above, so if you could provide them that would be useful.
- Yes, ideally we should play the media without audio (and also indicate that there was an unsupported audio track in the media). We're working on making this better as part of our multi-track improvement works.
- As an aside, note that it's not that the device doesn't support 5.1 audio. The device probably does support 5.1 AAC. It's specifically AC-3 that the device doesn't support. There are valid reasons why devices and/or applications may opt not to support AC-3. See for example this.
Thanks, for the clarification. That is exactly what happening. Closing this since we have response to original question.