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.75k stars 6.03k forks source link

Failed to initialize decoder: c2.android.mpeg4.decoder #7984

Closed adamstyrc closed 4 years ago

adamstyrc commented 4 years ago

[REQUIRED] Issue description

On Pixel 3 and probably 3a (Android 10) some mp4 videos cannot be played because of failed decoder initialization. On other android os or devices, they work. They also work on iOS and desktop. Link to video: https://cdn.vidcamera.io/videos/78/22/55/88/5f5b902f7fc0061dc0b5e4e6/78225588-e2ca-4fa7-9a39-aa5b0a1bd09c.mp4

[REQUIRED] Reproduction steps

Use demo ExoPlayer version e.g. 2.12.0 or any older and try to play a video https://cdn.vidcamera.io/videos/78/22/55/88/5f5b902f7fc0061dc0b5e4e6/78225588-e2ca-4fa7-9a39-aa5b0a1bd09c.mp4

[REQUIRED] Link to test content

https://cdn.vidcamera.io/videos/78/22/55/88/5f5b902f7fc0061dc0b5e4e6/78225588-e2ca-4fa7-9a39-aa5b0a1bd09c.mp4

[REQUIRED] A full bug report captured from the device

2020-09-24 16:46:32.656 24875-24950/com.example.testapp D/CCodec: allocate(c2.android.mpeg4.decoder) 2020-09-24 16:46:32.658 24875-24950/com.example.testapp I/Codec2Client: Available Codec2 services: "default" "software" 2020-09-24 16:46:32.658 24875-24950/com.example.testapp I/Codec2Client: Creating a Codec2 client to service "default" 2020-09-24 16:46:32.660 24875-24950/com.example.testapp I/Codec2Client: Client to Codec2 service "default" created 2020-09-24 16:46:32.661 24875-24950/com.example.testapp I/CCodec: setting up 'default' as default (vendor) store 2020-09-24 16:46:32.661 24875-24950/com.example.testapp I/Codec2Client: Creating a Codec2 client to service "default" 2020-09-24 16:46:32.662 24875-24950/com.example.testapp I/Codec2Client: Client to Codec2 service "default" created 2020-09-24 16:46:32.665 24875-24950/com.example.testapp E/Codec2Client: createComponent(c2.android.mpeg4.decoder) -- call failed: NOT_FOUND. 2020-09-24 16:46:32.665 24875-24950/com.example.testapp I/Codec2Client: Creating a Codec2 client to service "software" 2020-09-24 16:46:32.669 24875-24950/com.example.testapp I/Codec2Client: Client to Codec2 service "software" created 2020-09-24 16:46:32.736 24875-24950/com.example.testapp I/CCodec: Created component [c2.android.mpeg4.decoder] 2020-09-24 16:46:32.736 24875-24950/com.example.testapp D/CCodecConfig: read media type: video/mp4v-es 2020-09-24 16:46:32.739 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.max-count.values 2020-09-24 16:46:32.739 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.subscribed-indices.values 2020-09-24 16:46:32.739 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: input.buffers.allocator-ids.values 2020-09-24 16:46:32.739 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.allocator-ids.values 2020-09-24 16:46:32.739 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.allocator-ids.values 2020-09-24 16:46:32.740 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.pool-ids.values 2020-09-24 16:46:32.740 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.pool-ids.values 2020-09-24 16:46:32.745 24875-24950/com.example.testapp D/ReflectedParamUpdater: ignored struct field coded.color-format.locations 2020-09-24 16:46:32.746 24875-24950/com.example.testapp D/CCodecConfig: ignoring local param raw.size (0xd2001800) as it is already supported 2020-09-24 16:46:32.746 24875-24950/com.example.testapp D/ReflectedParamUpdater: ignored struct field raw.hdr-static-info.mastering 2020-09-24 16:46:32.746 24875-24950/com.example.testapp I/CCodecConfig: query failed after returning 9 values (BAD_INDEX) 2020-09-24 16:46:32.746 24875-24950/com.example.testapp D/CCodecConfig: c2 config diff is Dict { c2::u32 coded.pl.level = 16388 c2::u32 coded.pl.profile = 12297 c2::u32 input.buffers.max-size.value = 3133440 c2::u32 input.delay.value = 0 string input.media-type.value = "video/mp4v-es" c2::u32 output.delay.value = 1 string output.media-type.value = "video/raw" c2::u32 raw.color.matrix = 0 c2::u32 raw.color.primaries = 0 c2::u32 raw.color.range = 0 c2::u32 raw.color.transfer = 0 c2::u32 raw.max-size.height = 1088 c2::u32 raw.max-size.width = 1920 c2::u32 raw.pixel-format.value = 35 c2::i32 raw.rotation.flip = 0 c2::i32 raw.rotation.value = 0 c2::u32 raw.sar.height = 1 c2::u32 raw.sar.width = 1 c2::u32 raw.size.height = 144 c2::u32 raw.size.width = 176 c2::u32 raw.surface-scaling.value = 1 } 2020-09-24 16:46:32.746 24875-24950/com.example.testapp W/ColorUtils: expected specified color aspects (0:0:0:0) 2020-09-24 16:46:32.748 24875-24949/com.example.testapp D/SurfaceUtils: connecting to surface 0x7458cfc010, reason connectToSurface 2020-09-24 16:46:32.749 24875-24949/com.example.testapp I/MediaCodec: [c2.android.mpeg4.decoder] setting surface generation to 25472001 2020-09-24 16:46:32.749 24875-24949/com.example.testapp D/SurfaceUtils: disconnecting from surface 0x7458cfc010, reason connectToSurface(reconnect) 2020-09-24 16:46:32.749 24875-24949/com.example.testapp D/SurfaceUtils: connecting to surface 0x7458cfc010, reason connectToSurface(reconnect) 2020-09-24 16:46:32.749 24875-24950/com.example.testapp D/CCodecConfig: no c2 equivalents for native-window 2020-09-24 16:46:32.750 24875-24950/com.example.testapp D/CCodecConfig: config failed => CORRUPTED 2020-09-24 16:46:32.750 24875-24950/com.example.testapp D/CCodecConfig: Bad parameter value 2020-09-24 16:46:32.750 24875-24950/com.example.testapp D/CCodecConfig: c2 config diff is c2::u32 input.buffers.max-size.value = 1175040 c2::u32 raw.max-size.width = 720 c2::u32 raw.size.width = 720 2020-09-24 16:46:32.751 24875-24950/com.example.testapp W/CCodec: failed to configure c2 params 2020-09-24 16:46:32.751 24875-24949/com.example.testapp E/MediaCodec: Codec reported err 0xffffffea, actionCode 0, while in state 3 2020-09-24 16:46:32.755 24875-24949/com.example.testapp D/SurfaceUtils: disconnecting from surface 0x7458cfc010, reason disconnectFromSurface 2020-09-24 16:46:32.756 24875-24938/com.example.testapp E/MediaCodec: configure failed with err 0xffffffea, resetting... 2020-09-24 16:46:32.767 24875-24950/com.example.testapp D/CCodec: allocate(c2.android.mpeg4.decoder) 2020-09-24 16:46:32.767 24875-24950/com.example.testapp I/Codec2Client: Creating a Codec2 client to service "default" 2020-09-24 16:46:32.768 24875-24950/com.example.testapp I/Codec2Client: Client to Codec2 service "default" created 2020-09-24 16:46:32.769 24875-24950/com.example.testapp I/CCodec: setting up 'default' as default (vendor) store 2020-09-24 16:46:32.777 24875-24950/com.example.testapp I/CCodec: Created component [c2.android.mpeg4.decoder] 2020-09-24 16:46:32.777 24875-24950/com.example.testapp D/CCodecConfig: read media type: video/mp4v-es 2020-09-24 16:46:32.779 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.max-count.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.subscribed-indices.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: input.buffers.allocator-ids.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.allocator-ids.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.allocator-ids.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.pool-ids.values 2020-09-24 16:46:32.780 24875-24950/com.example.testapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.pool-ids.values 2020-09-24 16:46:32.781 24875-24950/com.example.testapp D/ReflectedParamUpdater: ignored struct field coded.color-format.locations 2020-09-24 16:46:32.781 24875-24950/com.example.testapp D/CCodecConfig: ignoring local param raw.size (0xd2001800) as it is already supported 2020-09-24 16:46:32.781 24875-24950/com.example.testapp D/ReflectedParamUpdater: ignored struct field raw.hdr-static-info.mastering 2020-09-24 16:46:32.782 24875-24950/com.example.testapp I/CCodecConfig: query failed after returning 9 values (BAD_INDEX) 2020-09-24 16:46:32.782 24875-24950/com.example.testapp D/CCodecConfig: c2 config diff is Dict { c2::u32 coded.pl.level = 16388 c2::u32 coded.pl.profile = 12297 c2::u32 input.buffers.max-size.value = 3133440 c2::u32 input.delay.value = 0 string input.media-type.value = "video/mp4v-es" c2::u32 output.delay.value = 1 string output.media-type.value = "video/raw" c2::u32 raw.color.matrix = 0 c2::u32 raw.color.primaries = 0 c2::u32 raw.color.range = 0 c2::u32 raw.color.transfer = 0 c2::u32 raw.max-size.height = 1088 c2::u32 raw.max-size.width = 1920 c2::u32 raw.pixel-format.value = 35 c2::i32 raw.rotation.flip = 0 c2::i32 raw.rotation.value = 0 c2::u32 raw.sar.height = 1 c2::u32 raw.sar.width = 1 c2::u32 raw.size.height = 144 c2::u32 raw.size.width = 176 c2::u32 raw.surface-scaling.value = 1 } 2020-09-24 16:46:32.782 24875-24950/com.example.testapp W/ColorUtils: expected specified color aspects (0:0:0:0) 2020-09-24 16:46:32.788 24875-24938/com.example.testapp W/MediaCodecRenderer: Failed to initialize decoder: c2.android.mpeg4.decoder java.lang.IllegalArgumentException at android.media.MediaCodec.native_configure(Native Method) at android.media.MediaCodec.configure(MediaCodec.java:2024) at android.media.MediaCodec.configure(MediaCodec.java:1952) at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.configure(SynchronousMediaCodecAdapter.java:43) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.configureCodec(MediaCodecVideoRenderer.java:580) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1126) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1023) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:589) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1448) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:640) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:977) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:829) at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:892) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:467) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) 2020-09-24 16:46:32.789 24875-24938/com.example.testapp D/MediaCodecInfo: NoSupport [sizeAndRate.support, 720x1280x29.130435943603516] [c2.android.mpeg4.decoder, video/mp4v-es] [blueline, Pixel 3, Google, 29] 2020-09-24 16:46:32.790 24875-24938/com.example.testapp E/ExoPlayerImplInternal: Playback error com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/mp4v-es, null, -1, null, [720, 1280, 29.130436], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:542) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: c2.android.mpeg4.decoder, Format(1, null, null, video/mp4v-es, null, -1, null, [720, 1280, 29.130436], [-1, -1]) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1030) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:589) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1448) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:640) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:977) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:829) at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:892) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:467) at android.os.Handler.dispatchMessage(Handler.java:103)  at android.os.Looper.loop(Looper.java:214)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.lang.IllegalArgumentException at android.media.MediaCodec.native_configure(Native Method) at android.media.MediaCodec.configure(MediaCodec.java:2024) at android.media.MediaCodec.configure(MediaCodec.java:1952) at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.configure(SynchronousMediaCodecAdapter.java:43) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.configureCodec(MediaCodecVideoRenderer.java:580) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1126) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1023) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:589)  at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1448)  at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:640)  at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:977)  at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:829)  at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:892)  at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:467)  at android.os.Handler.dispatchMessage(Handler.java:103)  at android.os.Looper.loop(Looper.java:214)  at android.os.HandlerThread.run(HandlerThread.java:67) 

