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.RuntimeException: A cast to int has gone wrong. Please contact the mp4parser discussion group #126

Closed
bkjbkjbnkj687698698 opened this issue Oct 29, 2015 · 5 comments

Comments

@bkjbkjbnkj687698698
Copy link

I am getting below exception on line m = MovieCreator.build(videopath); ..my video path is correct..what could be the reason of this exception?

Fatal Exception: java.lang.RuntimeException: A cast to int has gone wrong. Please contact the mp4parser discussion group (3217028852)
       at com.googlecode.mp4parser.util.CastUtils.l2i(CastUtils.java)
       at com.googlecode.mp4parser.AbstractBox.parse(AbstractBox.java)
       at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java)
       at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java)
       at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java)
       at com.googlecode.mp4parser.util.LazyList.blowup(LazyList.java)
       at com.googlecode.mp4parser.util.LazyList.size(LazyList.java)
       at com.googlecode.mp4parser.BasicContainer.getBoxes(BasicContainer.java)
       at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.<init>(DefaultMp4SampleList.java)
       at com.coremedia.iso.boxes.mdat.SampleList.<init>(SampleList.java)
       at com.googlecode.mp4parser.authoring.Mp4TrackImpl.<init>(Mp4TrackImpl.java)
       at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java)
       at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java)
    at android.os.Handler.handleCallback(Handler.java)
       at android.os.Handler.dispatchMessage(Handler.java)
       at android.os.Looper.loop(Looper.java)
       at android.app.ActivityThread.main(ActivityThread.java)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
@sannies
Copy link
Owner

sannies commented Oct 29, 2015

It looks like the parser encountered a box in the file larger than 2GB. Typically only the mdat box is larger than 2GB but the mdat box is prepared to deal with this situation. So my best guess is a corrupted file. Could you perhaps make this file available to me so I can check what's going on?

@bkjbkjbnkj687698698
Copy link
Author

I have sent u file on email..My file is only around 20 mb and i tried for different files.

@sannies
Copy link
Owner

sannies commented Oct 29, 2015

Hi,
the mergedvideo file is corrupted. Your 18MB file only contains a data section (mdat or MediaDataBox) at 4225 which reports a size of 0xF3AD67 = 15969639. 15969639 + 4225 = 15973864 but your file is 18827037 bytes. The last 2.9MB do not belong to any 'box'.
Grüße,
Sebastian

@sannies sannies closed this as completed Oct 29, 2015
@bkjbkjbnkj687698698
Copy link
Author

That file i created by appending videos using this library.What i noticed is that replacing audio in video works fine for normal video but gives above exception if i try to replace audio of appended video..
Below code I am using for appending video-

      File mediaStorageDir = new  File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES), "Videos");
    File f = new File(mediaStorageDir.getPath());
    File file[] = f.listFiles();
    String paths[] = new String[file.length];
    Movie[] inMovies = new Movie[file.length];
    for (int i = 0; i < file.length; i++) {
        paths[i] = file[i].getPath();
        inMovies[i] = MovieCreator.build(paths[i]);
    }
    List<Track> videoTracks = new LinkedList<Track>();
    List<Track> audioTracks = new LinkedList<Track>();
    for (Movie m : inMovies) {
        for (Track t : m.getTracks()) {
            if (t.getHandler().equals("soun")) {
                audioTracks.add(t);
            }
            if (t.getHandler().equals("vide")) {
                videoTracks.add(t);
            }
        }
    }
    Movie result = new Movie();
    if (audioTracks.size() > 0) {
        result.addTrack(new AppendTrack(audioTracks
                .toArray(new Track[audioTracks.size()])));
    }
    if (videoTracks.size() > 0) {
        result.addTrack(new AppendTrack(videoTracks
                .toArray(new Track[videoTracks.size()])));
    }
    BasicContainer out = (BasicContainer) new DefaultMp4Builder()
            .build(result);
    @SuppressWarnings("resource")
    FileChannel fc = new RandomAccessFile(String.format(Environment
            .getExternalStorageDirectory() + "/mergedvideo.mp4"),
            "rw").getChannel();
    out.writeContainer(fc);
    fc.close();
} catch (FileNotFoundException e) {
    e.printStackTrace();
    Log.e("Appending", e.toString());
} catch (IOException e) {
    e.printStackTrace();
    Log.e("Appending", e.toString());
}
String mFileName = Environment.getExternalStorageDirectory()
        .getAbsolutePath();
mFileName += "/mergedvideo.mp4";
return mFileName;

@kishanverma26
Copy link

why this issue is closed
is there anyone who solved this

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

3 participants