mp4parser
mp4parser copied to clipboard
java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0)
The library sucks from the first line of code:
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(baseDir + "/sample2.mp4"));
java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0)
at java.nio.Buffer.checkIndex(Buffer.java:528)
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:212)
at com.googlecode.mp4parser.authoring.tracks.h264.H264TrackImpl.getNalUnitHeader(H264TrackImpl.java:96)
at com.googlecode.mp4parser.authoring.tracks.h264.H264TrackImpl.readSamples(H264TrackImpl.java:285)
at com.googlecode.mp4parser.authoring.tracks.h264.H264TrackImpl.parse(H264TrackImpl.java:107)
at com.googlecode.mp4parser.authoring.tracks.h264.H264TrackImpl.
I have same issue, found any solution ????
Yeah i have the same error.
I also Have Same error Anyone have any solution
I have the same error when trying to parse this file: https://ia600502.us.archive.org/7/items/NuclearExplosion/NuclearExplosionwww.keepvid.com.mp4
This issue is fixed in the latest release
implementation 'org.mp4parser:isoparser:1.9.41'
implementation 'org.mp4parser:muxer:1.9.41'
implementation 'org.mp4parser:streaming:1.9.41'
I have tested with @reijin90 video and it is working fine.
Please close this issue.
Hi @HBiSoft , i just ran into the same issue again.
Tested with my own mp4 video and @reijin90 video, both of them throw me IndexOutOfBoundException
java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0)
at java.nio.Buffer.checkIndex(Buffer.java:556)
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:224)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.getNalUnitHeader(H264TrackImpl.java:116)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.readSamples(H264TrackImpl.java:306)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.parse(H264TrackImpl.java:138)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:98)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:103)
at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:107)
at com.otaliastudios.cameraview.demo.CameraActivity.concatenateVideo(CameraActivity.java:441)
at com.otaliastudios.cameraview.demo.CameraActivity.onClick(CameraActivity.java:299)
at android.view.View.performClick(View.java:7259)
at android.view.View.performClickInternal(View.java:7236)
at android.view.View.access$3600(View.java:801)
at android.view.View$PerformClick.run(View.java:27892)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I am using
implementation 'org.mp4parser:isoparser:1.9.41'
implementation 'org.mp4parser:muxer:1.9.41'
implementation 'org.mp4parser:streaming:1.9.41'
Using the code example from demo app, any help would be very much appreciated, thanks!
After some researching, i found a work around. If you have a mp4 video, try install ffmpeg CLI tools, for mac users, brew install ffmpeg. Once it's installed, then run ffmpeg -i input.mp4 -vcodec copy -bsf h264_mp4toannexb -an -f h264 output.h264 to convert mp4 to h264 first which can ben later fed into your code, you could find reference from StackOverflow