Interleaving MP4

737 views
Skip to first unread message

Tiberiu Breană

unread,
May 9, 2013, 4:45:57 AM5/9/13
to mp4parser-...@googlegroups.com
Hello,

I'm looking for a tool to use for programmatically re-interleaving an MP4 video. Does MP4Parser provide such a tool?
I need this for an Android app I'm developing.

Thanks,
Tiberiu

Sebastian Annies

unread,
May 9, 2013, 4:59:21 AM5/9/13
to mp4parser-...@googlegroups.com

What do you mean with interleave?

Create a standard MP4 file with audio/video in chunks interleaved in a single mdat from raw AAC and raw h264? Yes you can. Check this example: https://mp4parser.googlecode.com/svn/trunk/examples/src/main/java/com/googlecode/mp4parser/muxformats/H264Example.java

--
You received this message because you are subscribed to the Google Groups "mp4parser-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tiberiu Breană

unread,
May 9, 2013, 6:01:05 AM5/9/13
to mp4parser-...@googlegroups.com
Ok, first off, I'm not very experienced in MP4 formatting.

I've got some MPEG-DASH mp4 segments that I'm trying to play on an Android phone. Initially, they aren't playable by Android's media player, but after I interleave them using the MP4Box command line tool (e.g. "MP4Box -inter 1" (1 ms)), they become playable. What's stranger is that these clips don't even have audio tracks...

I'm currently looking for a way to perform this operation programmatically, or at least call an executable binary from the Android code.


--
You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mp4parser-discussion/3gdSA89bm8U/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.

Sebastian Annies

unread,
May 9, 2013, 6:14:37 AM5/9/13
to mp4parser-...@googlegroups.com

Please send me some example files so that I can check how it might work. You can also send me the files private if copyright might be an issue.

Tiberiu Breană

unread,
May 9, 2013, 6:32:32 AM5/9/13
to mp4parser-...@googlegroups.com
Ok, I've attached clips.zip to this thread, which contains:
- redbull_500kbit_dash.mp4: contains only initialization data, no video data
- redbull_10sec2.m4s: contains only video data
- clip_non_inter.mp4: clip obtained by "cat redbull_500kbit_dash.mp4 redbull_10sec2.m4s > clip_non_inter.mp4"
- clip_inter.mp4: clip obtained by calling "MP4Box -inter 1 clip_non_inter.mp4"

As mentioned before, only clip_inter.mp4 plays on the phone.
Clips were downloaded using this DASH MPD file, from the 10sec, 500kbps representation; files located here.

Thanks for your time!

clips.zip

Tiberiu Breană

unread,
May 9, 2013, 7:04:27 AM5/9/13
to mp4parser-...@googlegroups.com
I ran MP4Box -info on both the non-interleaved and the interleaved clips and diff'd the output:


It seems that the non-interleaved clip is seen as having 00:00:00 duration, for some reason. By the way, non-interleaved clips play fine with the default Ubuntu media player.

Tiberiu Breană

unread,
May 9, 2013, 11:48:08 AM5/9/13
to mp4parser-...@googlegroups.com
The guys at MP4Box say that the clips might not be playing because Android doesn't support fragmented MP4 playback:
https://sourceforge.net/projects/gpac/forums/forum/287546/topic/8082872

Can I "un-fragment" a clip using mp4parser?

Sebastian Annies

unread,
May 11, 2013, 1:28:18 PM5/11/13
to mp4parser-...@googlegroups.com

Yes, you can.

 

Movie m = MovieCreator.build(fragmentedFile)

DefaultMp4Builder builder = new DefaultMp4Builder();

IsoFile stdMp4 = builder.build(m);

FileOutputStream fos = new FileOutputStream("out.mp4");

stdMp4.getBox(fos.getChannel());

fos.close();

 

With a bit of work it will also be possible to just use the mp4parser to stitch the files together. I was trying today for about an hour but still not finished. I’ll try on Monday as I can move some of this work in my worktime as it is a related topic.

 

 

Von: mp4parser-...@googlegroups.com [mailto:mp4parser-...@googlegroups.com] Im Auftrag von Tiberiu Breana
Gesendet: Donnerstag, 9. Mai 2013 17:48
An: mp4parser-...@googlegroups.com
Betreff: Re: Interleaving MP4

 

