AbedElazizShe / LightCompressor

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

video compression not supporting for android 10 in the sample app #152

Closed yangiljae closed 1 year ago

yangiljae commented 1 year ago

the same code is working fine in android 13 but when I'm running the app in the android version 10 the app has been crashed

Screenshot_20230512-103436_VideoCompressor

2023-05-12 10:38:17.958 28981-2318 Compressor com.abedelazizshe.lightcompressor E /storage/emulated/0/Movies/compressed_video.mp4: open failed: EACCES (Permission denied) java.io.FileNotFoundException: /storage/emulated/0/Movies/compressed_video.mp4: open failed: EACCES (Permission denied) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.FileOutputStream.(FileOutputStream.java:235) at java.io.FileOutputStream.(FileOutputStream.java:186) at com.abedelazizshe.lightcompressorlibrary.video.MP4Builder.createMovie(MP4Builder.kt:28) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.start(Compressor.kt:177) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.access$start(Compressor.kt:30) at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invokeSuspend(Compressor.kt:134) 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:166) 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:157) 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:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8044) at libcore.io.IoBridge.open(IoBridge.java:482) at java.io.FileOutputStream.(FileOutputStream.java:235)  at java.io.FileOutputStream.(FileOutputStream.java:186)  at com.abedelazizshe.lightcompressorlibrary.video.MP4Builder.createMovie(MP4Builder.kt:28)  at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.start(Compressor.kt:177)  at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.access$start(Compressor.kt:30)  at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor$compressVideo$2.invokeSuspend(Compressor.kt:134)  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:166)  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:157)  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:749)  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 

Micoder-dev commented 1 year ago

You have to get required storage permission, then it works fine

AbedElazizShe commented 1 year ago

Hi @yangiljae , please follow the usage part: https://github.com/AbedElazizShe/LightCompressor#usage, feel free to reopen the issue if adding the permissions does not work.

Thank you.