我有一个用 jcodec 生成的 MP4 文件。
然后我有一个使用 Android 的 MediaCodec 生成的 AAC 文件。
我想将它们混合到一个文件中,因为我不想将我的 Android API 限制得太高,所以我选择了MP4Parser。
这是我当前的代码:
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("input.mp4"));
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("input.aac"));
Movie movie = new Movie();
movie.addTrack(h264Track);
movie.addTrack(aacTrack);
Container mp4file = new DefaultMp4Builder().build(movie);
FileOutputStream fileOutputStream = new FileOutputStream(new File("output.mp4"));
FileChannel fc = fileOutputStream.getChannel();
mp4file.writeContainer(fc);
fileOutputStream.close();
代码在该行崩溃:
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("input.mp4"));
以此作为堆栈跟踪:
09-01 18:46:40.611: E/AndroidRuntime(14115): FATAL EXCEPTION: GLThread 1260
09-01 18:46:40.611: E/AndroidRuntime(14115): Process: package.app, PID: 14115
09-01 18:46:40.611: E/AndroidRuntime(14115): java.lang.RuntimeException: Sequence parameter set extension is not yet handled. Needs TLC.
09-01 18:46:40.611: E/AndroidRuntime(14115): at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.readSamples(H264TrackImpl.java:362)
09-01 18:46:40.611: E/AndroidRuntime(14115): at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.parse(H264TrackImpl.java:108)
09-01 18:46:40.611: E/AndroidRuntime(14115): at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.<init>(H264TrackImpl.java:90)
09-01 18:46:40.611: E/AndroidRuntime(14115): at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.<init>(H264TrackImpl.java:96)
09-01 18:46:40.611: E/AndroidRuntime(14115): at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.<init>(H264TrackImpl.java:100)
09-01 18:46:40.611: E/AndroidRuntime(14115): at ...
(在这一行的这个函数中发生了崩溃。)
所以我不太确定这意味着什么?jcodec 是否输出与 MP4Parser 不兼容的 MP4 文件(它适用于所有视频播放器)?
我应该研究什么来解决这个问题?
感谢任何建议。
编辑
以错误的方式进行,这有效
Movie movie = MovieCreator.build(_videoFile.getAbsolutePath());
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(_aacFile));
CroppedTrack aacCroppedTrack = new CroppedTrack(aacTrack, 1, aacTrack.getSamples().size());
movie.addTrack(aacCroppedTrack);
Container mp4file = new DefaultMp4Builder().build(movie);
FileOutputStream fileOutputStream = new FileOutputStream(_outputFile);
FileChannel fc = fileOutputStream.getChannel();
mp4file.writeContainer(fc);
fileOutputStream.close();