I’ve been using GPT and publications from Medium to help with my how I’m supposed to use the FFmpeg kit for Flutter but they have been no help. Perhaps I need clarification on what the tool is supposed to do because links like these below have not been of any help and are very outdated:
https://dev.to/usp/flutter-live-streaming-a-complete-guide-2634
https://medium.com/itnext/how-to-make-a-serverless-flutter-video-sharing-app-with-firebase-storage-including-hls-and-411e4fff68fa
https://github.com/arthenica/ffmpeg-kit/blob/main/flutter/flutter/README.md
This is the code i’ve been trying to run to convert a video file before I upload to Firestore Database.
Future<Uint8List?> convertToH264(Uint8List bytes) async {
try {
final filename = const Uuid().v4();
final tempDir = await getTemporaryDirectory();
final tempVideoFile = File('${tempDir.path}/$filename.mp4');
await tempVideoFile.writeAsBytes(bytes);
final outputPath = '${tempDir.path}/$filename-aac.mp4';
await FFmpegKit.execute(
'-i ${tempVideoFile.path} -c:v libx264 -c:a aac $outputPath',
);
return await File(outputPath).readAsBytes();
} catch (e) {
rethrow;
}
}