sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.76k stars 566 forks source link

mp4parser compatibility issue with Unity #263

Open RandomCouch opened 7 years ago

RandomCouch commented 7 years ago

Hi,

I was trying to use mp4parser as an android Unity plugin in order to combine two mp4 files and was having some difficulties.

My issue was that the InputStream in PropertyBoxParserImpl.java wasn't loading properly, it was failing to retrieve the isoparser-default.properties file InputStream is = getClass().getResourceAsStream("/isoparser-default.properties");

I've actually fixed this by moving the isoparser-default.properties file inside the src/assets folder Edit: Actually, the above was wrong, moving the file inside src/assets did not change anything, what I did was rewrite the file from Unity streaming assets directory into the app's local data directory on the device.

And then changing the previous line to InputStream is = UnityPlayer.currentActivity.getApplicationContext().getAssets().open("isoparser-default.properties");

This worked for me, so I figured I'd let you know here instead of making a pull request because that code would obviously not work natively (without UnityPlayer)

pajama commented 7 years ago

@RandomCouch sorry for the naive question. Did you have to rebuild this library from source to make this changes for Unity? I'm having a hard time getting android studio to read the repo as a project and build it. My android dev chops are lacking to say the least. Any tips greatly appreciated!

RandomCouch commented 7 years ago

Hey @pajama , I actually put this library's .jar inside my libs folder and I copied 3 files from it to my project: IsoFile2.java MovieCreator2.java and PropertyBoxParserImpl2.java and then replaced the class links in each accordingly, all in order to change that one line in PropertyBoxParserImpl class, and in my main activity I used MovieCreator2().build(file)

pajama commented 7 years ago

@RandomCouch, thanks so much for replying!

Ok cool, this all sounds good, because I can not for the life of me build from source. Been trying to get maven working.This is all still pretty far over my head, but I'm gonna give it a shot.

It seems you are using the jar for version 2? Where did you find that? The maven link goes to 1.1.2.

Any tips on replacing class links? I assume I can just unzip the jar, grab those three files and put them in my project, then zip it back up, then google how to relink class files. But it's never that simple is it...

RandomCouch commented 7 years ago

@pajama I am using 1.1.22, I could not find any link to version 2 unfortunately, I am still just a beginner heh

What I did is just copy those files and the code, and instead of using the classes in the jar I use the classes I copied in order to use my modified code

pajama commented 7 years ago

You are a saint! Thank you!