pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.54k stars 772 forks source link

CameraX Integration #1389

Closed Panha-VTechs closed 7 months ago

Panha-VTechs commented 8 months ago

Hello there. May I know if im about to integrate the camerax package in this project, is there any sample process i could follow to achieve this ?

Thanks

pedroSG94 commented 8 months ago

Hello,

You have 2 ways to implement it.

I recommend you use the last case but VideoSource is really recent and it is not uploaded to the last library version of gradle so you need compile the last commit of master using this gradle:

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'
Panha-VTechs commented 8 months ago

Thank you @pedroSG94

Panha-VTechs commented 8 months ago

Hello,

May I know If it's the same process to integrate cameraX with RtmpStreamClient or if there're other way to achieve this?

Thanks

pedroSG94 commented 8 months ago

I'm not sure I understand you but RtmpStreamClient is not related with CameraX integration.

Panha-VTechs commented 8 months ago

Hello,

If I use the second way to create VideoSource, how can I start preview and stream with cameraX in PreviewView. As I see there wasn't method to set Preview in RtrmStream, or if there'a other alternative for it.

Thanks

pedroSG94 commented 8 months ago

Hello,

You can attach a SurfaceView or TextureView like this: https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/rotation/StreamService.kt#L131 You need call prepareVideo before call that method: https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/base/StreamBase.kt#L197

Panha-VTechs commented 8 months ago

So you mean I don't need to used PreviewView from cameraX, just SurfaceView or TextureView, Is that right?

fun startPreview(surface: Surface, width: Int, height: Int) {
    if (!surface.isValid) throw IllegalArgumentException("Make sure the Surface is valid")
    isOnPreview = true
    if (!glInterface.running) glInterface.start()
    if (!videoSource.isRunning()) {
      videoSource.start(glInterface.surfaceTexture)
    }
    glInterface.attachPreview(surface)
    glInterface.setPreviewResolution(width, height)
}

as I see startPreview need Surface, but PreviewView in cameraX doesn't have surface. So I would like to know what way I should use?

Thanks

pedroSG94 commented 8 months ago

Hello,

This is a possible implementation of CameraX using a VideoSource:

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class CameraXSource(
    private val context: Context,
    private val lifecycleOwner: LifecycleOwner
): VideoSource() {

    private val cameraProviderFuture = ProcessCameraProvider.getInstance(context)
    private val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
    private var camera: Camera? = null
    private var preview = Preview.Builder()
        .setTargetResolution(Size(1280, 720))
        .build()

    override fun create(width: Int, height: Int, fps: Int): Boolean {
        preview = Preview.Builder()
            .setTargetResolution(Size(width, height))
            .build()
        return true
    }

    override fun start(surfaceTexture: SurfaceTexture) {
        cameraProviderFuture.addListener({
            try {
                val cameraSelector = CameraSelector.Builder()
                    .requireLensFacing(CameraSelector.LENS_FACING_BACK)
                    .build()

                preview.setSurfaceProvider {
                    it.provideSurface(Surface(surfaceTexture), Executors.newSingleThreadExecutor()) {
                    }
                }
                camera = cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, preview)
            } catch (e: ExecutionException) {
                // No errors need to be handled for this Future.
                // This should never be reached.
            } catch (ignored: InterruptedException) { }
        }, ContextCompat.getMainExecutor(context))
    }

    override fun stop() {
        camera?.let {
            cameraProvider.unbindAll()
            camera = null
        }
    }

    override fun release() {

    }

    override fun isRunning(): Boolean {
        return camera != null
    }
}

You only need use this video source in the constructor or change it using changeVideoSource method

Panha-VTechs commented 8 months ago

Hello,

When I used the above code and start preview. It crash with this message log: FATAL EXCEPTION: Thread-7 Process: com.pedro.streamer, PID: 2014 java.lang.RuntimeException: FrameBuffer uncompleted code: 36054 at com.pedro.encoder.input.gl.render.BaseRenderOffScreen.initFBO(BaseRenderOffScreen.java:95) at com.pedro.encoder.input.gl.render.BaseRenderOffScreen.initFBO(BaseRenderOffScreen.java:63) at com.pedro.encoder.input.gl.render.CameraRender.initGl(CameraRender.java:89) at com.pedro.encoder.input.gl.render.MainRender.initGl(MainRender.kt:48) at com.pedro.library.view.GlStreamInterface.run(GlStreamInterface.kt:157) at java.lang.Thread.run(Thread.java:1012)

pedroSG94 commented 8 months ago

Hello,

Did you try using rotation example? and replace this: https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/rotation/RotationExampleActivity.kt#L110

to:

service?.changeVideoSource(CameraXSource(applicationContext, this))

After that, you only need use the menu and press camera2 to use CameraX. I tested it this way.

If this is working you need check the difference. Maybe the problem is that you are not calling prepareVideo before startPreview

Panha-VTechs commented 8 months ago

Thank @pedroSG94. I can start the preview, but I got the other issue that it can not send the video and audio packet to server via rtmp. Is there any steps that I might miss it? Should I call prepareVideo and PrepareAudio again before start steaming?

image

pedroSG94 commented 8 months ago

Using StreamBase (RtmpStream). You only need call prepareVieo and prepareAudio one time. After that, you can call startStream, stopStream, startPreview, stopPreview, startRecord and stopRecord all times you want. For example:

val result = rtmpStream.prepareVideo(640, 480, 1200 * 1000) && rtmpStream.prepareAudio(44100, true, 128 * 1000)
    if (result) {
      rtmpStream.startPreview(surfaceview)
      rtmpStream.startStream(url)
      rtmpStream.stopPreview()
      rtmpStream.stopStream()

      rtmpStream.startRecord(path)
      rtmpStream.stopRecord()

      rtmpStream.startPreview(surfaceview)
    }

This sequence should work. You only need call prepareVideo or prepareAudio again if you want change the configuration. Remember that you need stop all before change the configuration.

I'm doing it like this in the rotation example

Panha-VTechs commented 8 months ago

Hello,

As I debug I see the problem cause when I call stopStream.

fun stopStream(): Boolean {
    isStreaming = false
    rtpStopStream()
    if (!isRecording) {
      stopSources()
      return prepareEncoders()
    }
    return true
  }
pedroSG94 commented 8 months ago

Hello,

Where is the problem?

Can you share code used and the error logcat to reproduce? Can you tell me the expected result?

Panha-VTechs commented 8 months ago

Hello, The problem is prepareEncoders() called again and again when I debug it. It show message as this image https://github.com/pedroSG94/RootEncoder/issues/1389#issuecomment-1923276969

Panha-VTechs commented 8 months ago

Hello, As I debug the process that I implemented on my project, The problem is when I call stopStream Multiple time.

pedroSG94 commented 8 months ago

Hello,

Ok, I will fix it to avoid problems in that case, like ignore the call if you aren't streaming. For now, you can check if you are streaming, recording or onPreview before call stop

Panha-VTechs commented 8 months ago

Thank you @pedroSG94, But now I got the other issue that I can not make camera show for the whole screen and video quality is also not good. Do you have any solution?

Thanks

pedroSG94 commented 8 months ago

Hello,

