Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate class import error with ffmpeg package #8

Closed
rlee1990 opened this issue Jan 28, 2023 · 19 comments
Closed

Duplicate class import error with ffmpeg package #8

rlee1990 opened this issue Jan 28, 2023 · 19 comments
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on

Comments

@rlee1990
Copy link

Hi is is possible to use the ffmpeg_kit_flutter instead of the one used in this package?
It causes issues with other packages that all use ffmpeg_kit_flutter.

@rlee1990 rlee1990 added the bug Something isn't working label Jan 28, 2023
@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Hi,
Renderuses ffmpeg_kit_flutter_https_gpl, which is a sub-package of ffmpeg_kit_flutter. Could you please provide the errors you are getting?
I suspect this is an import issue , which would mean you need to change the imports a bit:

Example: Instead of

import 'package:flutter/services.dart';

do:

import 'package:flutter/services.dart' as service;

service.yourMethod();

@rlee1990
Copy link
Author

rlee1990 commented Jan 28, 2023

The error I get is
Duplicate class com.arthenica.ffmpegkit.Statistics found in modules jetified-ffmpeg-kit-https-5.1-runtime
I receive this trying to build for android.
The other package that I am using is video_trimmer

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Ok got it. Have you tried changing the imports, like i have shown? In case this resolves this, i will adjust the import line in Renderpackage, so you can import like you would do normally....

Could you prepare a quick example for debugging, if this doesnt work? I will be on it right away!

@rlee1990
Copy link
Author

Ok got it. Have you tried changing the imports, like i have shown? In case this resolves this, i will adjust the import line in Renderpackage, so you can import like you would do normally....

Should I be changing them in your package or in the code I write because I don't directly use the services import

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

No the import in your code. Sorry, the service import was just an example. Change your Ffmepg / video_trimmerimport like the example.

@rlee1990
Copy link
Author

Sorry trying that now

@rlee1990
Copy link
Author

rlee1990 commented Jan 28, 2023

I am using flutter 3.7 if that makes a difference. I also tried removing video_trimmer and then it will build. Tried adding video_trimmer and removing the render packager and it builds.
Nope it still fails to build the application:

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-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) 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-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) 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-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.AsyncFFmpegExecuteTask found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.AsyncFFprobeExecuteTask found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.AsyncGetMediaInformationTask found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.BuildConfig found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.CameraSupport found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Chapter found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegKit found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegKitConfig found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegKitConfig$1 found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegKitConfig$2 found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegKitConfig$SAFProtocolUrl found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegSession found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFmpegSessionCompleteCallback found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFprobeKit found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFprobeSession found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.FFprobeSessionCompleteCallback found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Level found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Log found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.LogCallback found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.LogRedirectionStrategy found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.MediaInformation found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.MediaInformationJsonParser found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.MediaInformationSession found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.MediaInformationSessionCompleteCallback found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.NativeLoader found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Packages found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.ReturnCode found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Session found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.SessionState found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Signal found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.Statistics found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.StatisticsCallback found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)
     Duplicate class com.arthenica.ffmpegkit.StreamInformation found in modules jetified-ffmpeg-kit-https-5.1-runtime (com.arthenica:ffmpeg-kit-https:5.1) and jetified-ffmpeg-kit-https-gpl-5.1-runtime (com.arthenica:ffmpeg-kit-https-gpl:5.1)

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Thanks for the issue. Could you provide me with a quick and dirty example with video_trimmer import so i can run it and debug it?

@rlee1990
Copy link
Author

Sure Ill get started on that right now

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Also, can you check if this solution helps? This might be a multi dex issue and not related to this plugin.

@polarby polarby changed the title Switching ffmpeg package Duplicate class import error with ffmpeg package Jan 28, 2023
@rlee1990
Copy link
Author

Also, can you check if this solution helps? This might be a multi dex issue and not related to this plugin.

Yup I tried it and it still doesn't work. I will leave that in the example also.

@rlee1990
Copy link
Author

Okay the quick example is just a fork of your example and I added the video_trimmer package without using it in the code and get the errors still:
https://github.com/rlee1990/render

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Alright, I am on it, it might take some time!

@rlee1990
Copy link
Author

I also just did a test with the fork without deploying it back to github were I switched the FFMPEG to use the same one in video_trimmer and its working without an issue.

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

I was not able to find a satisfying solution for this error. It appears this is a problem happens always if there are multiple FFmpeg instances within one project. This can either be by multiple plugins imports that use Ffmpeg or a plugin with FFmpeg usage and own FFmpeg import. This error will happen with any plugin, when you use multiple instances like this.

What needs to be done?

As far as my research goes so far, there is no current appropriate resolution to this problem. As this is a double import problem of two different versions, a possible solution is to sync the Ffmpeg version number (which is not always easy, as some operations require different ffmpeg version).
It would be great to isolate the plugins that are used within a package, but I am not aware of any way to do this.

In this specific issue we have both a jetified-ffmpeg-kit-https-gpl-5.1(used by Render) and the jetified-ffmpeg-kit-https-5.1(used by video_trimmer) FFmpeg usage:

2 files found with path 'lib/arm64-v8a/libavcodec.so' from inputs:
      - /Users/myName/.gradle/caches/transforms-3/29473f64bb3a0e5823587658e804b0da/transformed/jetified-ffmpeg-kit-https-gpl-5.1/jni/arm64-v8a/libavcodec.so
      - /Users/myName/.gradle/caches/transforms-3/ac7665f545673455679b57f9a4d09ae7/transformed/jetified-ffmpeg-kit-https-5.1/jni/arm64-v8a/libavcodec.so

As jetified-ffmpeg-kit-https-gpl-5.1 includes jetified-ffmpeg-kit-https-5.1, it is possible to remove the import of the lower package and therefore only depend on one -the higher- import. Therefore in the following I will give a standardized solution to how to resolve it by correcting the imports:

Dirty solution

  1. Find the package with the denominator import by running flutter pub deps and search for all FFmpeg instances (highest import, with most functions -> in this case jetified-ffmpeg-kit-https-gpl-5.1, see hierarchy ffmpeg packages)

Do the the following procedure for all sub import plugins

  1. git clone <url to package> ./lib/package_name_copy (for the render example flutter project ./example/lib -> git clone https://github.com/sbis04/video_trimmer ./example/lib/video_trimmer_copy)
  2. Manually go to ./lib/package_name_copy/pubspec.yaml and change the ffmpeg dependency to the denominator one (in our case ffmpeg_kit_flutter_https_gpl: ^5.1.0)
  3. run flutter clean & flutter pub get

Note that you will archive the current version of this package to a local directory. This is a dirty solution as updating needs to be done manually like the described solution, and therefore can only be maintained with very few packages (aka Renderand Video_trimmer).

Using FFmpeg package with Renderplugin

  1. Find the package with the denominator-import by running flutter pub deps and search for all FFmpeg instances (see above)
  2. Use the denominator-import incase your default ffmpeg_kit_flutter import

If you find a better solution I would like to ask you to post it here as well so others can maybe do a cleaner import resolution.

Same issues

Just for references, here is a small segment many more issues that have the exact same problem:

Here are problems with same issues and with solutions, that I could not reproduce:

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

I am gonna close this issue for now, as there is a temporary solution. Please be sure to notify me if you think this issue is ongoing and update this issue if there is a better alternative!!!

@polarby polarby closed this as completed Jan 28, 2023
@polarby polarby added help wanted Extra attention is needed wontfix This will not be worked on labels Jan 28, 2023
@rlee1990
Copy link
Author

@polarby is there a reason why you don't use the same exact package of ffmpeg as video_trimmer?

@polarby
Copy link
Owner

polarby commented Jan 28, 2023

Yes, in order to work with the audio conversion the x264 of the https-gpl (http, which video_trimmer uses is not enough) is required:

final overwriteAudio = audio != null && audio!.isNotEmpty
? "-map??[v]??-map??[a]??-c:v??libx264??-c:a??"
"aac??-shortest??-pix_fmt??yuv420p??-vsync??2"
: "-map??[v]??-pix_fmt??yuv420p";

I am sorry that there currently isn't a better way to do this (or I couldn't find it yet), but I hope that you still decide to take advantage of the great functions of FFmpeg.

@rlee1990
Copy link
Author

@polarby thanks good to know. I am keeping the package and looking for alternatives for video_trimmer that will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants