NOTE: The latest documentation describing MP4Box Support for DASH is given here.
With our work on Dynamic Adaptive Streaming over HTTP (DASH), in the current version of GPAC (revision 2642 on SVN), we now have many options for interleaving, fragmenting and segmenting … which may be confusing. It is time to clarify their usage in MP4Box. Some related aspects using MPEG-2 TS instead of MP4 can be seen in this previous post.
The options are:
-inter time_in_ms (with possibly -tight) or -flat (no interleaving)
-frag time_in_ms
-dash dur_in_ms
-split time_sec (or -split-size)
Interleaving (-inter) is when (groups of ) samples of different tracks are stored alternatively in the file: e.g. N milliseconds of video samples, followed by N milliseconds of audio samples, followed by N milliseconds of video samples … Typically, interleaved samples are grouped within an interleaving window. Interleaving reduces disk accesses, playback buffer requirements and enables progressive download and playback.
Fragmentation (-frag) is an optional process applicable to the MP4 file format. By default, MP4 files generated with MP4Box are not fragmented. This process consists in using Movie Fragments (moof). Movie Fragments is a tool introduced in the ISO spec to improve recording of long-running sequences and that is now used for HTTP streaming. Even if it is possible, according to the ISO spec, to do interleaving on fragments, MP4Box currently does not support it, because we don’t see important use cases for it. For instance, all audio samples within a fragment are contiguously stored and similarly for the video samples. The only way to ‘interleave’ tracks is to have small fragments. There may be some overhead for big files, we welcome comments on this.
Segmentation (-dash) is the process of creating segments, parts of an original file meant for individual/separate HTTP download (not necessarily for individual playback). A segment can be a part of a big file or a separate file. It is not specific to the MP4 file format (in particular it may apply to MPEG-2 TS) but a segment may imply specific ISO signaling (styp and sidx boxes, for instance). A segment is what is refered to by the XML file used to drive the HTTP Streaming and segment boundaries can be convenient places for bitstream switching. Segmentation often implies fragmentation but not necessarily.
Last, MP4Box can split (-split) a file and create individual playable files from an original one. It does not use segmentation in the above sense, it removes fragmentation and can use interleaving.
Some examples of MP4Box usages:
- Rewrites a file with an interleaving window of 1 sec.
MP4Box -inter 1000 file.mp4
- Rewrites a file with 10 sec. fragments
MP4Box -frag 10000 file.mp4
- Rewrites a file (and creates the associated XML) with 10 sec. fragments and 30 sec. segments
MP4Box -frag 10000 -dash 30000 file.mp4
- Segmentation of a file into 30 sec. segment files with 10 sec. fragments (and creation of the associated XML file.mpd)
MP4Box -frag 10000 -dash 30000 -segment-name segment_file file.mp4
Interested readers can find more details about the ISO Base Media File Format specification, here.

