1

[I have found below link upon stackoverflow but it does not match my requirements. I am trying to append videos by presenting a custom gallery to user in which all the videos stored in sdcard is displayed and the user has to select any number of them and finally after pressing append button videos get merged/appended, it works fine in many cases but it fails in some cases don't understand this error and how to solve it. And the link above is used to setVideoCodec for videos which are recorded from application itself which I am not doing. How to change videocodec of already available mp4 video?

This is the Log error that I get while appending.I have also printed sample box description entries to get help out of it but to no avail and I can see the sample box description entries are same and there is no documentation of Isoparser Library which can help me out. I am using isoparser-1.0-RC-2.jar and aspectjrt-1.8.0.jar as the latest isoparser library didn't work for me :-(

java-io-ioexception-cannot-append-mp4trackimplhandler-vide-to-mp4trackimpl

09-03 11:53:43.390: I/MERGE_VIDEO_ACTIVITY(28345): SampleDescriptionBox[AudioSampleEntry]
09-03 11:53:43.390: I/MERGE_VIDEO_ACTIVITY(28345): SampleDescriptionBox[com.coremedia.iso.boxes.sampleentry.VisualSampleEntry@42118240]
09-03 11:53:43.390: I/MERGE_VIDEO_ACTIVITY(28345): SampleDescriptionBox[AudioSampleEntry]
09-03 11:53:43.390: I/MERGE_VIDEO_ACTIVITY(28345): SampleDescriptionBox[com.coremedia.iso.boxes.sampleentry.VisualSampleEntry@41f08c60]
09-03 11:53:43.400: W/System.err(28345): java.io.IOException: Cannot append com.googlecode.mp4parser.authoring.Mp4TrackImpl@42008d78 to com.googlecode.mp4parser.authoring.Mp4TrackImpl@41ef5d90 since their Sample Description Boxes differ
09-03 11:53:43.400: W/System.err(28345):    at com.googlecode.mp4parser.authoring.tracks.AppendTrack.<init>(AppendTrack.java:48)
09-03 11:53:43.400: W/System.err(28345):    at com.spec.videoeditingdemo.service.asynctasks.MergeVideos.doInBackground(MergeVideos.java:113)
09-03 11:53:43.400: W/System.err(28345):    at com.spec.videoeditingdemo.service.asynctasks.MergeVideos.doInBackground(MergeVideos.java:1)
09-03 11:53:43.400: W/System.err(28345):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
09-03 11:53:43.400: W/System.err(28345):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-03 11:53:43.400: W/System.err(28345):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
09-03 11:53:43.400: W/System.err(28345):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-03 11:53:43.400: W/System.err(28345):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-03 11:53:43.400: W/System.err(28345):    at java.lang.Thread.run(Thread.java:841)

-Thanks in advance. I would be very happy if somebody could help me out with the issue.

Bob Vale
  • 18,094
  • 1
  • 42
  • 49
Namrata Bagerwal
  • 1,202
  • 13
  • 27

1 Answers1

0

the error message is quite precise. The sample description boxes (== codec initialization) is different. Therefore you cannot append these track - remember: the mp4parser cannot re-encode the file - it just appends what's already there. Sometimes the differences can be ignored but in most cases you cannot ignore it. For example you will not be able to append two videos with different resolution or framerate without reencoding them.

So: How is it in your case? Have the two source videos been encoded with the same encoder settings?

Sebastian Annies
  • 2,438
  • 1
  • 20
  • 38
  • That's what I am asking is there any way to find out videocodec of already available video in sdcard. And hence any way to re-encode them in the same format before passing them for merging so such issues don't persist further. Please note:All these videos are not the ones recorded from cel-phone's camera, these are some different mp4 files like a song/cartoon mp4 video. – Namrata Bagerwal Sep 03 '14 at 09:15
  • If you need to reencode I'd say you are better off with something like ffmpeg or using MediaCodec API (Android 4.x) together with mp4parser. – Sebastian Annies Sep 03 '14 at 10:01
  • Hey Sebastian Can you please let me know what all properties I need to check compulsorily to see whether two videos can be appended? So that I can pre-inform user that the currently selected video can't be appended to previously selected videos. – Namrata Bagerwal Sep 11 '14 at 04:56