I can't help you without info about your code and a capture of the screen to check the problem. For now, you can check that you have the preview full screen. Also, if you want use full preview size cropping the image to fill instead of adjust the image to preview size. You can use this method:

rtmpStream.getGlInterface().setAspectRatioMode(AspectRatioMode.Fill) //using AspectRatioMode.Adjust by default

About the quality, you can increment the video quality using a higher resolution and using a higher video bitrate

Panha-VTechs commented 8 months ago

I've just got the other issue with samsung A52 5G. When I start stream it show this Screenshot 2024-02-05 at 4 33 19 in the afternoon

pedroSG94 commented 8 months ago

I need more info.

Can you tell me prepareVideo parameters used? Can you reproduce the error using my rotation app example? Can you share me a code example of your implementation?

Panha-VTechs commented 8 months ago

Okay, Here prepareVideo param

rtmpCameraX?.prepareVideo(width = width,height = height,bitrate = 1200 * 1024,fps = fps)

width and height have default value which 1920, 1080 and calculate from :

private fun calculateBestPreviewSize() {
        val aspMinList = mutableListOf<Float>()
        val aspMinListSecondary = mutableListOf<Float>()
        val mRtmpCameraX = rtmpCameraX ?: return
        val mFacing = facing ?: CameraSelector.DEFAULT_FRONT_CAMERA

        val resolutionSizes = mRtmpCameraX.getCameraResolutionSize(mFacing)
        val resolutionsSizesSecondary = mutableListOf<Size>()

        val metrics = context.resources.displayMetrics
        val deviceAsp = metrics.widthPixels.toFloat() / metrics.heightPixels.toFloat()

        for (size in resolutionSizes) {

            val asp = size.width.toFloat() / size.height.toFloat()
            if (size.width != 1920) {
                aspMinListSecondary.add(abs(deviceAsp - asp))
                resolutionsSizesSecondary.add(size)
            } else {
                aspMinList.add(abs(deviceAsp - asp))
            }
        }

        var minIndex = aspMinList.indexOf(aspMinList.minOrNull())

        if (minIndex == -1) {
            minIndex = aspMinListSecondary.indexOf(aspMinListSecondary.minOrNull())
            width = resolutionsSizesSecondary[minIndex].width
            height = resolutionsSizesSecondary[minIndex].height
        } else {
            width = resolutionSizes[minIndex].width
            height = resolutionSizes[minIndex].height
        }
 }

I called prepare in onSurfaceChange callback:

override fun surfaceChanged(
        surfaceHolder: SurfaceHolder,
        format: Int,
        mWidth: Int,
        mHeight: Int
    ) {
        if (!isPrepared) {
            val isPreparedAudio = rtmpCameraX?.prepareAudio() ?: false
            val isPreparedVideo = rtmpCameraX?.prepareVideo(
                width = width,
                height = height,
                bitrate = 1200 * 1024,
                fps = fps
            ) ?: false
            isPrepared = isPreparedAudio && isPreparedVideo
        }

        rtmpCameraX!!.getGlInterface().setAspectRatioMode(AspectRatioMode.Fill)
        rtmpCameraX?.safeStartPreview(mBinding.openGlView, width, height)

        FilterManager.filterRender?.let { filter ->
            setFilter(filter)
        }
    }

I setup rtmpCamraX like this

 rtmpCameraX = RtmpCameraXStream(context, mLifecycleOwner, this)
 rtmpCameraX!!.getStreamClient().setReTries(10)
 mBinding.openGlView.holder.addCallback(this)

RtmpCameraXStream class

class RtmpCameraXStream(
    context: Context,
    connectChecker: ConnectChecker,
    videoSource: VideoSource,
    audioSource: AudioSource,
) : StreamBase(context, videoSource, audioSource) {

    private companion object {
        const val TAG = "RtmpCameraXStream"
    }

    private var isAllowedToSendAudio = true

    private val rtmpClient = RtmpClient(connectChecker)
    private val streamClientListener = object : StreamClientListener {
        override fun onRequestKeyframe() {
            requestKeyframe()
        }
    }

    override fun getStreamClient(): RtmpStreamClient =
        RtmpStreamClient(rtmpClient, streamClientListener)

    constructor(
        context: Context,
        lifecycleOwner: LifecycleOwner,
        connectChecker: ConnectChecker
    ) : this(
        context,
        connectChecker,
        CameraXSource(context, lifecycleOwner),
        MicrophoneSource()
    )

    override fun setVideoCodecImp(codec: VideoCodec) {
        rtmpClient.setVideoCodec(codec)
    }

    override fun setAudioCodecImp(codec: AudioCodec) {
        rtmpClient.setAudioCodec(codec)
    }

    override fun audioInfo(sampleRate: Int, isStereo: Boolean) {
        rtmpClient.setAudioInfo(sampleRate, isStereo)
    }

    override fun rtpStartStream(endPoint: String) {
        val resolution = super.getVideoResolution()
        rtmpClient.setVideoResolution(resolution.width, resolution.height)
        rtmpClient.setFps(super.getVideoFps())
        rtmpClient.connect(endPoint)
    }

    override fun rtpStopStream() {
        rtmpClient.disconnect()
    }

    override fun onSpsPpsVpsRtp(sps: ByteBuffer, pps: ByteBuffer?, vps: ByteBuffer?) {
        rtmpClient.setVideoInfo(sps, pps, vps)
    }

    override fun getH264DataRtp(h264Buffer: ByteBuffer, info: MediaCodec.BufferInfo) {
        Log.d(TAG, "getH264DataRtp")
        rtmpClient.sendVideo(h264Buffer, info)
    }

    override fun getAacDataRtp(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo) {
        if (!isAllowedToSendAudio) return
        Log.d(TAG, "getAacDataRtp")
        rtmpClient.sendAudio(aacBuffer, info)
    }

    /**
     * called this method allow send audio data to server. if you set it to false,
     * you have to set it true back in order to send audio file. Default: true
     */
    fun setIsAllowedToSendAudio(isAllowed: Boolean) {
        isAllowedToSendAudio = isAllowed
    }

    fun getCameraResolutionSize(facing: CameraSelector): List<Size> {
        val mVideoSource = videoSource
        if (mVideoSource !is CameraXSource) return emptyList()
        return mVideoSource.getCameraResolutions(facing)
    }

    fun prepareAudio(): Boolean {
        return prepareAudio(sampleRate = 44100, isStereo = true, bitrate = 128 * 1024)
    }

    fun switchCamera() {
        val mVideoSource = videoSource
        if (mVideoSource !is CameraXSource) return
        mVideoSource.switchCamera()
    }

    fun safeStartPreview(surfaceView: SurfaceView, width: Int, height: Int) {
        if (isOnPreview || !surfaceView.holder.surface.isValid) return
        startPreview(surfaceView)
    }

    fun safeStopStream() {
        if (!isStreaming) return
        stopStream()
    }

    fun disableAudio() {
        val mAudioSource = audioSource
        if (mAudioSource !is MicrophoneSource) return
        mAudioSource.mute()
    }

    fun enableAudio() {
        val mAudioSource = audioSource
        if (mAudioSource !is MicrophoneSource) return
        mAudioSource.unMute()
    }
}

