sannies / mp4parser

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

when I muxer h264 raw file into mp4, some error happend #164

Open xsjqqq123 opened 8 years ago

xsjqqq123 commented 8 years ago

hello, when I find a h264 raw stream file(size 6MB) from this site: [http://download.csdn.net/detail/mirroatl187/5627013] it can be played by VLC. I test it on android studio.it show me error like this: 02-19 12:15:02.773 26276-26276/com.xxx.xusongjie.androidmp4parsertest W/System: ClassLoader referenced unknown path: /data/app/com.xxx.xusongjie.androidmp4parsertest-2/lib/arm 02-19 12:15:02.882 26276-26303/com.xxx.xusongjie.androidmp4parsertest D/isoparser: FileDataSourceImpl:0 6291456 02-19 12:15:02.885 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: java.lang.IndexOutOfBoundsException: index=0, limit=0 02-19 12:15:02.891 26276-26304/com.xxx.xusongjie.androidmp4parsertest D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at java.nio.Buffer.checkIndex(Buffer.java:150) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:171) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.getNalUnitHeader(H264TrackImpl.java:106) 02-19 12:15:02.891 26276-26303/com.anjvision.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.readSamples(H264TrackImpl.java:300) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.parse(H264TrackImpl.java:117) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:88) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:93) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at org.mp4parser.muxer.tracks.h264.H264TrackImpl.<init>(H264TrackImpl.java:97) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at com.anjvision.xusongjie.androidmp4parsertest.MainActivity$1.run(MainActivity.java:29) 02-19 12:15:02.891 26276-26303/com.xxx.xusongjie.androidmp4parsertest W/System.err: at java.lang.Thread.run(Thread.java:818)

my test code: `new Thread(new Runnable() { @Override public void run() { try { String saveDir = Environment.getExternalStorageDirectory().getAbsolutePath(); H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(saveDir +"/test.h264")); Movie movie = new Movie(); movie.addTrack(h264Track); Container mp4file = new DefaultMp4Builder().build(movie); FileChannel fc = new FileOutputStream(new File(saveDir +"/output.mp4")).getChannel(); mp4file.writeContainer(fc); fc.close(); }catch (Exception e) { e.printStackTrace(); } Log.d("MainActivity", "finished");

        }
    }).start();`

is there any step I did not do?

eptanska commented 8 years ago

I'm also getting the same error when trying to create a H264TrackImpl for an .mp4 file created with Android's Muxer with MUXER_OUTPUT_MPEG_4. (Crash at H264TrackImpl.getNalUnitHeader, because there's no bytes available in the nal ByteBuffer)

Robbypatel1357 commented 7 years ago

i have same issue if can any one solve it?

GauravCreed commented 5 years ago

i have same issue if can any one solve it?