Pingback: DASH Support | GPAC
Pingback: MPEG-DASH support in Google Chrome | GPAC
Hello. I recently installed MP4Box, and I’ve tried a few commands, but whenever I do, I always get a symbol lookup error. For example, I tried the command:
$ ~/myvns/gpac/bin/gcc/MP4Box -frag 10000 -dash 30000 -segment-name test test.mp4
and I received the output:
DASH-ing file: 30.00s segments 10.00s fragments single sidx per segment
mysvns/gpac/bin/gcc/MP4Box: symbol lookup error: mysvns/gpac/bin/gcc/MP4Box: undefined symbol: gf_url_get_resource_name
I’m not totally sure what the issue is, or if this is normal or not. I’ve tried a few other commands as well, and I get the same error.
Looks like you have a mismatch between your libgpac and your MP4Box on your system – could you try a complete cleanup:
make uninstall
make clean
make
make install
and let us know ?
Well, I suppose that would make sense, since I was never actually able to get gpac to compile correctly. When I try to install gpac this is what happens:
In the gpac directory, I typed:
sudo make uninstall
make clean
make
make install
and I get the following error message:
/usr/bin/ld: /usr/local/lib/libavformat.a(allformats.o): relocation R_X86_64_32 against `ff_a64_muxer’ can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavformat.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [gm_ffmpeg_in.so] Error 1
make[2]: Leaving directory `/home/jeremy/mysvns/gpac/modules/ffmpeg_in’
make[1]: *** [plugs] Error 2
make[1]: Leaving directory `/home/jeremy/mysvns/gpac/modules’
make: *** [all] Error 2
I really only need gpac to use the MP4Box application, though, so as a work-around someone told me to use this:
./configure –use-js=no
make -C src
make -C applications/mp4box
and then this if MP4Box can’t find libgpac.so :
sudo install -m644 bin/gcc/libgpac.so /usr/local/lib/libgpac.so
sudo chmod +x /usr/local/lib/libgpac.so
sudo ldconfig
MP4Box seems to work now, but I’ll post again if I run into more issues.
Compiling FFmpeg with –enable-pic will solve the first issue. I am guessing that installing FFmpeg binaries from your distro will solve the problem too.
As for MP4Box not finding libgpac, all you need to do is to append the path of your libgpac ($HOME/gpac/bin/gcc in my case) in /etc/ld.so.conf and then do a “sudo ldconfig”. Then you can use MP4Box without installing it.
Hi, I have an issue using the latest mp4box build (and also with older one). I just try to fragment a mp4 file : c:\GPAC>mp4box -frag 10000 test.mp4 –>
Fragmenting file (10.000 seconds fragments) and get a crash. Independet from the mp4file I use. I tried several ones. According to the statement above, the command line is correct. Can you help ? Btw. I tried to fragment the iso file to support smooth streaming as a next step. And, thanks for all the GPAC stuff. Best, Sven
This should now be fixed on SVN
Hi Jean,
Yes, works indeed. Many thanks. I can imagine that you don´t like to do support for Smooth Streaming. I am just stucked and maybe you have a hint. Is it possible to create a fMP4 file that works for Smooth Streaming ? I guess I tried all possible settings without success. Don´t get me wrong, it´s not about the manifest, the fragmented stream doesn´t play at all. Thanks,
Sven
additional note :
C:\GPAC>mp4box -info sven3.mp4
* Movie Info *
Timescale 600 – Duration 00:01:46.738
1 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom – version 1
Created: GMT Fri Mar 08 12:21:35 2013
File has root IOD (9 bytes)
Scene PL 0xff – Graphics PL 0xff – OD PL 0xff
Visual PL: AVC/H264 Profile (0×15)
Audio PL: No audio capability required (0xff)
No streams included in root OD
Track # 1 Info – TrackID 1 – TimeScale 108000000 – Media Duration 00:01:46.739
Media Info: Language “Undetermined” – Type “vide:avc1″ – 3199 samples
Visual Track layout: x=0 y=0 width=220 height=124
MPEG-4 Config: Visual Stream – ObjectTypeIndication 0×21
AVC/H264 Video – Visual Size 224 x 124
AVC Info: 1 SPS – 1 PPS – Profile Main @ Level 1.3
NAL Unit length bits: 32
Pixel Aspect Ratio 1008:1024 – Indicated track size 220 x 124
Self-synchronized
is one of the stream I use.
After
C:\GPAC>mp4box -frag 2000 sven3.mp4
Fragmenting file (2.000 seconds fragments)
I get a file with a lot of small mdat atoms, for instance the first one is just 184 bytes, 235 second etc.. But the 2 sec GOP of the elementary stream is around 26000 Bytes. Can you help ?
Thanks,
Sven
I tried to use MP4Box to generate an mpd file with 1 second segements using:
MP4Box -dash 1000 -rap putlocker.mp4
But I get only one segment in the file. The video is 30 min long.
By default all segments will be generated in a single file, use -segment-name NAME (or specify -profile live) to create one file file per segment