Here CameraXSource class:

class CameraXSource(
    private val context: Context,
    private val lifecycleOwner: LifecycleOwner,
) : VideoSource() {

    companion object {
        private const val TAG = "CameraXSource"
    }

    private val cameraProviderFuture = ProcessCameraProvider.getInstance(context)
    private var camera: Camera? = null

    private var preview = Preview.Builder()
        .setResolutionSelector(
            ResolutionSelector.Builder()
                .setResolutionStrategy(
                    ResolutionStrategy(
                        Size(1920, 1080),
                        ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER
                    )
                ).build()
        ).build()

    private var cameraSelector = CameraSelector.DEFAULT_FRONT_CAMERA

    override fun create(width: Int, height: Int, fps: Int): Boolean {
        preview = Preview.Builder()
            .setResolutionSelector(
                ResolutionSelector.Builder()
                    .setResolutionStrategy(
                        ResolutionStrategy(
                            Size(width, height),
                            ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER
                        )
                    ).build()
            ).build()
        this.width = width
        this.height = height
        this.fps = fps
        this.created = true
        return true
    }

    override fun start(surfaceTexture: SurfaceTexture) {
        this.surfaceTexture = surfaceTexture
        surfaceTexture.setDefaultBufferSize(width, height)
        bindPreview()
    }

    override fun stop() {
        releaseCamera()
    }

    override fun release() {
    }

    override fun isRunning(): Boolean = camera != null

    fun switchCamera() {
        executeCameraListenerAsync {
            when {
                cameraSelector == CameraSelector.DEFAULT_BACK_CAMERA && it.hasCamera(CameraSelector.DEFAULT_FRONT_CAMERA) -> {
                    cameraSelector = CameraSelector.DEFAULT_FRONT_CAMERA
                }

                cameraSelector == CameraSelector.DEFAULT_FRONT_CAMERA && it.hasCamera(CameraSelector.DEFAULT_BACK_CAMERA) -> {
                    cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
                }
            }
            bindPreview(it)
        }
    }

    private fun bindPreview() {
        executeCameraListenerAsync(::bindPreview)
    }

    private fun bindPreview(cameraProvider: ProcessCameraProvider) {
        surfaceTexture?.let { mSurfaceTexture ->
            preview.targetRotation = Surface.ROTATION_0
            preview.setSurfaceProvider {
                val executor = Executors.newSingleThreadExecutor()
                it.provideSurface(
                    Surface(mSurfaceTexture),
                    executor
                ) { result ->
                    Log.d(TAG, "Create surface provider: ${result.resultCode}")
                    executor.shutdown()
                }
            }
        }

        try {
            cameraProvider.unbindAll()
            camera = cameraProvider.bindToLifecycle(
                lifecycleOwner,
                cameraSelector,
                preview
            )
        } catch (e: Exception) {
            e.printStackTrace()
            Log.d(TAG, "Can not start camera with error: ${e.message}")
        }
    }

    private fun releaseCamera() {
        executeCameraListenerAsync { cameraProvider ->
            try {
                camera?.let {
                    cameraProvider.unbindAll()
                    camera = null
                }
            } catch (e: Exception) {
                e.printStackTrace()
                Log.d(TAG, "Error unbind camera with message: ${e.message}")
            }
        }
    }

    fun getCameraResolutions(facing: CameraSelector): List<Size> {
        try {
            val cameraCharacteristics =
                getCameraCharacteristicsByFacing(facing = facing) ?: return emptyList()
            val streamConfigurationMap = cameraCharacteristics.get(
                CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP
            ) ?: return emptyList()
            return streamConfigurationMap.getOutputSizes(
                SurfaceTexture::class.java
            )?.asList() ?: emptyList()
        } catch (e: Exception) {
            e.printStackTrace()
            Log.d(TAG, "Error getCameraResolutions: ${e.message}")
            return emptyList()
        }
    }

    private fun getCameraCharacteristicsByFacing(facing: CameraSelector): CameraCharacteristics? {
        val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
        val selectedFacing = getFacing(facing = facing)
        val selectedCameraId = cameraManager.cameraIdList.find {
            val cameraFacing =
                cameraManager.getCameraCharacteristics(it).get(CameraCharacteristics.LENS_FACING)
            cameraFacing != null && cameraFacing == selectedFacing
        } ?: return null
        return cameraManager.getCameraCharacteristics(selectedCameraId)
    }

    private fun getFacing(facing: CameraSelector): Int {
        return when (facing) {
            CameraSelector.DEFAULT_BACK_CAMERA -> CameraMetadata.LENS_FACING_BACK
            CameraSelector.DEFAULT_FRONT_CAMERA -> CameraMetadata.LENS_FACING_FRONT
            else -> throw Exception("Unknown camera facing")
        }
    }

    private fun executeCameraListenerAsync(action: (ProcessCameraProvider) -> Unit) {
        cameraProviderFuture.addListener({
            action.invoke(cameraProviderFuture.get())
        }, ContextCompat.getMainExecutor(context))
    }
}
pedroSG94 commented 8 months ago

Hello,

I was testing the code and the resolution get from your method could be the problem (the resolution is 4k, exactly 3264x2448 in my case). The error should be related with the Android version according with this post in exoplayer project (I can't reproduce it because I haven't a device with that patch version): https://github.com/google/ExoPlayer/issues/10661

I recommend you try to update your phone to the last available release as explained in the post, this should be fixed that way.

If you can't do it. Try to use a lower resolution like 1920x1080

Panha-VTechs commented 8 months ago

Thank you @pedroSG94, Now I lower the resolution and it work but I just got the other issue that I want to set bitrate on fly while streaming as the code below:

rtmpCameraX = RtmpCameraXStream(context, mLifecycleOwner, facing, this)
rtmpCameraX!!.getStreamClient().setReTries(10)
rtmpCameraX!!.setFpsListener {
      Log.d(TAG, "Fps: $it")
      //This means that if you have 15fps, bitrate = 1.5mb. 20 fps = 2mb.
      //30 fps is the limit so keep bitrate constant 3000000 * 30 / 30 = 3000000 (3mb)
      val bitrate = bitrateUsedInPrepareVideo * it / fps
      Log.d(TAG, "bitrate: $bitrate")
      rtmpCameraX?.setVideoBitrateOnFly(bitrate = bitrate)
}
mBinding.openGlView.holder.addCallback(this)

Here is the code I use:

fun setVideoBitrateOnFly(bitrate: Int) {
    try {
        Log.d(TAG, "Here")
        val privateVideoEncoderProperty = StreamBase::class.memberProperties.find {
            it.name == "videoEncoder"
        }
        Log.d(TAG, "Here 1")
        if (privateVideoEncoderProperty == null) {
            Log.d(TAG, "Cannot find VideoEncoder")
            return
        }
        Log.d(TAG, "Here 2")
        privateVideoEncoderProperty.isAccessible = true
        val videoEncoder = privateVideoEncoderProperty.get(this) as? VideoEncoder
        privateVideoEncoderProperty.isAccessible = false
        Log.d(TAG, "Here 3")
        if (videoEncoder == null) {
            Log.d(TAG, "Cannot cast private properties VideoEncoder")
            return
        }
        Log.d(TAG, "Here 4")
        videoEncoder.setVideoBitrateOnFly(bitrate)
    } catch (e: Exception) {
        e.printStackTrace()
        Log.d(TAG, "Error with message: ${e.message}")
    }
}

