mp4parser version conflict (compressed video has no sound)
Asked Answered
I

3

11

I am using these two libraries in my project:

https://github.com/HemendraGangwar/VideoTrimmingLikeWhatsapp https://github.com/fishwjy/VideoCompressor

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);

EDIT1

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 Maven not 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

EDIT 2

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.

Isabeau answered 30/7, 2018 at 13:27 Comment(0)
S
5

This combination worked for me:

implementation 'com.iceteck.silicompressorr:silicompressor:2.2.3'
implementation ('com.googlecode.mp4parser:isoparser:1.0.6') {
         exclude group: 'org.aspectj', module: 'aspectjrt' 
}

Credit to: https://github.com/AndreyAsadchy https://github.com/Tourenathan-G5organisation/SiliCompressor/issues/141#issuecomment-625308490

Sarrusophone answered 16/6, 2020 at 11:56 Comment(1)
this works when proguard is off but app crashes when proguard is on. Can you please share which pro-guard rules you added for this one?Tondatone
T
0

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:

https://github.com/fishwjy/VideoCompressor/issues/1

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.

Trevor answered 4/8, 2018 at 7:39 Comment(5)
you can: replace 'VideoCompressor': it seems to rely on Android libraries to perform the compression, you may implement that yourself. How to do that? any links please? See post EDIT1 for more of what I have doneIsabeau
Well, VideoCompressor is opensource, you could read the code and fix or reimplement it, but.. yeah can be a LOT of work. This problem you are facing looks very weird, give me some time, I'll try further investigation.Trevor
Hi again, I'm trying VideoCompressor using his intended isoparser version (1.0.6), and the resulting video has no audio! , could you provide a sample video? Alternatively, could you try converting this one: archive.org/download/Test_Avi/MVI_0043.AVITrevor
@fontkap I tried using your video, but the output is just a file of 140B which is not playable at all. Here a file and is working only when using old version drive.google.com/open?id=1jWhzdKUuT8Lb5i8NYlUQF6-3CYRaGD4cIsabeau
This is super weird, that is what I get: drive.google.com/open?id=1Clw1IXZp1aJK16y-EvjZKwT2TT3ZImAS small video of 57kb, but pefectly playable. I'll try your file. If it is useful info for you I'm using my phone for running the sample VideoCompressor app, it is a Moto G (XT1072).Trevor
A
0

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.

Solution:

  • 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:

    import com.googlecode.mp4parser.FileDataSourceViaHeapImpl;
    

    Then change the following line:

    Movie movie = MovieCreator.build(new FileDataSourceViaHeapImpl(src.getAbsolutePath()));
    

    To

    Movie movie = MovieCreator.build(src.getAbsolutePath());
    

It's done.

NOTE: Be careful about large files. Because this solution doesn't use memory mapping.

Anteater answered 19/2, 2020 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.