fluttercandies / saver_gallery

MIT License
15 stars 15 forks source link

[Bug report] app crashes after try to save video made by ffmpeg #14

Closed husen-hn closed 3 months ago

husen-hn commented 4 months ago

Version

3.0.3

Platforms

Android

Device Model

Google Pixel 3XL ((Android 11) (API 30))

flutter info

[✓] Flutter (Channel stable, 3.13.1, on Manjaro Linux 5.15.154-1-MANJARO, locale en_US.UTF-8)
    • Flutter version 3.13.1 on channel stable at /home/hn/fvm/versions/3.13.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e1e47221e8 (9 months ago), 2023-08-22 21:43:18 -0700
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /opt/android-sdk
    • Platform android-34, build-tools 30.0.3
    • ANDROID_HOME = /opt/android-sdk
    • ANDROID_SDK_ROOT = /usr/local/share/android-sdk
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.6
    • cmake version 3.28.3
    • ninja version 1.11.1
    • pkg-config version 2.1.0

[✓] Android Studio (version 2023.1)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 77.1.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Connected device (3 available)
    • 127.0.0.1:5555 (mobile) • 127.0.0.1:5555 • android-x64    • Android 11 (API 30)
    • Linux (desktop)         • linux          • linux-x64      • Manjaro Linux 5.15.154-1-MANJARO
    • Chrome (web)            • chrome         • web-javascript • Chromium 123.0.6312.122 Arch Linux

[✓] Network resources
    • All expected network resources are available.

• No issues found!

How to reproduce?

After I create a new video file using FFMPEG and (I also check the created video file, it can be run without problems by the emulator video player) I try to save it in the emulator gallery using the saver_gallery package, the whole application crashes and it fails.

Logs

E/AndroidRuntime(27613): FATAL EXCEPTION: DefaultDispatcher-worker-1
E/AndroidRuntime(27613): Process: com.hn.fm, PID: 27613
E/AndroidRuntime(27613): java.lang.IllegalArgumentException: Primary directory fm not allowed for content://media/external/video/media; allowed directories are [DCIM, Movies, Pictures]
E/AndroidRuntime(27613):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
E/AndroidRuntime(27613):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
E/AndroidRuntime(27613):    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
E/AndroidRuntime(27613):    at android.content.ContentResolver.insert(ContentResolver.java:2149)
E/AndroidRuntime(27613):    at android.content.ContentResolver.insert(ContentResolver.java:2111)
E/AndroidRuntime(27613):    at com.mhz.savegallery.saver_gallery.SaverDelegateAndroidT.generateUri(SaverDelegateAndroidT.kt:246)
E/AndroidRuntime(27613):    at com.mhz.savegallery.saver_gallery.SaverDelegateAndroidT.access$generateUri(SaverDelegateAndroidT.kt:25)
E/AndroidRuntime(27613):    at com.mhz.savegallery.saver_gallery.SaverDelegateAndroidT$saveFileToGallery$1.invokeSuspend(SaverDelegateAndroidT.kt:155)
E/AndroidRuntime(27613):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(27613):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(27613):    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
E/AndroidRuntime(27613):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
E/AndroidRuntime(27613):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
E/AndroidRuntime(27613):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
I/Process (27613): Sending signal. PID: 27613 SIG: 9
Lost connection to device.

Exited.

Example code (optional)

// FFMPEG codes:
FFmpegKit.executeAsync(
'-i file1.mp4 -c:v mpeg4 /storage/emulated/0/Movies/fk_app.mp4');

// saving codes:
await SaverGallery.saveFile(
        file: '/storage/emulated/0/Movies/fk_app.mp4',
        androidExistNotSave: true,
        name: '123.mp4',
        androidRelativePath: "Fk");
zhangruiyu commented 3 months ago

androidRelativePath should be filled with one of [DCIM, Movies, Pictures], which the error log already indicates

husen-hn commented 3 months ago

androidRelativePath should be filled with one of [DCIM, Movies, Pictures], which the error log already indicates

‍/storage/emulated/0/Movies/fk_app.mp4'‍ Isn't this path related to [DCIM, Movies, Pictures]? this is a path to Movies and basically, there should be no problem

zhangruiyu commented 3 months ago

androidRelativePath why should we pass Fk here should we pass one of [DCIM, Movies, Pictures]