I use kotlin reflection to access video encoder in order to setBitrateOnFly, But the problem is that when it run on release it can not find video encoder and it crash. Do you have any solution? I also try set prograud as this too:

-keep class com.pedro.library.base.StreamBase {*;}
-keep class com.pedro.encoder.video.VideoEncoder {*;}
-keep class com.pedro.encoder.audio.AudioEncoder {*;}
pedroSG94 commented 8 months ago

Hello,

I will add the method to stream base soon and give you a gradle to use. I will try to do it this afternoon. Meanwhile, you can copy StreamBase and add the method yourself

Panha-VTechs commented 8 months ago

Okay thank you @pedroSG94

pedroSG94 commented 8 months ago

Added in this commit: https://github.com/pedroSG94/RootEncoder/commit/ee28e4d84b2f5043d383ec98de8fd19b0b0a431f I compiled the commit with setVideoBitrateOnFly in this commit:

  implementation 'com.github.pedroSG94.RootEncoder:library:ee28e4d84b'
Panha-VTechs commented 8 months ago

Hello,

I still got this issue but it only happen the third time I call prepareVideo. My samsung A52 5G device:

I've just got the other issue with samsung A52 5G. When I start stream it show this Screenshot 2024-02-05 at 4 33 19 in the afternoon

The other device that I tested with show like this:

MicrophoneManager       Microphone created, 44100hz, Stereo
AudioEncoder            2 encoders found
AudioEncoder            Encoder selected c2.android.aac.encoder
CCodec                  allocate(c2.android.aac.encoder)
CCodec                  Created component [c2.android.aac.encoder]
CCodecConfig            read media type: audio/mp4a-latm
ReflectedParamUpdater   extent() != 1 for single value type: algo.buffers.max-count.values
ReflectedParamUpdater   extent() != 1 for single value type: output.subscribed-indices.values
ReflectedParamUpdater   extent() != 1 for single value type: input.buffers.allocator-ids.values
ReflectedParamUpdater   extent() != 1 for single value type: output.buffers.allocator-ids.values
ReflectedParamUpdater   extent() != 1 for single value type: algo.buffers.allocator-ids.values
ReflectedParamUpdater   extent() != 1 for single value type: output.buffers.pool-ids.values
ReflectedParamUpdater   extent() != 1 for single value type: algo.buffers.pool-ids.values
CCodecConfig            query failed after returning 9 values (BAD_INDEX)
CCodecConfig            c2 config diff is Dict {
                          c2::u32 coded.bitrate.value = 64000
                          c2::u32 coded.pl.level = 0
                          c2::u32 coded.pl.profile = 8192
                          c2::u32 coding.aac-sbr-mode.value = 3
                          c2::u32 input.buffers.max-size.value = 2048
                          c2::u32 input.delay.value = 0
                          string input.media-type.value = "audio/raw"
                          string output.media-type.value = "audio/mp4a-latm"
                          c2::u32 raw.channel-count.value = 1
                          c2::u32 raw.sample-rate.value = 44100
                        }
MediaCodec              MediaCodec will operate in async mode
CCodec                  [c2.android.aac.encoder] buffers are bound to CCodec for this session
CCodecConfig            no c2 equivalents for aac-profile
CCodecConfig            no c2 equivalents for flags
CCodecConfig            no c2 equivalents for encoder
CCodecConfig            c2 config diff is   c2::u32 coded.bitrate.value = 131072
                          c2::u32 input.buffers.max-size.value = 4096
                          c2::u32 raw.channel-count.value = 2
Codec2Client            query -- param skipped: index = 1107298332.
CCodec                  setup formats input: AMessage(what = 0x00000000) = {
                          int32_t aac-sbr-mode = 3
                          int32_t channel-count = 2
                          int32_t max-input-size = 7104
                          string mime = "audio/raw"
                          int32_t sample-rate = 44100
                        } and output: AMessage(what = 0x00000000) = {
                          int32_t aac-sbr-mode = 3
                          int32_t bitrate = 131072
                          int32_t channel-count = 2
                          int32_t level = 0
                          int32_t max-bitrate = 131072
                          string mime = "audio/mp4a-latm"
                          int32_t profile = 2
                          int32_t sample-rate = 44100
                        }
