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

java.lang.ArrayIndexOutOfBoundsException: length=8; index=8 #101

Closed
m-o opened this issue Aug 18, 2015 · 12 comments
Closed

java.lang.ArrayIndexOutOfBoundsException: length=8; index=8 #101

m-o opened this issue Aug 18, 2015 · 12 comments

Comments

@m-o
Copy link

m-o commented Aug 18, 2015

Hi, I am having strange problem. I am recording vidoe files from Android surface(originally from GoPro3) and I am adding audio track.
I get exception on some files. I can play those files, ffprobe does not show anything strange. And the error shows only in combination with audio track.

Example:
Load mp4 - load video8, extract video track, add to new Movie, save - ok;
Load mp4 - load video9, extract video track, add to new Movie, save - ok;
Load mp4 - load video8. extract video, add to new Movie, load .aac file, add to movie, ok;
Load mp4 - load video9. extract video, add to new Movie, load .aac file, add to movie, error;

Files are here: https://www.dropbox.com/sh/jvrd5qovoz488du/AACbFSWHNCxqVO1CE1dTwGIca?dl=0

Here is my code:

public void openFiles(){
        String dir = Environment.getExternalStorageDirectory()+"/";
        try {
            String video = dir + "video_track9.mp4";
            Movie originalVideo = MovieCreator.build(video);
            List<Track> tracks = originalVideo.getTracks();
            Track videoTrack = null;
            for (int i = 0; i < tracks.size(); i++) {
                Track t = tracks.get(i);
                if (t.getHandler().equals("vide")){
                    videoTrack = tracks.get(i);
                }
            }
            if(null != videoTrack) {
                Log.d("Main", "start saving: ");
                Uri uri = Uri.parse(dir + "/twentysec.aac");
                AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(uri.getPath()));
                Movie movie = new Movie();
                movie.addTrack(aacTrack);
                movie.addTrack(videoTrack);
                Container mp4file = new DefaultMp4Builder().build(movie);
                FileChannel fc = new FileOutputStream(dir + "test_output_track9.mp4").getChannel();
                mp4file.writeContainer(fc);
                fc.close();
                Log.d("Main", "saving done: " + video);
            }
            else{
                Log.d("Main", "mo video track");
            }
        } catch (IOException e) {
            e.printStackTrace();
            Log.d("Muxing",e.toString());
        }
    }

And here is full exception:

java.lang.ArrayIndexOutOfBoundsException: length=8; index=8
        at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStco(DefaultMp4Builder.java:497)
        at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStbl(DefaultMp4Builder.java:360)
        at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createTrackBox(DefaultMp4Builder.java:321)
        at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createMovieBox(DefaultMp4Builder.java:225)
        at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:115)
        at com.example.marek.audiorecorder.MainActivity.openFiles(MainActivity.java:92)
        at com.example.marek.audiorecorder.MainActivity.onClick(MainActivity.java:68)
        at android.view.View.performClick(View.java:4761)
        at android.view.View$PerformClick.run(View.java:19767)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5312)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

The problem is, I do not know where to look for the error. Is it in video or audio track?
Also, when I tried to use FragmentedMp4Builder - the movie was saved. But library I use for reading the final file had problems reading it, so FragmentedMp4Builder is not a solution for me...
The error log shows error on line:

Container mp4file = new DefaultMp4Builder().build(movie);

Thanks for repsonse!

@m-o
Copy link
Author

m-o commented Aug 18, 2015

Edit: I tried to use diferent audio file, and the problems are the same: vide8 ok, video9 error.

@sannies
Copy link
Owner

sannies commented Aug 18, 2015

Are you using one of the latest builds?
When I do:

public static void main(String[] args) {
    String baseDir = "c:\\users\\sannies\\Downloads\\";
    Movie vt8 = MovieCreator.build(baseDir + "video_track8.mp4");
    Movie vt9 = MovieCreator.build(baseDir + "video_track9.mp4");
    Track audio = new AACTrackImpl(new FileDataSourceImpl(baseDir + "twentysec.aac"));
    vt8.addTrack(audio);
    vt9.addTrack(audio);
    Mp4Builder builder = new DefaultMp4Builder();
    Container c = builder.build(vt8);
    c.writeContainer(new FileOutputStream("vt8.mp4").getChannel());
    c = builder.build(vt9);
    c.writeContainer(new FileOutputStream("vt9.mp4").getChannel());
}

