0

I am trying to fetch the metadata from the video for that using lib https://pub.dev/packages/flutter_ffmpeg,

Below code is not working with ffmpeg

  Directory appDocDir = await getApplicationDocumentsDirectory();
  String appDocPath = appDocDir.path;
  File file = File('{$appDocPath}/folder_name/out.mp4');
  final FlutterFFprobe _flutterFFprobe = new FlutterFFprobe();

 _flutterFFprobe.getMediaInformation(file.path).then((info) => print(info));

How could I resolve the above one?

Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147

1 Answers1

1

File required storage access first and then given path is accessible to ffmpeg lib

Add Storage Permission

permission_handler: ^5.0.1 // in pubspec.yaml file

Ask for runtime permission before accessing video

    var status = await Permission.storage.status;
          if (status.isUndetermined) {
            // You can request multiple permissions at once.
            Map<Permission, PermissionStatus> statuses = await [
              Permission.storage,
            ].request();
            print(statuses[Permission.storage]); // this must show permission granted. 
          }

Finally, use it with ffmpeg with storage path like

          File file = File('/storage/emulated/0/folder_name/out.mp4');
          final FlutterFFprobe _flutterFFprobe = new FlutterFFprobe();

          _flutterFFprobe
              .getMediaInformation(file.path)
              .then((info) => print(info)); // This should print metadata inside of video
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
  • How to fetch cover image(album art) and other properties of audio files such as artist name, song name, total time length of audio files etc? Please help, I am stuck on this for 2 weeks i post question on stack but no response from community. – user11908262 Oct 21 '20 at 12:46