natsuk4ze / gal

How to Save Image or Video to Photo Gallery in Flutter
https://pub.dev/packages/gal
BSD 3-Clause "New" or "Revised" License
85 stars 13 forks source link

Unsupported file formats Error for existed files #162

Closed husen-hn closed 8 months ago

husen-hn commented 8 months ago

Did you check the documentation and it did not help?

Overview

after converting the files using FFmpeg ... the generated files can be accessed and run without any problems through the file manager. but when I use Gal to display it inside the gallery, I get an Unsupported file formats error.

Steps to reproduce

  1. add FFmpeg package ffmpeg_kit_flutter_full_gpl: '6.0.3-LTS
  2. add filesystem_picker: ^3.1.0 to pick file from system
  3. gal: ^2.1.2
  4. convert a picked video to formats like mp4, avi, mkv, and ...
  5. after the converting process done
  6. check the converted video from File Manager for sure if it is done successfully
  7. save the converted video to the gallery using Gal
  8. geting error Unsupported file formats

Code sample

Code sample ```dart String selectedFilePath = '/data/user/0/com.test.fmkr/cache/file_picker/VID_20230428_140439.mp4'; String outputPath = ' /storage/emulated/0/Movies/fmkr/VID_20230428_140439_2023101818313.avi'; // convert mp4 to avi format FFmpegKit.executeAsync( '-i $selectedFilePath -c:v libx264 -c:a aac $outputPath', (Session session) async { final returnCode = await session.getReturnCode(); if (ReturnCode.isSuccess(returnCode) == true) { Gal.putVideo(outputPath); } }, ); ```

Environment

Logs ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.1, on Manjaro Linux 5.15.125-1-MANJARO, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Chrome - develop for the web [✓] Linux toolchain - develop for Linux desktop [✓] Android Studio (version 2022.3) [✓] Connected device (3 available) [☠] Network resources (the doctor check crashed) ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. ✗ Exception: Network resources exceeded maximum allowed duration of 0:04:30.000000 ! Doctor found issues in 1 category. ```

Logs

Logs ```console E/flutter ( 5527): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [GalException/NOT_SUPPORTED_FORMAT]: Unsupported file formats. E/flutter ( 5527): #0 GalPlatform._invokeMethod (package:gal/src/gal_platform.dart:17:7) E/flutter ( 5527): E/flutter ( 5527): #1 GalPlatform.putVideo (package:gal/src/gal_platform.dart:24:5) E/flutter ( 5527): E/flutter ( 5527): #2 ConvertingCubit.saveOnGallery (package:fmkr/controller/converting/converting_cubit.dart:158:5) ```
natsuk4ze commented 8 months ago

Thank you for your contribution @husen-hn 🤝

The cause is that Android does not support avi as standard.

you will need to change the out put file format to one that is supported. Like mp4.

String outputPath = ' /storage/emulated/0/Movies/fmkr/video.mp4';

This is a screenshot of the result of saving the same file to a file with the same code. When I save the file as avi, the thumbnails do not show up and when I open the file, it jags and does not play properly.

If you get the error even with mp4, then it is most likely a codec problem.

Please see wiki for more.

github-actions[bot] commented 8 months ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, Thanks for your contribution.