4

The problem

i am trying to trim and compress a video using two libraries: Silicompressor and k4l-video-trimmer. the problem is both libraries use mp4parser but different versions of it. k4l-video-trimmer is using version 1.1.20 as a dependency in build.gradle and Silicompressor is using version 1.0.6 as a jar file. now the project builds fine but when i try to run it, i get the error:

More than one file was found with OS independent path 'builddef.lst'

The things i have already tried

Exclude builddef.lst in packaging options

i added these lines in app level build.gradle:

android {
    packagingOptions {
        exclude 'builddef.lst'
        exclude 'version.txt'
        exclude 'isoparser-default.properties'
    }
}

and then i got another error which i was unable to solve:

Program type already present: com.coremedia.iso.BoxParser Message{kind=ERROR, text=Program type already present: com.coremedia.iso.BoxParser, sources=[Unknown source file], tool name=Optional.of(D8)}

Exclude mp4parser from k4l-video-trimmer

i used

implementation ('life.knowledge4:k4l-video-trimmer:1.0') {
    exclude group: 'com.googlecode.mp4parser'
}

instead of

implementation 'life.knowledge4:k4l-video-trimmer:1.0'

and now the project runs and crashes when i try to trim a video.

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/googlecode/mp4parser/FileDataSourceViaHeapImpl; at life.knowledge4.videotrimmer.utils.TrimVideoUtils.genVideoUsingMp4Parser(TrimVideoUtils.java:72) at life.knowledge4.videotrimmer.utils.TrimVideoUtils.startTrim(TrimVideoUtils.java:65) at life.knowledge4.videotrimmer.K4LVideoTrimmer$5.execute(K4LVideoTrimmer.java:354) at life.knowledge4.videotrimmer.utils.BackgroundExecutor$Task.run(BackgroundExecutor.java:212) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

Exclude mp4parser from Silicompressor

i imported Silicompressor's module instead of using dependency line and removed mp4parser's jar file to force the library to use the version 1.1.20. now app runs again but the compressed video has no audio!

Use both versions of mp4parser

i used jarjar to repackage the jar file Silicompressor was using from com.googlecode.mp4parser to org.repackage.com.googlecode.mp4parser. still having the very same issue.

Build.gradle

here's my app level build.gradle file:

apply plugin: 'com.android.application'

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "---"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        google()
        jcenter({url "http://jcenter.bintray.com/"})
        mavenLocal()
        jcenter()
        maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.google.com' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    }

    /*packagingOptions {
        exclude 'builddef.lst'
        exclude 'version.txt'
        exclude 'isoparser-default.properties'
    }*/
}

dependencies {
    ...
    implementation ('life.knowledge4:k4l-video-trimmer:1.0') {
        exclude group: 'com.googlecode.mp4parser'
    }
    implementation 'com.iceteck.silicompressorr:silicompressor:2.1'
}

and THANK YOU FOR YOUR TIME!

