enrichVideoWithPath static method

Future<VideoWithThumbnail> enrichVideoWithPath(
  1. String memberMediumDocumentID,
  2. String filePath
)

Implementation

static Future<VideoWithThumbnail> enrichVideoWithPath(
    String memberMediumDocumentID, String filePath) async {
  var baseName = BaseNameHelper.baseName(memberMediumDocumentID, filePath);
  var thumbnailBaseName =
      BaseNameHelper.thumbnailBaseName(memberMediumDocumentID, baseName);
  var videoBytes = await File(filePath).readAsBytes();
/*
  if (videoBytes == null) {
    throw Exception("Can't read $filePath. videoBytes is null");
  }
*/

  var thumbNailData = await VideoThumbnail.thumbnailData(
    video: filePath,
    imageFormat: ImageFormat.PNG,
    maxWidth:
        thumbnailSize, // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio
    quality: 30,
  );

/*
  if (thumbNailData == null) {
    throw Exception(
        "Could not create thumbnail for video with path $filePath");
  }
*/

  // return the data
  return VideoWithThumbnail(
      videoData: VideoData(
          baseName: baseName,
          data: videoBytes), // we don't know the size of the video... todo
      thumbNailData: ImageData(
          baseName: thumbnailBaseName,
          width: thumbnailSize,
          height: thumbnailSize,
          data: thumbNailData));
}