Using Flutter FFMPEG_KIT to convert a sequence of RGBA images into a mp4 video

221 Views Asked by At

I’m trying to convert a sequence of RGBA byte images into an MP4 video by using Flutter FFMPEGKit package. The following is the code snippet but it gives me an error. I’m not sure what is the correct option that I should use to convert a set of rawrgba images to a video. I appreciate any help.

 static Future<void> videoEncoder() async {
    appTempDir = '${(await getTemporaryDirectory()).path}/workPath';
   
    FFmpegKit.execute(
           '-hide_banner -y -f rawvideo -pix_fmt rgba -i appTempDir/input%d.rgba -c:v mpeg4  -r 12 appTempDir/output.mp4')
     .then((session) async {
       final returnCode = await session.getReturnCode();
      if (ReturnCode.isSuccess(returnCode)) {
        print('SUCCESS');
      } else if (ReturnCode.isCancel(returnCode)) {
        print('CANCEL');
      } else {
        print('ERROR');
      }
    });
  }
}

The image rgba data is saved via the following code snippet.

Utils.getBuffer(renderKey).then((value) async {
        ui.Image buffer = value;
        final data =
            await buffer!.toByteData(format: ui.ImageByteFormat.rawRgba);
        Uint8List uData = data!.buffer.asUint8List();
        VideoUtil.saveImageFileToDirectory(uData, 'input$frameNum.rgba');
        frameNum++;
        });
0

There are 0 best solutions below