ffmpeg – How do i properly use Flutter FFmpegKit to convert video file formats to H.264?

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:

dev.to/usp/flutter-live-streaming-a-complete-guide-2634

medium.com/itnext/how-to-make-a-serverless-flutter-video-sharing-app-with-firebase-storage-including-hls-and-411e4fff68fa

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 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;
  }
} 

Read more here: Source link