android - Why does Media3 Transformer never finish transforming when my video is larger than 3 seconds? - Stack Overflow

I am trying to use media3 transformer to replace FFMPEG Kit which is being retired and it does work but

I am trying to use media3 transformer to replace FFMPEG Kit which is being retired and it does work but only on videos that are around 2-3 seconds. If your video is larger than that it never finishes the transformation.

I reached out to Google's Github but they felt it was an app issue and never could resolve it.

It is supposed to show onCompleted or onError but it never will and gets hung infinitely.

                    val effect = arrayListOf<Effect>()

//                    effect.add(
//                        Presentation.createForHeight(
//                            1080
//                        )
//                    )

                    val transformer = with(
                        Transformer.Builder(context)
                    ) {
                        addListener(object : Transformer.Listener {
                            override fun onCompleted(
                                composition: Composition,
                                exportResult: ExportResult
                            ) {
                                Log.d("CameraForShotScreen", "onCompleted")

                            }

                            override fun onError(
                                composition: Composition,
                                exportResult: ExportResult,
                                exportException: ExportException
                            ) {
                                Log.d(
                                    "CameraForShotScreen",
                                    "errorCode = ${exportException.errorCode}"
                                )
                                Log.d("CameraForShotScreen", "onError - $exportException")
                                userViewModel.saveData(
                                    mutableMapOf(
                                        "id" to (yourUserId ?: ""),
                                        "isSendingShot" to false
                                    ),
                                    mutableMapOf<String, Uri>(), // Empty mediaItems map
                                    context
                                ) {}
                            }
                        })
                        setVideoMimeType(MimeTypes.VIDEO_H264)
                        setMaxDelayBetweenMuxerSamplesMs(C.TIME_UNSET) // Allows unlimited delay
//                        setEncoderFactory(
//                            DefaultEncoderFactory.Builder(context)
//                                .setRequestedVideoEncoderSettings(
//                                    VideoEncoderSettings.Builder()
//                                        .setBitrate(4 * 1024 * 1024)
//                                        .build()
//                                )
//                                .build()
//                        )
                        build()
                    }

                    val inputMediaItem = MediaItem.fromUri(input)
                    val editedMediaItem = EditedMediaItem.Builder(inputMediaItem).apply {
                        setEffects(Effects(mutableListOf(), effect))
                    }

                    transformer.start(editedMediaItem.build(), file.absolutePath)
                }

Does anyone have an idea as to how I can fix this?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744741004a4591025.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信