Search code examples
dartflutterflutter-layout

Flutter:Get the first frame of the video


How to get the first frame of the local video file in the Flutter project? Here is my code:

ImagePicker.pickVideo(source: ImageSource.camera).then((File file) {
  if (file != null && mounted) {
    //I got the video file here, but I want to get the first frame of the video.
  }
 });
},

Solution

  • String thumb = await Thumbnails.getThumbnail(
        thumbnailFolder:'[FOLDER PATH TO STORE THUMBNAILS]', // creates the specified path if it doesnt exist
        videoFile: '[VIDEO PATH HERE]',
        imageType: ThumbFormat.PNG,
        quality: 30);
    
    /*
    * thumbnailFolder property can be omitted if you dont wish to keep the generated thumbails past each usage
    */