AudioEncoder            prepared
VideoEncoder            3 encoders found
VideoEncoder            Encoder OMX.qcom.video.encoder.avc
VideoEncoder            Color supported: 2141391878
VideoEncoder            Color supported: 2141391876
VideoEncoder            Color supported: 2141391880
VideoEncoder            Color supported: 2141391879
VideoEncoder            Color supported: 2130708361
VideoEncoder            Encoder selected OMX.qcom.video.encoder.avc
OMXClient               IOmx service obtained
VideoEncoder            Prepare video info: SURFACE, 1920x1080
VideoEncoder            set bitrate mode CBR
MediaCodec              MediaCodec will operate in async mode
OMXUtils                do not know color format 0x7fa30c06 = 2141391878
OMXUtils                do not know color format 0x7fa30c04 = 2141391876
OMXUtils                do not know color format 0x7fa30c08 = 2141391880
OMXUtils                do not know color format 0x7fa30c07 = 2141391879
OMXUtils                do not know color format 0x7f000789 = 2130708361
ACodec                  setupAVCEncoderParameters with [profile: Baseline] [level: Level42]
ACodec                  [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
ACodec                  setupVideoEncoder succeeded
OMXUtils                do not know color format 0x7f000789 = 2130708361
VideoEncoder            prepared

Here're meassage I log with this code: CodecUtil.showAllCodecsInfo()

[----------------
Name: OMX.qcom.video.encoder.heic
Type: image/vnd.android.heic
Max instances: 6
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 100
CBR supported: false
VBR supported: false
CQ supported: true
----- -----
----- Video info -----
Supported colors: 
2141391878
2141391876
2141391872
2141391881
2141391882
2141391880
2141391879
2130708361
2135033992
21
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 4, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Bitrate range: 1 - 64000
Frame rate range: 1 - 20
Width range: 512 - 8192
Height range: 512 - 8192
----- -----
Max instances: 6
----------------
, ----------------
Name: OMX.qcom.video.decoder.avc
Type: video/avc
Max instances: 16
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 65536, level: 32768
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 524288, level: 32768
Profile: 8, level: 32768
Bitrate range: 1 - 100000000
Frame rate range: 1 - 240
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 16
----------------
, ----------------
Name: OMX.qcom.video.decoder.avc.secure
Type: video/avc
Max instances: 3
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 65536, level: 32768
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 524288, level: 32768
Profile: 8, level: 32768
Bitrate range: 1 - 40000000
Frame rate range: 1 - 60
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 3
----------------
, ----------------
Name: OMX.qti.video.decoder.h263sw
Type: video/3gpp
Max instances: 4
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
2141391876
21
Profile: 1, level: 128
Bitrate range: 1 - 16000000
Frame rate range: 1 - 30
Width range: 96 - 720
Height range: 96 - 576
----- -----
Max instances: 4
----------------
, ----------------
Name: OMX.qcom.video.decoder.hevc
Type: video/hevc
Max instances: 16
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 4, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Bitrate range: 1 - 100000000
Frame rate range: 1 - 240
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 16
----------------
, ----------------
Name: OMX.qcom.video.decoder.hevc.secure
Type: video/hevc
Max instances: 3
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 4, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Bitrate range: 1 - 40000000
Frame rate range: 1 - 60
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 3
----------------
, ----------------
Name: OMX.qti.video.decoder.mpeg4sw
Type: video/mp4v-es
Max instances: 4
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
2141391876
21
Profile: 1, level: 256
Profile: 32768, level: 128
Bitrate range: 1 - 12000000
Frame rate range: 12 - 30
Width range: 96 - 1344
Height range: 96 - 1344
----- -----
Max instances: 4
----------------
, ----------------
Name: OMX.qcom.video.decoder.vp9
Type: video/x-vnd.on2.vp9
Max instances: 6
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 1, level: 4096
Profile: 4, level: 4096
Profile: 4096, level: 4096
Profile: 16384, level: 4096
Bitrate range: 1 - 100000000
Frame rate range: 1 - 240
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 6
----------------
, ----------------
Name: OMX.qcom.video.decoder.vp9.secure
Type: video/x-vnd.on2.vp9
Max instances: 3
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2141391878
2135033992
2141391876
21
19
2141391877
6
Profile: 1, level: 4096
Profile: 4, level: 4096
Profile: 4096, level: 4096
Profile: 16384, level: 4096
Bitrate range: 1 - 40000000
Frame rate range: 1 - 60
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 3
----------------
, ----------------
Name: OMX.qcom.video.encoder.avc
Type: video/avc
Max instances: 16
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2141391878
2141391876
2141391872
2141391881
2141391882
2141391880
2141391879
2130708361
2135033992
21
Profile: 65536, level: 32768
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 524288, level: 32768
Profile: 8, level: 32768
Bitrate range: 1 - 100000000
Frame rate range: 1 - 240
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 16
----------------
, ----------------
Name: OMX.qcom.video.encoder.h263sw
Type: video/3gpp
Max instances: 3
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2141391876
2141391872
2130708361
2135033992
21
Profile: 1, level: 128
Bitrate range: 1 - 2000000
Frame rate range: 1 - 30
Width range: 96 - 720
Height range: 96 - 576
----- -----
Max instances: 3
----------------
, ----------------
Name: OMX.qcom.video.encoder.hevc
Type: video/hevc
Max instances: 16
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 100
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2141391878
2141391876
2141391872
2141391881
2141391882
2141391880
2141391879
2130708361
2135033992
21
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 4, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Bitrate range: 1 - 100000000
Frame rate range: 1 - 240
Width range: 128 - 4096
Height range: 128 - 4096
----- -----
Max instances: 16
----------------
, ----------------
Name: OMX.qcom.video.encoder.hevc.cq
Type: video/hevc
Max instances: 16
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 100
CBR supported: false
VBR supported: false
CQ supported: true
----- -----
----- Video info -----
Supported colors: 
2141391878
2141391876
2141391872
2141391881
2141391882
2141391880
2141391879
2130708361
2135033992
21
Profile: 1, level: 32768
Profile: 2, level: 32768
Profile: 4, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Bitrate range: 1 - 100000000
Frame rate range: 1 - 20
Width range: 128 - 512
Height range: 128 - 512
----- -----
Max instances: 16
----------------
, ----------------
Name: OMX.qcom.video.encoder.mpeg4sw
Type: video/mp4v-es
Max instances: 3
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2141391876
2141391872
2130708361
2135033992
21
Profile: 1, level: 128
Bitrate range: 1 - 8000000
Frame rate range: 12 - 30
Width range: 96 - 864
Height range: 96 - 864
----- -----
Max instances: 3
----------------
, ----------------
Name: c2.sec.amrnb.decoder
Type: audio/3gpp
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 4750 - 12200
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.amrwb.decoder
Type: audio/amr-wb
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 6600 - 23850
Channels supported: 1
Supported sample rate: 
16000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.flac.decoder
Type: audio/flac
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 1 - 21000000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.ima.decoder
Type: audio/x-ima
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 5000 - 384000
Channels supported: 2
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.mp3.decoder
Type: audio/mpeg
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 8000 - 320000
Channels supported: 2
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
Type: audio/mpeg-L1
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 8000 - 448000
Channels supported: 2
----- -----
Max instances: 32
Type: audio/mpeg-L2
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 8000 - 384000
Channels supported: 2
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.vc1.decoder
Type: video/wvc1
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2130708361
2135033992
19
21
20
39
Bitrate range: 1 - 64000
Frame rate range: 0 - 960
Width range: 32 - 2048
Height range: 32 - 2048
----- -----
Max instances: 32
Type: video/x-ms-wmv
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2130708361
2135033992
19
21
20
39
Bitrate range: 1 - 64000
Frame rate range: 0 - 960
Width range: 32 - 2048
Height range: 32 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.aac.decoder
Type: audio/mp4a-latm
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Profile: 2, level: 0
Profile: 5, level: 0
Profile: 29, level: 0
Profile: 23, level: 0
Profile: 39, level: 0
Profile: 20, level: 0
Profile: 42, level: 0
Bitrate range: 8000 - 510000
Channels supported: 8
Supported sample rate: 
7350
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.aac.decoder
Type: audio/mp4a-latm
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Profile: 2, level: 0
Profile: 5, level: 0
Profile: 29, level: 0
Profile: 23, level: 0
Profile: 39, level: 0
Profile: 20, level: 0
Profile: 42, level: 0
Bitrate range: 8000 - 510000
Channels supported: 8
Supported sample rate: 
7350
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.aac.encoder
Type: audio/mp4a-latm
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Audio info -----
Profile: 2, level: 0
Profile: 5, level: 0
Profile: 29, level: 0
Profile: 23, level: 0
Profile: 39, level: 0
Bitrate range: 8000 - 510000
Channels supported: 6
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.aac.encoder
Type: audio/mp4a-latm
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Audio info -----
Profile: 2, level: 0
Profile: 5, level: 0
Profile: 29, level: 0
Profile: 23, level: 0
Profile: 39, level: 0
Bitrate range: 8000 - 510000
Channels supported: 6
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.amrnb.decoder
Type: audio/3gpp
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 4750 - 12200
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.amrnb.decoder
Type: audio/3gpp
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 4750 - 12200
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.amrnb.encoder
Type: audio/3gpp
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: false
CQ supported: false
----- -----
----- Audio info -----
Bitrate range: 4750 - 12200
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.amrnb.encoder
Type: audio/3gpp
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: false
CQ supported: false
----- -----
----- Audio info -----
Bitrate range: 4750 - 12200
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.amrwb.decoder
Type: audio/amr-wb
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 6600 - 23850
Channels supported: 1
Supported sample rate: 
16000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.amrwb.decoder
Type: audio/amr-wb
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 6600 - 23850
Channels supported: 1
Supported sample rate: 
16000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.amrwb.encoder
Type: audio/amr-wb
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: false
CQ supported: false
----- -----
----- Audio info -----
Bitrate range: 6600 - 23850
Channels supported: 1
Supported sample rate: 
16000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.amrwb.encoder
Type: audio/amr-wb
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: false
CQ supported: false
----- -----
----- Audio info -----
Bitrate range: 6600 - 23850
Channels supported: 1
Supported sample rate: 
16000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.flac.decoder
Type: audio/flac
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 1 - 21000000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.flac.decoder
Type: audio/flac
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 1 - 21000000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.flac.encoder
Type: audio/flac
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 8
Quality range: 0 - 0
CBR supported: false
VBR supported: false
CQ supported: true
----- -----
----- Audio info -----
Bitrate range: 1 - 21000000
Channels supported: 2
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.flac.encoder
Type: audio/flac
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 8
Quality range: 0 - 0
CBR supported: false
VBR supported: false
CQ supported: true
----- -----
----- Audio info -----
Bitrate range: 1 - 21000000
Channels supported: 2
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.g711.alaw.decoder
Type: audio/g711-alaw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 64000 - 64000
Channels supported: 6
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.g711.alaw.decoder
Type: audio/g711-alaw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 64000 - 64000
Channels supported: 6
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.g711.mlaw.decoder
Type: audio/g711-mlaw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 64000 - 64000
Channels supported: 6
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.g711.mlaw.decoder
Type: audio/g711-mlaw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 64000 - 64000
Channels supported: 6
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.gsm.decoder
Type: audio/gsm
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 13000 - 13000
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.gsm.decoder
Type: audio/gsm
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 13000 - 13000
Channels supported: 1
Supported sample rate: 
8000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.mp3.decoder
Type: audio/mpeg
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 8000 - 320000
Channels supported: 2
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.mp3.decoder
Type: audio/mpeg
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 8000 - 320000
Channels supported: 2
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.opus.decoder
Type: audio/opus
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 6000 - 510000
Channels supported: 8
Supported sample rate: 
8000
12000
16000
24000
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.opus.decoder
Type: audio/opus
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 6000 - 510000
Channels supported: 8
Supported sample rate: 
8000
12000
16000
24000
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.opus.encoder
Type: audio/opus
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 10
Quality range: 0 - 0
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Audio info -----
Bitrate range: 6000 - 510000
Channels supported: 2
Supported sample rate: 
8000
12000
16000
24000
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.raw.decoder
Type: audio/raw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 1 - 10000000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.raw.decoder
Type: audio/raw
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 1 - 10000000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.vorbis.decoder
Type: audio/vorbis
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 32000 - 500000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.vorbis.decoder
Type: audio/vorbis
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 32000 - 500000
Channels supported: 8
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.dolby.ac4.decoder
Type: audio/ac4
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 16000 - 2688000
Channels supported: 16
Supported sample rate: 
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.dolby.ac4.decoder
Type: audio/ac4
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 16000 - 2688000
Channels supported: 16
Supported sample rate: 
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.dolby.eac3.decoder
Type: audio/ac3
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 32000 - 640000
Channels supported: 6
Supported sample rate: 
32000
44100
48000
----- -----
Max instances: 32
Type: audio/eac3
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 32000 - 6144000
Channels supported: 8
Supported sample rate: 
32000
44100
48000
----- -----
Max instances: 32
Type: audio/eac3-joc
Max instances: 32
----- Decoder info -----
----- -----
----- Audio info -----
Bitrate range: 32000 - 6144000
Channels supported: 16
Supported sample rate: 
48000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.aac.encoder
Type: audio/mp4a-latm
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Audio info -----
Profile: 2, level: 0
Profile: 5, level: 0
Profile: 29, level: 0
Profile: 23, level: 0
Profile: 39, level: 0
Bitrate range: 8000 - 510000
Channels supported: 6
Supported sample rate: 
8000
11025
12000
16000
22050
24000
32000
44100
48000
64000
88200
96000
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.sec.mpeg4.decoder
Type: video/mp4v-es
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2130708361
2135033992
19
21
20
39
Profile: 1, level: 256
Bitrate range: 1 - 12000000
Frame rate range: 12 - 60
Width range: 32 - 1344
Height range: 32 - 1344
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.av1.decoder
Type: video/av01
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 32768
Profile: 4096, level: 32768
Profile: 8192, level: 32768
Profile: 2, level: 32768
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.av1.encoder
Type: video/av01
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 5
Quality range: 0 - 100
CBR supported: true
VBR supported: true
CQ supported: true
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 512
Profile: 2, level: 512
Bitrate range: 1 - 5000000
Frame rate range: 0 - 960
Width range: 2 - 720
Height range: 2 - 720
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.avc.decoder
Type: video/avc
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 65536, level: 65536
Profile: 1, level: 65536
Profile: 2, level: 65536
Profile: 524288, level: 65536
Profile: 8, level: 65536
Bitrate range: 1 - 48000000
Frame rate range: 0 - 960
Width range: 2 - 4080
Height range: 2 - 4080
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.h264.decoder
Type: video/avc
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 65536, level: 65536
Profile: 1, level: 65536
Profile: 2, level: 65536
Profile: 524288, level: 65536
Profile: 8, level: 65536
Bitrate range: 1 - 48000000
Frame rate range: 0 - 960
Width range: 2 - 4080
Height range: 2 - 4080
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.avc.encoder
Type: video/avc
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16384
Profile: 65536, level: 16384
Profile: 2, level: 16384
Bitrate range: 1 - 12000000
Frame rate range: 0 - 960
Width range: 16 - 2048
Height range: 16 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.h264.encoder
Type: video/avc
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16384
Profile: 65536, level: 16384
Profile: 2, level: 16384
Bitrate range: 1 - 12000000
Frame rate range: 0 - 960
Width range: 16 - 2048
Height range: 16 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.h263.decoder
Type: video/3gpp
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16
Profile: 1, level: 8
Profile: 8, level: 16
Profile: 8, level: 8
Bitrate range: 1 - 384000
Frame rate range: 1 - 30
Width range: 4 - 352
Height range: 4 - 288
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.h263.decoder
Type: video/3gpp
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16
Profile: 1, level: 8
Profile: 8, level: 16
Profile: 8, level: 8
Bitrate range: 1 - 384000
Frame rate range: 1 - 30
Width range: 4 - 352
Height range: 4 - 288
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.h263.encoder
Type: video/3gpp
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16
Profile: 1, level: 8
Bitrate range: 1 - 128000
Frame rate range: 1 - 30
Width range: 176 - 176
Height range: 144 - 144
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.h263.encoder
Type: video/3gpp
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 16
Profile: 1, level: 8
Bitrate range: 1 - 128000
Frame rate range: 1 - 30
Width range: 176 - 176
Height range: 144 - 144
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.hevc.decoder
Type: video/hevc
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 524288
Profile: 4, level: 524288
Bitrate range: 1 - 10000000
Frame rate range: 0 - 960
Width range: 2 - 4096
Height range: 2 - 4096
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.hevc.decoder
Type: video/hevc
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 524288
Profile: 4, level: 524288
Bitrate range: 1 - 10000000
Frame rate range: 0 - 960
Width range: 2 - 4096
Height range: 2 - 4096
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.hevc.encoder
Type: video/hevc
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 10
Quality range: 0 - 100
CBR supported: true
VBR supported: true
CQ supported: true
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 262144
Profile: 4, level: 262144
Bitrate range: 1 - 10000000
Frame rate range: 1 - 120
Width range: 2 - 512
Height range: 2 - 512
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.mpeg4.decoder
Type: video/mp4v-es
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 256
Bitrate range: 1 - 12000000
Frame rate range: 12 - 60
Width range: 2 - 1344
Height range: 2 - 1344
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.mpeg4.decoder
Type: video/mp4v-es
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 256
Bitrate range: 1 - 12000000
Frame rate range: 12 - 60
Width range: 2 - 1344
Height range: 2 - 1344
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.mpeg4.encoder
Type: video/mp4v-es
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 8
Bitrate range: 1 - 64000
Frame rate range: 12 - 60
Width range: 16 - 176
Height range: 16 - 144
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.mpeg4.encoder
Type: video/mp4v-es
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: false
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 8
Bitrate range: 1 - 64000
Frame rate range: 12 - 60
Width range: 16 - 176
Height range: 16 - 144
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.vp8.decoder
Type: video/x-vnd.on2.vp8
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 1
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.vp8.decoder
Type: video/x-vnd.on2.vp8
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 1
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.vp8.encoder
Type: video/x-vnd.on2.vp8
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 1
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.vp8.encoder
Type: video/x-vnd.on2.vp8
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 1
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.vp9.decoder
Type: video/x-vnd.on2.vp9
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 256
Profile: 4, level: 256
Profile: 4096, level: 256
Profile: 16384, level: 256
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.vp9.decoder
Type: video/x-vnd.on2.vp9
Max instances: 32
----- Decoder info -----
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 256
Profile: 4, level: 256
Profile: 4096, level: 256
Profile: 16384, level: 256
Bitrate range: 1 - 40000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: c2.android.vp9.encoder
Type: video/x-vnd.on2.vp9
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 128
Bitrate range: 1 - 30000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
, ----------------
Name: OMX.google.vp9.encoder
Type: video/x-vnd.on2.vp9
Max instances: 32
----- Encoder info -----
Complexity range: 0 - 0
Quality range: 0 - 0
CBR supported: true
VBR supported: true
CQ supported: false
----- -----
----- Video info -----
Supported colors: 
2135033992
19
21
20
39
2130708361
Profile: 1, level: 128
Bitrate range: 1 - 30000000
Frame rate range: 0 - 960
Width range: 2 - 2048
Height range: 2 - 2048
----- -----
Max instances: 32
----------------
]
pedroSG94 commented 8 months ago

Hello,

I can't see an error in your logs. If you only have this error the third time you call prepareVideo try to check this:

Panha-VTechs commented 8 months ago

I've already change resolution to 1080p and I only called prepareVideo only one. Here the error when open it the third time:

image

pedroSG94 commented 8 months ago

I don't understand you. What do you mean with third time if you only call prepareVideo one time?

Panha-VTechs commented 8 months ago

I mean after I build my app and then I do like this: 1- I open app and go to camera preview , videoEncoder init successfully and doesn't show error log and then I close camera preview. 2- I open camera preview again and videoEncoder init successfully and doesn't show error log too and I close it again. 3- I open camera preview again and videoEncoder show the error log like the image

pedroSG94 commented 8 months ago

I can't reproduce it so I need a way to reproduce your case Can you create a project to reproduce the case and share me it as a zip? (keep it all small as possible)

Panha-VTechs commented 8 months ago

Hello,

I have test on android 14 with physical and emulator. On emulator it work fine but On my android device which is Samsung A52 5G is not working. As I test I see:

Encoder name: c2.android.avc.encoder
Support color: 2135033992
Support color: 19
Support color: 21
Support color: 20
Support color: 39
Support color: 2130708361
Support color: 2141391878
Support color: 2141391876
Support color: 2141391872
Support color: 2141391881
Support color: 2141391882

I think it happen on samsung device. So I'm not sure if you can reproduce it and I don't know if it happen because of VideoEncoder? Do you have other suggestion?

pedroSG94 commented 8 months ago

Hello,

Using emulator you only can use software encoders but in a real device by default a hardware encoder is selected. You can force use software encoders like this:

rtmpCamera.forceCodecType(codecTypeVideo = CodecUtil.CodecType.SOFTWARE, codecTypeAudio = CodecUtil.CodecType.FIRST_COMPATIBLE_FOUND)

Remember compile the last commit for it:

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'
Panha-VTechs commented 8 months ago

I can't reproduce it so I need a way to reproduce your case Can you create a project to reproduce the case and share me it as a zip? (keep it all small as possible)

Hello ,

here the project you test it: StreamPleyer.zip

You can test by open camera preview again and again maybe on third or forth time it will show error log as above.

Panha-VTechs commented 8 months ago

Hello,

Using emulator you only can use software encoders but in a real device by default a hardware encoder is selected. You can force use software encoders like this:

rtmpCamera.forceCodecType(codecTypeVideo = CodecUtil.CodecType.SOFTWARE, codecTypeAudio = CodecUtil.CodecType.FIRST_COMPATIBLE_FOUND)

Remember compile the last commit for it:

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'

Hello, I can not use this one because it doesn't have setBitrateOnFly and I can not find forceCodecType method too.

pedroSG94 commented 8 months ago

Hello, Using emulator you only can use software encoders but in a real device by default a hardware encoder is selected. You can force use software encoders like this:

rtmpCamera.forceCodecType(codecTypeVideo = CodecUtil.CodecType.SOFTWARE, codecTypeAudio = CodecUtil.CodecType.FIRST_COMPATIBLE_FOUND)

Remember compile the last commit for it:

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'

Hello, I can not use this one because it doesn't have setBitrateOnFly and I can not find forceCodecType method too.

Please, update gradle to the commit mentioned in that post:

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'
Panha-VTechs commented 8 months ago

Yes I've used this one that you mention, but I still cannot find setBitrateOnFly and forceCodecType method.

implementation 'com.github.pedroSG94.RootEncoder:library:53eb9d9272'

pedroSG94 commented 8 months ago

Ok, the gradle commit was wrong. My bad. Try this:

implementation 'com.github.pedroSG94.RootEncoder:library:5f322b7c80'
Panha-VTechs commented 8 months ago

Can I do it like this:

if (!isPrepared) {
    val isPreparedAudio = rtmpCameraX?.prepareAudio() ?: false
    var isPreparedVideo = rtmpCameraX?.prepareVideo(
        width = 1920,
        height = 1080,
        bitrate = bitrateUsedInPrepareVideo,
        fps = fps
    ) ?: false
    if (!isPreparedVideo) {
        rtmpCameraX?.forceCodecType(
            codecTypeVideo = CodecUtil.CodecType.SOFTWARE,
            codecTypeAudio = CodecUtil.CodecType.FIRST_COMPATIBLE_FOUND
        )
        isPreparedVideo = rtmpCameraX?.prepareVideo(
            width = 1920,
            height = 1080,
            bitrate = bitrateUsedInPrepareVideo,
            fps = fps
        ) ?: false
    }
    isPrepared = isPreparedAudio && isPreparedVideo
    mLifecycleOwner.lifecycleScope.launch {
        withContext(Dispatchers.Default) {
            for (codecInfo in CodecUtil.getAllEncoders(CodecUtil.H264_MIME)) {
                Log.d(TAG, "Encoder name: ${codecInfo.name}")
                codecInfo.getCapabilitiesForType(CodecUtil.H264_MIME).colorFormats.map {
                    Log.d(TAG, "Support color: $it")
                }
            }
        }
    }
}

As I want to use hardware encoder and use software when the first one error. I used bitrateUsedInPrepareVideo = 3000 * 1024

pedroSG94 commented 8 months ago

Yes, you can try it. Also, try to use 30fps instead of 60fps. Maybe the error is related with fps. I have others tips after check a bit the project example shared:

For now, I tested with 3 devices (Pixel 5a, PIxel 6a and Pixel 7) and I was no able to produce the error. I will try with more devices and report back.

Panha-VTechs commented 8 months ago

I use openGlView because I plan to use filter when live stream. So I will try as you suggest

Panha-VTechs commented 8 months ago

Yes, you can try it. Also, try to use 30fps instead of 60fps. Maybe the error is related with fps. I have others tips after check a bit the project example shared:

  • Try to check if you are onPreview before call stopPreview. It is only a sanity check
  • You can use a SurfaceView in your XML instead of OpenGlView (RtmpStream don't need OpenGlView, you can use a normal SurfaceView or TextureView)
  • Never call startPreview in onResume because the SurfaceView will never be ready in that method

For now, I tested with 3 devices (Pixel 5a, PIxel 6a and Pixel 7) and I was no able to produce the error. I will try with more devices and report back.

Do you see it selected the same video encoder as me?

pedroSG94 commented 8 months ago

I use openGlView because I plan to use filter when live stream. So I will try as you suggest

You don't need OpenGlView for filters using RtmpStream. The Gl render is managed internally instead of use OpenGlView as render.

Do you see it selected the same video encoder as me?

No, Pixel use c2.qti.avc.encoder or c2.exynos.h264.encoder (this last for google tensor CPU).

I have 2 samsungs to test and a Oneplus but I'm not sure if I can reproduce the error

Panha-VTechs commented 8 months ago

Okay lemme try it. Thank you so much @pedroSG94 for your time with me.

Panha-VTechs commented 8 months ago

Now I got the other error after follow your tips and it show like:

VideoEncoder         3 encoders found
VideoEncoder         Encoder OMX.qcom.video.encoder.avc
VideoEncoder         Color supported: 2141391878
VideoEncoder         Color supported: 2141391876
VideoEncoder         Color supported: 2141391872
VideoEncoder         Color supported: 2141391881
VideoEncoder         Color supported: 2141391882
VideoEncoder         Color supported: 2141391880
VideoEncoder         Color supported: 2141391879
VideoEncoder         Color supported: 2130708361
VideoEncoder         Encoder selected OMX.qcom.video.encoder.avc
ACodec                [] Now uninitialized
ACodec               [] onAllocateComponent
OMXClient            IOmx service obtained
ACodec               Unable to instantiate codec 'OMX.qcom.video.encoder.avc' with err 0xfffffff4.
ACodec               signalError(omxError 0xfffffff4, internalError -12)
MediaCodec           Codec reported err 0xfffffff4/NO_MEMORY, actionCode 0, while in state 1/INITIALIZING
MediaCodec           flushMediametrics
MediaCodec-JNI       try to release MediaCodec from JMediaCodec::~JMediaCodec()...
MediaCodec-JNI       done releasing MediaCodec from JMediaCodec::~JMediaCodec().
VideoEncoder         Create VideoEncoder failed.
                     android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.encoder.avc, error 0xfffffff4 (NO_MEMORY)
                        at android.media.MediaCodec.native_setup(Native Method)
                        at android.media.MediaCodec.<init>(MediaCodec.java:2094)
                        at android.media.MediaCodec.<init>(MediaCodec.java:2072)
                        at android.media.MediaCodec.createByCodecName(MediaCodec.java:2042)
                        at com.pedro.encoder.video.VideoEncoder.prepareVideoEncoder(VideoEncoder.java:106)
                        at com.pedro.library.base.StreamBase.prepareVideo(StreamBase.kt:107)
                        at com.pedro.library.base.StreamBase.prepareVideo$default(StreamBase.kt:98)
                        at com.vtech.streamVerseApp.stream_publisher.StreamPublisherView.surfaceChanged(StreamPublisherView.kt:304)
                        at android.view.SurfaceView.updateSurface(SurfaceView.java:1277)
                        at android.view.SurfaceView.lambda$new$0(SurfaceView.java:258)
                        at android.view.SurfaceView.$r8$lambda$cm3nmzErr-srXoT_KjIYQgdhFN0(Unknown Source:0)
                        at android.view.SurfaceView$$ExternalSyntheticLambda2.onPreDraw(Unknown Source:2)
                        at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1204)
                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4672)
                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3248)
                        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:11206)
                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1650)
                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1659)
                        at android.view.Choreographer.doCallbacks(Choreographer.java:1129)
                        at android.view.Choreographer.doFrame(Choreographer.java:1055)
                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1622)
                        at android.os.Handler.handleCallback(Handler.java:958)
                        at android.os.Handler.dispatchMessage(Handler.java:99)
                        at android.os.Looper.loopOnce(Looper.java:230)
                        at android.os.Looper.loop(Looper.java:319)
                        at android.app.ActivityThread.main(ActivityThread.java:8893)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