[REQUIRED] Version of ExoPlayer being used

2.12.0

[REQUIRED] Device(s) and version(s) of Android being used

Google Pixel 3 - Android 10 QQ3A.200805.001

veljkomih commented 4 years ago

From this log there is a problem with parameters passed to MediaCodec. Some mandatory fields are probably missing for Video decoding. Here is the list of all necessary parameters (those that don't have optional next to, are mandatory) https://developer.android.com/reference/android/media/MediaFormat. I've checked in the AOSP code, these params are the only mandatory in a place where your app threw exception. Also, while inspecting the .mp4 you posted, it is encoded in apple specific codecs, which are unlikely to play by default on Android devices. I guess most manufacturers have that support like Samsung, but my guess that since Pixel3 is vanila Android device, it doesn't have that support. image

adamstyrc commented 4 years ago

The video was encoded with Flutter FFmpeg on that Pixel 3, to my dismay 😄

@veljkomih So do I understand you right, that adding some decoding mandatory fields would seal the deal? Or no matter what I do, trying to launch it with Pixel 3 Android native codecs will result with a failure?

andrewlewis commented 4 years ago

I think it's likely that this video is too high resolution for the decoder (720 * 1280):

com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/mp4v-es, null, -1, null, [720, 1280, 29.130436], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES

On the device I'm testing on this software MPEG 4 decoder only advertises support up to 352 * 288 pixels. Is it an option to change the video format to something more widely supported like H.264/AVC?

Side note: encoding portrait videos like this as landscape videos with rotation metadata may also help compatibility.

veljkomih commented 4 years ago

Yes, I think by adding those fields will definitely fix your exception. Will it play though, I'm not sure 100% sure.

adamstyrc commented 4 years ago

Ok, I will play with the resolution :)

Unfortunately using H.264 - which ffmpeg has inside when using another package - requires a GPL license which is not viable for me at the moment or pay for every video which is even worse :(

Thanks! :)

andrewlewis commented 4 years ago

Unfortunately using H.264 - which ffmpeg has inside when using another package - requires a GPL license which is not viable for me at the moment or pay for every video which is even worse :(

Can you use Android platform APIs to encode the video (MediaCodec), instead of bundling a software encoder?

Alternatively, encoding to a format like VP9 may be an option if you're happy with software video decoding on devices that don't have a hardware decoder for it.