Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaCodec$CodecException: Error 0xffffec77 When trying to record video via CameraX while LiTr compressing #254

Open
LiveInParadise opened this issue Mar 21, 2023 · 2 comments

Comments

@LiveInParadise
Copy link

LiveInParadise commented Mar 21, 2023

This error happens in CameraX only when LiTr library doing compress

Receiving this error -

androidx.camera.video.internal.ResourceCreationException: androidx.camera.video.internal.encoder.InvalidConfigException: android.media.MediaCodec$CodecException: Error 0xffffec77

Here is a full log stack

androidx.camera.video.internal.ResourceCreationException: androidx.camera.video.internal.encoder.InvalidConfigException: android.media.MediaCodec$CodecException: Error 0xffffec77
	at androidx.camera.video.Recorder.setupVideo(Recorder.java:1333)
	at androidx.camera.video.Recorder.initializeInternal(Recorder.java:1012)
	at androidx.camera.video.Recorder.lambda$onSurfaceRequested$0$androidx-camera-video-Recorder(Recorder.java:427)
	at androidx.camera.video.Recorder$$ExternalSyntheticLambda16.run(Unknown Source:4)
	at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:111)
	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
	at java.lang.Thread.run(Thread.java:764)
Caused by: androidx.camera.video.internal.encoder.InvalidConfigException: android.media.MediaCodec$CodecException: Error 0xffffec77
	at androidx.camera.video.internal.encoder.EncoderImpl.<init>(EncoderImpl.java:234)
	at androidx.camera.video.Recorder$$ExternalSyntheticLambda15.createEncoder(Unknown Source:2)
	at androidx.camera.video.Recorder.setupVideo(Recorder.java:1330)
	... 9 more
Caused by: android.media.MediaCodec$CodecException: Error 0xffffec77
	at android.media.MediaCodec.native_configure(Native Method)
	at android.media.MediaCodec.configure(MediaCodec.java:1943)
	at android.media.MediaCodec.configure(MediaCodec.java:1872)
	at androidx.camera.video.internal.encoder.EncoderImpl.reset(EncoderImpl.java:262)
	at androidx.camera.video.internal.encoder.EncoderImpl.<init>(EncoderImpl.java:232)

This is how I'm creating MediaFormat

private fun createVideoMediaFormat(trackFormat: VideoTrackFormat): MediaFormat {
        return MediaFormat().apply {
            setString(MediaFormat.KEY_MIME, "video/avc")
            setInteger(MediaFormat.KEY_WIDTH, trackFormat.width)
            setInteger(MediaFormat.KEY_HEIGHT, trackFormat.height)
            setInteger(MediaFormat.KEY_BIT_RATE, trackFormat.bitrate)
            setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, trackFormat.keyFrameInterval)
            setInteger(MediaFormat.KEY_FRAME_RATE, trackFormat.frameRate)
            setLong(MediaFormat.KEY_DURATION, trackFormat.duration)
            setInteger(KEY_ROTATION, trackFormat.rotation)
        }
    }

CameraX Recorder class has simple create method where I set highest supported quality -

 val recorder = Recorder.Builder().apply {
                        getVideoQuality()?.let {
                            setQualitySelector(QualitySelector.from(it))
                        }
                    }.build()

Can reproduce this on Samsung SM-J710FQ with Android 8

litr version - 1.5.4
CameraX - 1.2.1

What problem can it be?

@izzytwosheds
Copy link
Contributor

I don't think we experimented with CameraX yet.
@IanDBird can you take a look when you get a moment?

@IanDBird
Copy link
Contributor

Hey 👋 Curious how you're integrating LiTr + CameraX. The current changes I landed recently really only support Camera2 as the API is more flexible about where the camera is rendering too. I have looked into proper CameraX support and was considering moving it to a separate module (since it requires a fair amount of dependencies).

If you're able to share how you're attaching CameraX, then happy to see if I can suggest a short term workaround until native support is ready?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants