I am using these two libraries in my project:
Both libraries are imported locally to my project (i.e. copied them and added them to the project)
Both libraries work fine when used separately, but when I use them together I get some errors of type
Program type already present which I solved by deleting the file
isoparser-1.0.6.jar from the second library, because I noticed that the two libraries use the same library
'com.googlecode.mp4parser:isoparser' but with different versions:
1.1.21 for the first one and
1.0.6 for the second one.
When using only the old library, I get this code:
error: cannot find symbol class FileDataSourceViaHeapImpl
It is working now, but the problem the output video (after compression) does not have sound on it. How can I solve this?
Here is the code I am using for compressing the video (after trimming):
VideoController.getInstance().convertVideo(tmpFile.toString(), dstFile.toString(), VideoController.COMPRESS_QUALITY_MEDIUM, null);
Summering the scenarios here with the same video:
VideoTrimmingLikeWhatsapp with verion 1.1.21 => works
VideoTrimmingLikeWhatsapp with verion 1.0.6 => does not works (compile error of missing classes)
VideoCompressor with 1.1.21 => does not work (no sound)
VideoCompressor with 1.0.6 => work
I tried a lot of things, and I am loosing tracks here. I also tried using SiliCompressor which seems also using version 1.0.6 of mp4isoparser, and the same problem is happening, output video has no sound. I posted an issue here a few days ago, but I don’t think they will address this any time soon.
I also submitted here.
I tried downloading the mp4parser version 1.1.21 from here, and tried to import it locally so I can change the package names, but I couldn’t because it using
Gradle. The old version is a
jar file, and I need to decompile it so I can mess with it. Can I do that?
I also tried using
ffmpeg libraries, but all of them work very slowly compared to mp4isoparser
The author of SiliCompressor has replied to the here I opened, he says that the problem should be solved by now. For the moment I am unable to verify it, as I no longer work on that project. If any one can confirm it, just tell me to add the answer to this topic.
If the problem is really caused by the libraries version it is going to be tough to solve.
First I’d double check that. You said you tested the libs separately and that they worked, but, have you tried using the output of ‘VideoTrimmingLikeWhatsapp’ as input of ‘VideoCompressor’?
I’m suspecting that ‘VideoCompressor’ does weird things with audio in some circumstances, somebody in this issues says there is no audio:
If you get a video without sound using ‘VideoCompressor’ with his own version of ‘isoparser’ you can discard libraries version as the source of the problem.
Then, I think, you can: replace ‘VideoCompressor’: it seems to rely on Android libraries to perform the compression, you may implement that yourself, or you could find another library for doing the job. Or you can fix ‘VideoCompressor’: you could report the problem to the author or you could try to fix it yourself.
If you confirm the problem is the versions conflict: Then I can think several options, but none of them is easy:
You can try playing with classloaders and force each library to use their correct version of ‘isoparser’. This alone can be difficult to do, besides that it can be very problematic in Android.
You can patch one version of isoparser, renaming package names (for example to com.googlecode.mp4parser_old ) so two versions of them can coexist, you should also patch the client library for using the new package names. This is very ugly but seems doable.
You can try to update ‘VideoCompressor’ to be compatible with isoparser-1.1.21. You could also ask the author to do it.
Again, you could replace ‘VideoCompressor’ (or may be ‘VideoTrimmingLikeWhatsapp’)
I’m aware this is not the definitive answer but I hope it helps you a little.
It’s too late but i send this solution to be useful for others.
Yes, the problem is about version conflicts between the two libraries.
- Don’t touch video compressor library at all.
- Downgrade the “isoparser” dependency of video trimmer to the same version (1.0.6) with video compressor library dependency “isoparser”.
Remove the following line from TrimVideoUtils.java file:
Then change the following line:
Movie movie = MovieCreator.build(new FileDataSourceViaHeapImpl(src.getAbsolutePath()));
Movie movie = MovieCreator.build(src.getAbsolutePath());
NOTE: Be careful about large files. Because this solution doesn’t use memory mapping.