in the master branch both videos just work fine (Do I assume correctly that the audio is silence?)

Would you please try version 1.1.2 from https://oss.sonatype.org/content/repositories/comgooglecodemp4parser-1071/

That should help!

@m-o
Copy link
Author

m-o commented Aug 18, 2015

I had version 1.0.6. When I added 1.1.2 I am getting error on both files:

java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;)V in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStco(DefaultMp4Builder.java:477)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStbl(DefaultMp4Builder.java:362)

On line:

Container container = mp4file.build(originalVideo);

And yes, the file is mute. It is just for testing purposses, I will be adding real audio later.

@sannies
Copy link
Owner

sannies commented Aug 18, 2015

Ohhh my ...
I accidentally used List.sort(Comparator) which is only available in Java 8 and therefore not on Android and earlier version of the JSDK. I'm replacing it with Collections.sort(List, Comparator) and build a new build. Gimme 10 minutes

@sannies
Copy link
Owner

sannies commented Aug 18, 2015

@m-o
Copy link
Author

m-o commented Aug 18, 2015

Hi, thank you for the prompt fix. But after I updated the library and cleaned the project, when I try to combine files I get similar error:

 Process: com.example.marek.audiorecorder, PID: 19590
    java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;)V in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder$InterleaveChunkMdat.<init>(DefaultMp4Builder.java:650)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder$InterleaveChunkMdat.<init>(DefaultMp4Builder.java:646)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:127)

@sannies
Copy link
Owner

sannies commented Aug 18, 2015

Oh my, there was a second one. Could you please grab the master branch and
build it on your own. I removed this second List.sort that caused you to
trip but there might be more. I don't have the time to build a new release
right now or do a thorough review.

Thank you!

Marek Ovečka notifications@github.com schrieb am Di., 18. Aug. 2015 um
20:49 Uhr:

Hi, I updated the library and cleaned the project, but when I try to
combine files I get similar error:

Process: com.example.marek.audiorecorder, PID: 19590
java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;)V in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)
at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder$InterleaveChunkMdat.(DefaultMp4Builder.java:650)
at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder$InterleaveChunkMdat.(DefaultMp4Builder.java:646)
at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:127)


Reply to this email directly or view it on GitHub
#101 (comment).

@m-o
Copy link
Author

m-o commented Aug 19, 2015

Ok, thank you. I will try to build it.

@m-o
Copy link
Author

m-o commented Aug 19, 2015

Hi, I made build but it gives me error on all files:

E/AndroidRuntime﹕ FATAL EXCEPTION: Timer-0
Process: easycoremedia.vucaster, PID: 18007
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.(DefaultMp4SampleList.java:57)
at com.coremedia.iso.boxes.mdat.SampleList.(SampleList.java:33)
at com.googlecode.mp4parser.authoring.Mp4TrackImpl.(Mp4TrackImpl.java:61)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:57)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:38)
at easycoremedia.vucaster.BufferingMuxer.createFinalMix(BufferingMuxer.java:145)
at easycoremedia.vucaster.BufferingMuxer.access$400(BufferingMuxer.java:33)
at easycoremedia.vucaster.BufferingMuxer$StopRecording.run(BufferingMuxer.java:84)
at java.util.Timer$TimerImpl.run(Timer.java:284)

I do not know, if I made some mistake when building the .jar.
I will be off the internet for few days, so I will be back to this issue after weekend.

@m-o
Copy link
Author

m-o commented Aug 25, 2015

Hi, I am still getting this error. I dot know, what I am doing wrong. Could you please create build off current version? Thank you!

@sannies
Copy link
Owner

sannies commented Aug 26, 2015

Please find 1.1.4 here:

https://oss.sonatype.org/content/repositories/comgooglecodemp4parser-1073

2015-08-25 15:09 GMT+02:00 Marek Ovečka notifications@github.com:

Hi, I am still getting this error. I dot know, what I am doing wrong.
Could you please create build off current version? Thank you!


Reply to this email directly or view it on GitHub
#101 (comment).

@m-o
Copy link
Author

m-o commented Aug 30, 2015

Works great, thank you!

@m-o m-o closed this as completed Aug 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants