尝试合并mp4视频时应用崩溃

时间:2014-08-11 12:43:20

标签: android video mp4parser

我下载了mp4parser的最新源代码,并使用它来组合两个mp4文件。 当我尝试结合两个mp4视频应用程序崩溃。

当我运行这行代码时

  MovieCreator.build("mnt/sdcard/CamVideo/0.mp4")

应用程序崩溃并且崩溃日志是

  08-11 17:27:49.023: E/AndroidRuntime(24864): FATAL EXCEPTION: main
  08-11 17:27:49.023: E/AndroidRuntime(24864): java.lang.ArrayIndexOutOfBoundsException:             length=0; index=0
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.<init>(DefaultMp4SampleList.java:52)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.coremedia.iso.boxes.mdat.SampleList.<init>(SampleList.java:33)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.googlecode.mp4parser.authoring.Mp4TrackImpl.<init>(Mp4TrackImpl.java:59)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:58)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:39)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.coderzheaven.pack.CustomCameraActivity.MergeVideos(CustomCameraActivity.java:200)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.coderzheaven.pack.CustomCameraActivity$1.onClick(CustomCameraActivity.java:108)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.view.View.performClick(View.java:4274)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.view.View$PerformClick.run(View.java:17357)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.os.Handler.handleCallback(Handler.java:615)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.os.Handler.dispatchMessage(Handler.java:92)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.os.Looper.loop(Looper.java:137)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at android.app.ActivityThread.main(ActivityThread.java:4949)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at java.lang.reflect.Method.invoke(Method.java:511)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
  08-11 17:27:49.023: E/AndroidRuntime(24864):  at dalvik.system.NativeStart.main(Native Method)

我正在使用示例代码中的相同属性文件&#34; isoparser-custom.properties&#34;和&#34; isoparser-default.properties&#34;

我期待电影对象应该正确构建。任何人都可以告诉我在这方面做错了什么,或者可以向我发送合并两个mp4文件的完整功能代码。

编辑: 我下载了这个文件&#34; isoparser-1.0.2.jar&#34;来自maven项目(http://repo1.maven.org/maven2/com/googlecode/mp4parser/isoparser/1.0.2/),但应用程序崩溃了这个崩溃报告

  08-18 17:32:20.571: E/AndroidRuntime(31446): FATAL EXCEPTION: main
  08-18 17:32:20.571: E/AndroidRuntime(31446): java.lang.ExceptionInInitializerError
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at java.lang.Class.classForName(Native Method)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at java.lang.Class.forName(Class.java:217)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at java.lang.Class.forName(Class.java:172)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coremedia.iso.PropertyBoxParserImpl.createBox(PropertyBoxParserImpl.java:86)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:102)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java:155)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java:131)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.googlecode.mp4parser.util.LazyList$1.hasNext(LazyList.java:55)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coremedia.iso.IsoFile.getMovieBox(IsoFile.java:109)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:48)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:35)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coderzheaven.pack.CustomCameraActivity.MergeVideos(CustomCameraActivity.java:200)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coderzheaven.pack.CustomCameraActivity$1.onClick(CustomCameraActivity.java:108)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.view.View.performClick(View.java:3517)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.view.View$PerformClick.run(View.java:14155)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.os.Handler.handleCallback(Handler.java:605)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.os.Handler.dispatchMessage(Handler.java:92)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.os.Looper.loop(Looper.java:137)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at android.app.ActivityThread.main(ActivityThread.java:4666)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at java.lang.reflect.Method.invoke(Method.java:511)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at dalvik.system.NativeStart.main(Native Method)
  08-18 17:32:20.571: E/AndroidRuntime(31446): Caused by: java.lang.NoClassDefFoundError: org.aspectj.runtime.reflect.Factory
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coremedia.iso.boxes.FileTypeBox.ajc$preClinit(FileTypeBox.java:1)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  at com.coremedia.iso.boxes.FileTypeBox.<clinit>(FileTypeBox.java:1)
  08-18 17:32:20.571: E/AndroidRuntime(31446):  ... 24 more

1 个答案:

答案 0 :(得分:3)

当你自己构建mp4parser时,你没有调用aspectJ编译器/编译时编织。请使用预编译版本 - 它们在maven central上可用 - 或确保您调用编译时编织。

Sonatype OSS staging repositories中提供了比Maven Central更新的版本。在存储库选项卡的标题中,请选择“Nexus Managed Repositories”(而不是User Managed Repositories)并搜索mp4parser。

如果您不使用maven或gradle等依赖关系管理工具,请确保包含AspectJ runtime jar(目前版本1.8.0)。

Grüße, 塞巴斯蒂安