我想在android中合并两个视频我正在关注此链接https://code.google.com/p/mp4parser/但它不适合我,所以请帮助我,谢谢,这是我的代码和日志猫错误: -
代码是:
MovieCreator mc = new MovieCreator();
try {
Movie video = mc.build(Channels.newChannel(MainActivity.class.getResourceAsStream("/video.mp4")));
Movie audio = mc.build(Channels.newChannel(MainActivity.class.getResourceAsStream("/funnysardar.mp4")));
List<Track> videoTracks = video.getTracks();
video.setTracks(new LinkedList<Track>());
List<Track> audioTracks = audio.getTracks();
for (Track videoTrack : videoTracks) {
video.addTrack(new AppendTrack(videoTrack, videoTrack));
}
for (Track audioTrack : audioTracks) {
video.addTrack(new AppendTrack(audioTrack, audioTrack));
}
IsoFile out = new DefaultMp4Builder().build(video);
FileOutputStream fos = new FileOutputStream(new File(String.format("output.mp4")));
out.getBox(fos.getChannel());
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
log cat错误是: -
07-29 07:29:08.120: E/AndroidRuntime(6456): FATAL EXCEPTION: main
07-29 07:29:08.120: E/AndroidRuntime(6456): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.merge/com.example.merge.MainActivity}: java.lang.NullPointerException
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.os.Looper.loop(Looper.java:123)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-29 07:29:08.120: E/AndroidRuntime(6456): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 07:29:08.120: E/AndroidRuntime(6456): at java.lang.reflect.Method.invoke(Method.java:507)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-29 07:29:08.120: E/AndroidRuntime(6456): at dalvik.system.NativeStart.main(Native Method)
07-29 07:29:08.120: E/AndroidRuntime(6456): Caused by: java.lang.NullPointerException
07-29 07:29:08.120: E/AndroidRuntime(6456): at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:350)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:55)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.coremedia.iso.IsoFile.next(IsoFile.java:162)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.coremedia.iso.IsoFile.hasNext(IsoFile.java:138)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.googlecode.mp4parser.util.LazyList$1.hasNext(LazyList.java:55)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.coremedia.iso.IsoFile.getMovieBox(IsoFile.java:241)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:57)
07-29 07:29:08.120: E/AndroidRuntime(6456): at com.example.merge.MainActivity.onCreate(MainActivity.java:32)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 07:29:08.120: E/AndroidRuntime(6456): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
答案 0 :(得分:0)
com.coremedia.iso.PropertyBoxParserImpl;
InputStream inputStream = getClass().getResourceAsStream("/isoparser-default.properties");
在Android项目中,这是:inputStream = null;