AbedElazizShe / LightCompressor

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

Crash on Android 12 when compressing videos captured via camera #145

Closed thecodepapaya closed 1 year ago

thecodepapaya commented 1 year ago

The application crashes when compressing a video captured via the device camera on Android 12. It works when compressing a video downloaded from Youtube.

The compression works when testing on older android versions. I tried it on Android 9 and it worked without any issues.

Using light_compressor version 1.2.2


D/CCodecBufferChannel(19060): [c2.android.amrnb.decoder#920] MediaCodec discarded an unknown buffer
W/AMessage(19060): failed to deliver message as target handler 8 is gone.
2
I/hw-BpHwBinder(19060): onLastStrongRef automatically unlinking death recipients
E/BufferQueueProducer(19060): [MediaCodec.release](id:4a7400000005,api:0,p:-1,c:19060) detachBuffer: BufferQueue has no connected producer
[current size in MB] 91.06140422821045
[bitrate] 8.470828300298647
E/AndroidRuntime(19060): FATAL EXCEPTION: main
E/AndroidRuntime(19060): Process: com.qoohoo_app, PID: 19060
E/AndroidRuntime(19060): java.lang.IllegalArgumentException: Primary directory (invalid) not allowed for content://media/external_primary/video/media; allowed directories are [DCIM, Movies, Pictures]
E/AndroidRuntime(19060):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
E/AndroidRuntime(19060):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
E/AndroidRuntime(19060):    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:557)
E/AndroidRuntime(19060):    at android.content.ContentResolver.insert(ContentResolver.java:2193)
E/AndroidRuntime(19060):    at android.content.ContentResolver.insert(ContentResolver.java:2155)
E/AndroidRuntime(19060):    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.saveVideoFile(VideoCompressor.kt:173)
E/AndroidRuntime(19060):    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor.access$saveVideoFile(VideoCompressor.kt:24)
E/AndroidRuntime(19060):    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$doVideoCompression$1.invokeSuspend(VideoCompressor.kt:97)
E/AndroidRuntime(19060):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(19060):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(19060):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(19060):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(19060):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(19060):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(19060):    at android.app.ActivityThread.main(ActivityThread.java:7842)
E/AndroidRuntime(19060):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(19060):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(19060):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
[QNetworkPerformanceInterceptor.onResponse] [201] https://staging-api.qoohoo.in/api/v3/asset/
I/Process (19060): Sending signal. PID: 19060 SIG: 9
Lost connection to device.
Exited
flutter doctor -v
``` [✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-arm, locale en-IN) • Flutter version 3.3.9 on channel stable at /Users/ashutoshsingh/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b8f7f1f986 (3 weeks ago), 2022-11-23 06:43:51 +0900 • Engine revision 8f2221fbef • Dart version 2.18.5 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/ashutoshsingh/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14B47b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code (version 1.74.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.54.0 [✓] Connected device (3 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 32) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 13.0.1 22A400 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.98 [✓] HTTP Host Availability • All required HTTP hosts are available ```
AbedElazizShe commented 1 year ago

Hi @thecodepapaya, a new version was released for the flutter plugin, please have a look.

I will close this issue for now as this repo is not for the flutter plugin.

Thanks a lot.