Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract Dart/Flutter video metadata

Tags:

flutter

dart

I am developing a flutter demo app. I want to use metadata about a video in my phone storage. I am able to extract the path of that video, but don't know how to extract its metadata in dart/flutter.

I need the following metadata:

  1. Duration of video
  2. Name of video
  3. Size of video
  4. When video was taken
like image 449
Sudhansu CronJ Avatar asked Mar 05 '19 05:03

Sudhansu CronJ


People also ask

How do you get the video file path in FLutter?

dart'; final videoInfo = FlutterVideoInfo(); String videoFilePath = "your_video_file_path"; var info = await videoInfo. getVideoInfo(videoFilePath); //String title = info. title; to get title of video //similarly path,author,mimetype,height,width,filesize,duration,orientation,date,framerate,location can be extracted.

How do I get the metadata from an image in FLutter?

exif plugin can be used to read the metadata of images. To use, read the image file using File. readAsBytesSync() then use readExifFromBytes() .


1 Answers

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!

like image 58
Kirill Karmazin Avatar answered Sep 21 '22 11:09

Kirill Karmazin