M.Nik
  • 81
  • 1
  • 8
  • no idea? i still can't figure it out... – M.Nik Jul 14 '18 at 19:31
  • bro I am also using these lib but having same problem....I figured it out what is the problem but I don't know how to solve this .... it is because of the isoparser they use in the library .... – lllllllllllllll Jul 17 '18 at 09:22
  • I downloaded the library file of both **sillicompressor** and **k4l trimmer** .....then I saw they were using different isoparser .......**sillicompressor** uses custom isoparser ...but k4l-trimmer uses **GitHub sannies.mp4parser** [https://github.com/sannies/mp4parser] ..**please reply me after seeing this** .... – lllllllllllllll Jul 17 '18 at 09:29
  • silicompressor is not using custom isoparser. it's just using jar file. because it works just fine with "implementation 'com.googlecode.mp4parser:isoparser:1.0.6'" – M.Nik Jul 18 '18 at 02:59
  • yes...sorry ..but thats what I am telling about ...and did you solved your problem...please tell me how did you solved this problem – lllllllllllllll Jul 18 '18 at 07:14
  • if sillicompressor remove the **jar.file** the compressor will not work ..it shows video cannot be played.. – lllllllllllllll Jul 18 '18 at 07:25
  • i haven't solved it yet. – M.Nik Jul 18 '18 at 12:10
  • so whats next??? what are you going to do even I can't find answer.....if we don't find answer than we should find another library which uses isoparser.jar or google mp4 parser .. – lllllllllllllll Jul 18 '18 at 13:58
  • please tell me if you find the way to solve ....I also help you if I found answer – lllllllllllllll Jul 18 '18 at 14:04
  • bro did you find the answer... – lllllllllllllll Jul 19 '18 at 12:29
  • did you find the answer – lllllllllllllll Jul 21 '18 at 13:17
  • @M.Nik have you find any solution because i am facing same issue. – Milan Pansuriya Oct 25 '18 at 12:48
  • @M.Nik if you find solution plz update with solution – Milan Pansuriya Oct 25 '18 at 12:48
  • 1
    @MilanPansuriya i did actually. i don't remember details now but as far as i remember, i just used version 1.0.6 and i went through k4l-video-trimmer's code and there was a simple exception happening there. i just removed it and everything worked fine. i'll post a detailed answer in a few days. – M.Nik Oct 26 '18 at 15:23
  • Thanks bro also I had achieved this way to resolve the issue. – Milan Pansuriya Oct 27 '18 at 07:21
  • @MilanPansuriya I am facing the same issue. Can you please explain in details what you guys did to solve the issue. After forcing k4l-video-trimmer to use 1.0.6 version I am getting error "cannot find FileDataSourceViaHeapImpl". – Shubhendra Singh Jan 23 '19 at 10:15
  • 1
    @ShubhendraSingh I had created combine lib with kl-trimmer and Silicompressor and include this project as a lib and add jar file in my lib – Milan Pansuriya Jan 23 '19 at 11:24
  • @MilanPansuriya Thanks for the help. Now working fine for me too. – Shubhendra Singh Jan 25 '19 at 13:53

2 Answers2

3

With the help of @MilanPansuriya I was finally able to solve the issue. Follow below steps to resolve above issue:-

  1. Create a new library combining both libraries (kl-trimmer and Silicompressor). In my case it was (kl-trimmer and VideoCompressor (https://github.com/fishwjy/VideoCompressor/)).
  2. Use isoparser-1.0.6.jar in your library.
  3. Now after building your new library you will get an error in class TrimVideoUtils of library kl-trimmer.
  4. Error will be for FileDataSourceViaHeapImpl not found. Actually particular class is available in higher version of isoparser. Change it to FileDataSourceImpl.
  5. Now library will build just fine in your project.

Note:- Both libraries will work fine now, but since we have changed FileDataSourceViaHeapImpl to FileDataSourceImpl sometimes I am getting Out Of Memory while trimming some large size videos (which is obviously supposed to happen & is also reported by users of older version of kl-trimmer).

As of now this is the only solution I am able to get. If someone have a better solution please update us too. Thanks.

Shubhendra Singh
  • 456
  • 1
  • 6
  • 16
  • @ Shubhendra Singh - I found Siliprocessor to be better than fishwjy. I needed to put together the capability to trim videos and compress them at the same time for my project. Didn't find one that could do both at the same instance though stand alone libraries are available and hence this effort. https://github.com/Indark-a-bit/pick-trim-compress-mp4-videos Unzip the file to a folder and you are all set to go! Hope some one finds it useful. Cheers! – Indark Jul 15 '19 at 16:09
  • @Indark Thanks for the update. This will definitely help someone in future. – Shubhendra Singh Jul 16 '19 at 06:37
1

I was able to resolve this problem by doing just what the above answer says (combining both libraries) but in my case, i'm using SiliCompressor and AndroidDeveloperLB/VideoTrimmer, and i also created a library just for anyone who comes across this issue and wants a quick fix :) https://github.com/tobioyelekan/VideoTrimmerCompressor

Tobi Oyelekan
  • 362
  • 5
  • 19