linkedin / linkedin/LiTr

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

Open
#254 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
663
Forks
92
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with createVideoMediaFormat and the EncoderImpl.reset/constructor path shown in the stack trace, then reproduce the failure using CameraX Recorder with QualitySelector on the Samsung SM-J710FQ running Android 8. Compare the MediaFormat values from LiTr 1.5.4 with the CameraX 1.2.1 configuration; done means the codec incompatibility is identified and a verified fix or supported configuration is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
audio-video-rtc, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.