Surime
Surime

Reputation: 25

How to extract all video frames using ffmpeg-kit with flutter

I'm trying to convert a file to a list of image file. Ideally with an option to extract a frame every X milliseconds.

Do you know if it possible to do so with flutter using ffmpeg?

Been trying with export_video_frame plugin but it is very slow and not stable.

Upvotes: 1

Views: 1882

Answers (1)

Siddharth Mehra
Siddharth Mehra

Reputation: 1899

Try the below snippet:

String command = "-i ${videoFilePath} -r $imagesCount -f image2 ${outputPath}image-%3d.png"
FFmpegKit.execute(command).then((session) async {
        final returnCode = await session.getReturnCode();

        if (ReturnCode.isSuccess(returnCode)) {
          print("Success!!!!");
        } else {
          print("Failed!!!!");
        }
      }
      );

Replace videoFilePath with the input file path and outputPath with the directory path where you want to save the images. Also, the imagesCount with how many images you want per frame.

Upvotes: 2

Related Questions