AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
537 stars 116 forks source link

Compressor don't work on Android 9 and 10 #175

Closed ViktoriiaPalykhata closed 1 year ago

ViktoriiaPalykhata commented 1 year ago

Please, help. I always have an issue when trying to compress any video made by device camera.

This on Android 10: Codec reported err 0x16, actionCode 0, while in state 6 An error has occurred! java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2789) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.start(Compressor.kt:309) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.access$start(Compressor.kt:30) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invokeSuspend(Compressor.kt:141) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invoke(Unknown Source:8) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.compressVideo(Compressor.kt:53) at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$startCompression$2.invokeSuspend(VideoCompressor.kt:180) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) An error has occurred!

And this on Android 9: Failed to find matching codec video/avc, error 0x80000000 java.io.IOException: Failed to find matching codec video/avc, error 0x80000000 at android.media.MediaCodec.native_setup(Native Method) at android.media.MediaCodec.(MediaCodec.java:1811) at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1777) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.prepareEncoder(Compressor.kt:528) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.start(Compressor.kt:206) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.access$start(Compressor.kt:30) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invokeSuspend(Compressor.kt:141) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invoke(Unknown Source:8) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.compressVideo(Compressor.kt:53) at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$startCompression$2.invokeSuspend(VideoCompressor.kt:180) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

They are also repeated in your demo app. Compressor version is 1.3.2

ViktoriiaPalykhata commented 1 year ago

Also compressor returns in Succes strange path to file which don't exists /data/user/0/${app}/files/simpleVideos/data/user/0/${app}/files/VID_20230929_211526.mp4_temp

ViktoriiaPalykhata commented 1 year ago

Sorry. Errors return because of emulators wrong behavior. And path to file is wrong because I set file path to videoNames in Configuration.