我有类似的问题,只有在播放视频并且我想开始另一个视频(或导航到自动播放视频的新页面)时。设备无法重复使用编解码器。
在logcat中我发现:
2022-03-10 10:05:31.636 9471-19121/* E/ACodec: [OMX.qcom.video.decoder.avc] configureCodec returning error -12
2022-03-10 10:05:31.636 9471-19121/* E/ACodec: signalError(omxError 0x80001001, internalError -12)
2022-03-10 10:05:31.636 9471-19120/* E/MediaCodec: Codec reported err 0xfffffff4, actionCode 0, while in state 3
2022-03-10 10:05:31.642 9471-19120/* E/MediaCodec: Codec reported err 0xffffec77, actionCode 0, while in state 0
2022-03-10 10:05:31.642 9471-12750/* E/cr_MediaCodecBridge: Cannot configure the video codec
android.media.MediaCodec$CodecException: Error 0xfffffff4
at android.media.MediaCodec.native_configure(Native Method)
at android.media.MediaCodec.configure(MediaCodec.java:2127)
at android.media.MediaCodec.configure(MediaCodec.java:2043)
at org.chromium.media.MediaCodecBridge.a(chromium-TrichromeWebViewGoogle.aab-stable-475810133:1)
at org.chromium.media.MediaCodecBridgeBuilder.createVideoDecoder(chromium-TrichromeWebViewGoogle.aab-stable-475810133:6)
此外,chrome 媒体日志显示:
FFmpegDemuxer: created video stream, config codec: h264, profile: h264 main, level: not available, alpha_mode: is_opaque, coded size: [1920,1080], visible rect: [0,0,1920,1080], natural size: [1920,1080], has extra data: true, encryption scheme: Unencrypted, rotation: 0°, flipped: 0, color space: {primaries:BT709, transfer:BT709, matrix:BT709, range:LIMITED}
FFmpegDemuxer: created audio stream, config codec: aac, profile: unknown, bytes_per_channel: 4, channel_layout: STEREO, channels: 2, samples_per_second: 48000, sample_format: Float 32-bit planar, bytes_per_frame: 8, seek_preroll: 0us, codec_delay: 0, has extra data: true, encryption scheme: Unencrypted, discard decoder delay: true, target_output_channel_layout: NONE, has aac extra data: true
Selected FFmpegAudioDecoder for audio decoding, config: codec: aac, profile: unknown, bytes_per_channel: 4, channel_layout: STEREO, channels: 2, samples_per_second: 48000, sample_format: Float 32-bit planar, bytes_per_frame: 8, seek_preroll: 0us, codec_delay: 0, has extra data: true, encryption scheme: Unencrypted, discard decoder delay: true, target_output_channel_layout: STEREO, has aac extra data: true
Selected MediaCodecVideoDecoder for video decoding, config: codec: h264, profile: h264 main, level: not available, alpha_mode: is_opaque, coded size: [1920,1080], visible rect: [0,0,1920,1080], natural size: [1920,1080], has extra data: true, encryption scheme: Unencrypted, rotation: 0°, flipped: 0, color space: {primaries:BT709, transfer:BT709, matrix:BT709, range:LIMITED}
Entering Terminal State: Unable to allocate codec
video decoder fallback after initial decode error.
Failed to initialize VpxVideoDecoder
Failed to initialize Dav1dVideoDecoder
video decoder reinitialization failed
解决方案是在清理时卸载视频,以便下一个视频播放可以重用(实际上用作新的)编解码器。
我的代码:
useEffect(() => {
return () => {
console.log('unmount video')
videoRef.current?.pause()
videoRef.current?.removeAttribute('src')
videoRef.current?.load()
console.log('video unmounted')
}
}, [videoRef])