Flutter: How to read data from video using ffmpeg


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?


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 [
            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();

              .then((info) => print(info)); // This should print metadata inside of video

Answered By – Jitesh Mohite

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *