generateThumbnail method
Used to generate a thumbnail for a video file.
Implementation
Future<void> generateThumbnail(String inputPath, String targetPath) async {
String timestamp =
JidoujishoTimeFormat.getFfmpegTimestamp(const Duration(seconds: 30));
final FlutterFFmpeg _flutterFFmpeg = FlutterFFmpeg();
String command =
'-ss $timestamp -y -i "$inputPath" -frames:v 1 -q:v 2 "$targetPath"';
await _flutterFFmpeg.execute(command);
String output = await FlutterFFmpegConfig().getLastCommandOutput();
if (output.contains('Output file is empty, nothing was encoded')) {
String timestamp =
JidoujishoTimeFormat.getFfmpegTimestamp(const Duration(seconds: 1));
String command =
'-ss $timestamp -y -i "$inputPath" -frames:v 1 -q:v 2 "$targetPath"';
await _flutterFFmpeg.execute(command);
}
}