getVideoCoverImage static method

Future<String> getVideoCoverImage(
  1. String videoPath
)

Implementation

static Future<String> getVideoCoverImage(String videoPath) async {
  String imgPath = await getVideoRootDirectory(foldName: 'coverImg') + '${const Uuid().v4()}.png';
  var cmd = '-ss 00:00:00.01 -i $videoPath -y -f image2 $imgPath';

  try {
    print('获取封面图成功');
    await ffmpeg.execute(cmd);
  } catch (e) {
    print('获取封面图失败');
    imgPath = '';
  }

  return imgPath;
}