VideoEncoder         stopped

As it show message " Failed to initialize OMX.qcom.video.encoder.avc, error 0xfffffff4". Do you have any solution for this?

pedroSG94 commented 8 months ago

Hello,

According with the log, you are still using hardware encoder and the error is exactly the same that before. I did a branch for this case with a commit that maybe help to fix the problem. Compile this gradle:

implementation 'com.github.pedroSG94.RootEncoder:library:a08865a0ca'

This branch contain a method called release in StreamBase. Try to use it in onDestroy method and check if the problem is solved. Also, check that forceCodecType is correctly called.

Panha-VTechs commented 8 months ago

Hello,

According with the log, you are still using hardware encoder and the error is exactly the same that before. I did a branch for this case with a commit that maybe help to fix the problem. Compile this gradle:

implementation 'com.github.pedroSG94.RootEncoder:library:a08865a0ca'

This branch contain a method called release in StreamBase. Try to use it in onDestroy method and check if the problem is solved. Also, check that forceCodecType is correctly called.

I have just disabled forceCodecType because when I stream with software encoder video quality is very poor. So I try to use hardware encoder but I just got this problem after open camera preview several time. So I will try release it and check if it fixed or not and report you back.

pedroSG94 commented 7 months ago

Hello,

Did you solved the error using the release method provided in my last gradle version? I need know it to merge the branch with the fix