How to extract Dart/Flutter video metadata

One of the ways to get the creation time of the video in FLutter is to use flutter_ffmpeg plugin.

  1. Add it to the pubspec.yaml:

    dependencies:
       flutter_ffmpeg: ^0.3.0
    
  2. Get the file path of your video, for example with file_picker:

    File pickedFile = await FilePicker.getFile(); 
    
  3. Get meta data of the video by its path using ffmpeg:

     final FlutterFFprobe flutterFFprobe = FlutterFFprobe();
     MediaInformation mediaInformation = await flutterFFprobe.getMediaInformation(pickedFile.path);
     Map<dynamic, dynamic> mp = mediaInformation.getMediaProperties();
     String creationTime = mp["tags"]["creation_time"];
     print("creationTime: $creationTime");
    

And in the console you'll get smth like this:

I/flutter (13274): creationTime: 2020-09-24T17:59:24.000000Z

Along with creation time, there are other useful details: enter image description here

Note: adding this plugin to your app increases the weight of your final apk!


You can use the VideoPlayerController.file constructor from the official video player plugin (which is maintained by the official google team so you don't have to worry about its future and stability) to access the file and get the following meta after you install the package:

first this is your VideoPlayerController:

 VideoPlayerController controller = new VideoPlayerController.file('');//Your file here
  1. Duration:

    controller.value.duration ;
    
  2. Video Name, this should already be possessed with you as you can reach the file path and pass it to the player constructor.

3.Video Size:

    controller.value.size ;

4.As for when the video was taken I can't help you with this. You have to find another way to figure it out.

Tags:

Dart

Flutter