any tool to fix box length value for an mp4 file ?

85 views
Skip to first unread message

Roger P.

unread,
Jan 21, 2015, 7:40:42 AM1/21/15
to mp4parser-...@googlegroups.com
Hi, All:

I managed to pipe an Android recording to a target dir, where it's saved as an mp4 file successfully.  Of course, it won't play due to missing all of the box value - they're all 00 00 00 00 - since the pipe is not seek-able.  In order to make the generated mp4 file playable, I need to somehow fill in all the box length value.

I've used the isoviewer in the mp4parser to check, and use Hex Editor to fill in the ftyp, mdat, moov, mvhd, udta, trak, when comparing it with a playable similar video.  Then I realized there're more box type to parse - SDLN, smrd, smta, tkhd, mdia, ...... and if I keep on going, I might finish with a mp4 parser myself ...  All I did was to search for above 4 letters strings, get the file offset and do a calculation of how big the box is, then fill in the 4 bytes in front of the box type.  I'll assume there should be some tool that can do it, and can catch all necessary box type better than I do.  Any hint from any one ? ... Many thanks in advance !

Roger
Message has been deleted
Message has been deleted

Roger P.

unread,
Jan 22, 2015, 5:39:13 AM1/22/15
to mp4parser-...@googlegroups.com
This is essentially to fix a broken linked-list ... where the original mp4 file has all the boxes with leading 4 bytes 00 00 00 00.  One pointer P1 stick to the first FourCC code appearance, 2nd pointer P2 continue to parse until next FourCC code, then get the address-diff (P2-P1), fill in the value into [P1-4] ... 

Only if I know how to parse all FourCC code, and have to distinguish if they are a container or not ....

Tried to use the class Movie target = MovieCreater.build(orig_mp4_file), and got nullPointerException:

Exception in thread "main" java.lang.NullPointerException
at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.<init>(DefaultMp4SampleList.java:44)
at com.coremedia.iso.boxes.mdat.SampleList.<init>(SampleList.java:33)
at com.googlecode.mp4parser.authoring.Mp4TrackImpl.<init>(Mp4TrackImpl.java:60)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:57)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:38)
at com.test.mp4.MuxMp4SourcesExample.main(MuxMp4SourcesExample.java:29)

Roger
Reply all
Reply to author
Forward
0 new messages