简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM