0

I use the ffmpeg_kit_flutter which take a list of image and make a video and i am not be able to run my app.

Future<void> createVideoFromImages(List<Uint8List> images) async {
  final tempDir = await getTemporaryDirectory();
  final videoPath = '${tempDir.path}/output_${DateTime.now().millisecondsSinceEpoch}.mp4';

  final imagePaths = <String>[];

  for (int i = 0; i < images.length; i++) {
    final imagePath = '${tempDir.path}/image$i.png';
    await File(imagePath).writeAsBytes(images[i]);
    imagePaths.add(imagePath);
  }

  final ffmpegCommand = [
    '-framerate', '7',
    '-i', '${tempDir.path}/image%d.png',
    '-c:v', 'libx264',
    '-pix_fmt', 'yuv420p',
    videoPath,
  ];

  final session = await FFmpegKit.executeWithArguments(ffmpegCommand);

  final logs = await session.getLogs(); // Get the logs

  for (final log in logs) {
    print(log.getMessage()); // Print each log message
  }

  if (ReturnCode.isSuccess(await session.getReturnCode())) {
    await GallerySaver.saveVideo(videoPath);
    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(
        content: Text('Video saved to gallery'),
      ),
    );
  } else {
    print('Error: Video creation failed');
  }
}

I think the error is in the package
The error log:

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.arthenica.ffmpegkit.Abi found in modules jetified-ffmpeg-kit-https-6.0-runtime (com.arthenica:ffmpeg-kit-https:6.0) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)

Duplicate class com.arthenica.ffmpegkit.AbiDetect found in modules jetified-ffmpeg-kit-https-6.0-runtime (com.arthenica:ffmpeg-kit-https:6.0) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)

Duplicate class com.arthenica.ffmpegkit.AbstractSession found in modules jetified-ffmpeg-kit-https-6.0-runtime (com.arthenica:ffmpeg-kit-https:6.0) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)

How can I handle this error?

mortalis
  • 2,060
  • 24
  • 34
  • It's comething about the dependency tree. You have 2 libraries with the same class name `com.arthenica:ffmpeg-kit-https:6.0` and `com.arthenica:ffmpeg-kit-https-gpl:5.1`. Check where they come from and how to remove one of them. Search for gradle commands on how to print dependency tree, how to exclude dependencies. Check your build.gradle, maybe you have 2 libraries there and can remove one of them. I would even clear the gradle cache, removing/renaming the `.gradle` directory in the user profile and build the project again to see if the conflict repeats. – mortalis Aug 30 '23 at 16:23

0 Answers0