media icon indicating copy to clipboard operation
media copied to clipboard

Video codec error

Open iiheng opened this issue 2 years ago • 3 comments

Version

Media3 1.2.0

More version details

No response

Devices that reproduce the issue

xiaomi note 12 Android 14

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Copy the video file into the app's own files
  2. play the video from the app's own video

Expected result

play the video the video smoothly

Actual result

 Access denied finding property "ro.vendor.audio.5k"
2023-11-24 12:47:33.600 11065-11199 BufferQueueProducer     com.wangyiheng.vcamsx                E  [SurfaceView[com.wangyiheng.vcamsx/com.wangyiheng.vcamsx.MainActivity]#10(BLAST Consumer)10](id:2b390000000e,api:0,p:-1,c:11065) dequeueBuffer: BufferQueue has no connected producer
2023-11-24 12:47:33.601 11065-12650 MediaCodecVideoRenderer com.wangyiheng.vcamsx                E  Video codec error
                                                                                                      java.lang.IllegalStateException
                                                                                                          at android.media.MediaCodec.native_queueInputBuffer(Native Method)
                                                                                                          at android.media.MediaCodec.queueInputBuffer(MediaCodec.java:2672)
                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecBufferEnqueuer.doQueueInputBuffer(AsynchronousMediaCodecBufferEnqueuer.java:227)
                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecBufferEnqueuer.doHandleMessage(AsynchronousMediaCodecBufferEnqueuer.java:200)
                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecBufferEnqueuer.access$000(AsynchronousMediaCodecBufferEnqueuer.java:47)
                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecBufferEnqueuer$1.handleMessage(AsynchronousMediaCodecBufferEnqueuer.java:96)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                          at android.os.Looper.loopOnce(Looper.java:210)
                                                                                                          at android.os.Looper.loop(Looper.java:299)
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)
2023-11-24 12:47:33.602 11065-12650 ExoPlayerImplInternal   com.wangyiheng.vcamsx                E  Playback error
                                                                                                      androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D4028, -1, null, [1080, 1782, 30.0, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=YES
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:608)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                          at android.os.Looper.loopOnce(Looper.java:210)
                                                                                                          at android.os.Looper.loop(Looper.java:299)
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                      Caused by: androidx.media3.exoplayer.video.MediaCodecVideoDecoderException: Decoder failed: c2.mtk.avc.decoder
                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1978)
                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:883)
                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:974)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1079)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:529)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                                          at android.os.Looper.loopOnce(Looper.java:210) 
                                                                                                          at android.os.Looper.loop(Looper.java:299) 
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67) 
                                                                                                      Caused by: java.lang.IllegalStateException
                                                                                                          at android.media.MediaCodec.native_queueInputBuffer(Native Method)
                                                                                                          at android.media.MediaCodec.queueInputBuffer(MediaCodec.java:2672)

Media