The guys at MP4Box say that the clips might not be playing because Android doesn't support fragmented MP4 playback:

--

Tiberiu Breană

unread,
May 13, 2013, 2:57:05 PM5/13/13
to mp4parser-...@googlegroups.com
Thanks for the code snippet. Unfortunately, I can't seem to get it to work.

I've copied the isoparser sources to my Android project (I've never used Maven, so I decided to save some time). I've ran your code on both a fragmented and a non-fragmented MP4, and they both seem to crash the app due to a NullPointerException, at the very first line  (MovieCreator.build). After a bit of debugging, I've found that getBoxes returns an empty track list, and getMovieHeaderBox() returns null.
As input I'm using File.getChannel():
FileInputStream inStream = new FileInputStream(playSegmentFile);
Movie movie = MovieCreator.build(inStream.getChannel());

Am I doing something wrong? Can you please try and run your code on the clips I've attached?

Thanks,
Tiberiu


--
You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mp4parser-discussion/3gdSA89bm8U/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.

sebastian.annies

unread,
May 13, 2013, 3:24:50 PM5/13/13
to mp4parser-...@googlegroups.com
Please try to use maven. Just unzip maven archive, type mvn install and copy the jar from the target directory.  This makes  sure that the classes are processed by the aspectJ compiler. This is exactly the issue you aee running into! 


-------- Ursprüngliche Nachricht --------
Von: Tiberiu Breană <tiberiu...@gmail.com>
Datum: 13.05.2013 20:57 (GMT+01:00)

Tiberiu Breană

unread,
May 13, 2013, 4:36:56 PM5/13/13
to mp4parser-...@googlegroups.com
Ok, I've downloaded Maven, created a dummy project based on their tutorial, then added
<dependency>
 <groupId>com.googlecode.mp4parser</groupId> 
 <artifactId>isoparser</artifactId> 
 <version>1.0-RC-15</version> 
</dependency>

to the pom.xml. From cmd I've typed mvn install. Everything seemed to work fine, but all I got is a 3KB mp4parser-1.0-SNAPSHOT.jar that only contains the dummy "App.class". What am I missing?

Tiberiu Breană

unread,
May 16, 2013, 12:52:44 PM5/16/13
to mp4parser-...@googlegroups.com
Sebastian, could you write a wiki page on how to integrate mp4parser into existing projects? It would be really useful, especialy for people with little or no experience in Maven, such as myself.

Tiberiu

Sebastian Annies

unread,
Jun 7, 2013, 4:42:41 AM6/7/13
to mp4parser-...@googlegroups.com
I put something on the frontpage. Will help people to find release and the aspectj-rt dependency. Thank you, that will reduce those support request!


2013/5/16 Tiberiu Breană <tiberiu...@gmail.com>

Tiberiu Breană

unread,
Jun 7, 2013, 5:35:29 AM6/7/13
to mp4parser-...@googlegroups.com
Great!
In the meantime, I've managed to integrate mp4parser in my Android MPEG-DASH player app by using a (modified) Maven pom.xml from a project found on GitHub that was also using the library. Now I'm building my .apk with Maven, and the mp4parser code does a great job in processing the fragmented video clips.
Thanks for your support!

Tiberiu

Sebastian Annies

unread,
Jun 7, 2013, 5:39:21 AM6/7/13
to mp4parser-...@googlegroups.com
When you publish the app please drop me a mail, I'm really interested in DASH (in case it's note private app).


2013/6/7 Tiberiu Breană <tiberiu...@gmail.com>

Sebastian Annies

unread,
Jun 7, 2013, 5:39:44 AM6/7/13
to mp4parser-...@googlegroups.com
(in case it's not a private app)


2013/6/7 Sebastian Annies <sebastia...@gmail.com>

Tiberiu Breană

unread,
Jun 7, 2013, 5:49:35 AM6/7/13
to mp4parser-...@googlegroups.com
Well, I'm not developing it as a commercial app, but for a university project. I'll notify you once it's done, if you want to check out the code.
Reply all
Reply to author
Forward
0 new messages