AbedElazizShe / LightCompressor

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

FileNotFoundException and ErrorNoException #134

Closed desaikishan02 closed 11 months ago

desaikishan02 commented 2 years ago

Screenshot from 2022-08-16 11-22-49 it gives an error like this in android 11 and android 12 so what i have to do

AS7C2 commented 2 years ago

I have this issue on Google Pixel 3 XL with Android 12.

android.system.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Linux.open(Linux.java)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7728)
    at libcore.io.IoBridge.open(IoBridge.java:560)
    at java.io.FileInputStream.<init>(FileInputStream.java:160)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.saveVideoInInternal(VideoCompressor.kt:214)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.saveVideoFile(VideoCompressor.kt:180)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.access$saveVideoFile(VideoCompressor.kt:26)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$doVideoCompression$1.invokeSuspend(VideoCompressor.kt:104)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7842)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
java.io.FileNotFoundException: : open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:574)
    at java.io.FileInputStream.<init>(FileInputStream.java:160)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.saveVideoInInternal(VideoCompressor.kt:214)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.saveVideoFile(VideoCompressor.kt:180)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.access$saveVideoFile(VideoCompressor.kt:26)
    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$doVideoCompression$1.invokeSuspend(VideoCompressor.kt:104)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7842)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
AlejandroImbox commented 2 years ago

Hello everyone , I also have a problem with Android 13. Searching why it could fail, I have seen that the problem comes when it goes to save the file in the "saveVideoFile" method. In case the storageConfiguration.isExternal parameter is true, it ends up throwing exception, just when it does val fileUri = context.contentResolver.insert(collection, values) .

Attached the error that throws me, any help is welcome, thanks.

Captura de pantalla 2022-08-31 a las 9 56 21

Amberon-voldi commented 1 year ago

hello @desaikishan02 this is probably caused by the way android handles storage access for new version of android after API 29. google released scoped storage to access files outside of the app's directory and i assume light compressor is not yet ready for it. so the compression fails when the package tries to access the path outside of it's dir

ajitdubey-mob-ibtech commented 1 year ago

I am getting the same error while compressing the video and trying to write it into another directory. Might be URI is wrong I don't know what is the exact issue.

This is the URI I am trying to pass to the library: file:///storage/emulated/0/Download/pexels-cup-of-couple-7303657.mp4

LightCompressor Version: 1.2.0 Android SDK: 11,12 and 13.

Kindly request to you please fix this issue ASAP or suggest any alternatives.