@Composable
fun HomeScreen() {
    val context = LocalContext.current
    val homeController = remember { HomeController() }
    val path = context.getExternalFilesDir(null)!!.absolutePath
    val file = File(path, "copied_video.mp4")
    val detailAlterShow = remember { mutableStateOf(false) }

    LaunchedEffect(Unit){
        homeController.init()
    }

    val selectVideoLauncher = rememberLauncherForActivityResult(
        contract = ActivityResultContracts.GetContent()
    ) { uri: Uri? ->
        uri?.let {
            homeController.copyVideoToAppDir(context,it)
        }
    }

    val requestPermissionLauncher = rememberLauncherForActivityResult(
        contract = ActivityResultContracts.RequestPermission(),
        onResult = { isGranted: Boolean ->
            if (isGranted) {
                selectVideoLauncher.launch("video/*")
            } else {
                // Handle permission denial
                Toast.makeText(context, "请打开设置允许读取文件夹权限", Toast.LENGTH_SHORT).show()
            }
        }
    )

    Box(
        modifier = Modifier.fillMaxSize().background(Color(255,255,255,1)),
        contentAlignment = Alignment.Center,

    ) {
        Column(
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier = Modifier.width(150.dp)
        ) {
            // 使按钮宽度等于列的最大宽度

            if (detailAlterShow.value) {
                val exoPlayer = remember {
                    ExoPlayer.Builder(context).build().apply {
                        // 配置 ExoPlayer,例如设置媒体源等
                        val mediaItem = MediaItem.fromUri(Uri.fromFile(file))
                        setMediaItem(mediaItem)
                        prepare()
                    }
                }

                Dialog(
                    onDismissRequest = {
                        detailAlterShow.value = false
                        exoPlayer.release() // 释放播放器资源
                    }
                ) {
                    Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) {
                        AndroidView(
                            factory = { context ->
                                PlayerView(context).apply {
                                    player = exoPlayer
                                }
                            },
                            modifier = Modifier
                                .fillMaxWidth()
                                .aspectRatio(16f / 9f) // 根据视频的比例调整
                        )

                        Spacer(modifier = Modifier.height(16.dp))

//                        Button(onClick = {
//                            detailAlterShow.value = false
//                            exoPlayer.release() // 关闭时释放播放器资源
//                        }) {
//                            Text("关闭")
//                        }
                    }
                }
            }




            Button(
                modifier = Modifier.fillMaxWidth(),
                onClick = {
                    requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
                }
            ) {
                Text("选择视频")
            }
            Button(
                modifier = Modifier.fillMaxWidth(),
                onClick = {
                    detailAlterShow.value = true
                }
            ) {
                Text("查看视频")
            }
            Row(
                verticalAlignment = Alignment.CenterVertically, // 对齐文本和开关
                modifier = Modifier.fillMaxWidth() // 拉伸以匹配按钮宽度
            ) {
                Text("视频开关:", modifier = Modifier.weight(1f)) // 权重使文本占据大部分空间
                Switch(
                    checked = homeController.isVideoEnabled.value,
                    onCheckedChange = {
                        homeController.isVideoEnabled.value = it
                        homeController.saveState()
                        Toast.makeText(context, if (it) "视频打开" else "视频关闭", Toast.LENGTH_SHORT).show()
                    }
                )
            }

            Row(
                verticalAlignment = Alignment.CenterVertically, // 对齐文本和开关
                modifier = Modifier.fillMaxWidth() // 拉伸以匹配按钮宽度
            ) {
                Text("音量开关:", modifier = Modifier.weight(1f)) // 权重使文本占据大部分空间
                Switch(
                    checked = homeController.isVolumeEnabled.value,
                    onCheckedChange = {
                        homeController.isVolumeEnabled.value = it
                        homeController.saveState()
                        Toast.makeText(context, if (it) "声音打开" else "声音关闭", Toast.LENGTH_SHORT).show()
                    }
                )
            }
        }
    }
}

@Preview
@Composable
fun PreviewMessageCard() {
    HomeScreen()
}

Bug Report

  • [X] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

iiheng avatar Nov 24 '23 05:11 iiheng

Hi @iiheng,

Looks like, we haven't received your bug report yet. Also it will be more helpful if you can share the media you've seen has this problem with us. Could you please send them to [email protected] with the subject Issue #835. Please also update this issue to indicate you've done this.

Thanks!

tianyif avatar Nov 24 '23 13:11 tianyif

Exoplayer seems to only support hard decoding. The hardware code will go wrong on the Tianji processor, but there will be no problem on the Snapdragon processor. The main thing is how to set up the soft decoding.

iiheng avatar Dec 08 '23 03:12 iiheng

Getting the same error with Flutter on handful of devis - OP Nord N30 5G, Galaxy A03

PlatformException(VideoError, Video player had error o1.m: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D4028, -1, null, [2560, 1440, 25.0, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false)], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES, , null)

mikeb2k avatar Feb 14 '24 12:02 mikeb2k

Getting the similar error many time on flutter when try to display video using video in home page in debug mode

packages : video_player: ^2.8.3 video_player_web: ^2.1.3


W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"
W/libc    (11633): Access denied finding property "ro.vendor.audio.5k"

mrsalesi avatar Apr 06 '24 07:04 mrsalesi