Rebuilding MP4 file from fragmented MP4 "mdat" atom?

6.8k Views Asked by At

I'm trying to rebuild a video file from a Smooth Streaming server. Smooth Streaming serves fMP4 files which are regular MP4 files without neither their FTYP nor their MOOV atoms.

All the informations stored in those atom are placed into a Manifest XML file, which I have.

Is there a way to programmatically rebuild the original MP4 file, either by:

  • rebuilding a new file straight from H264/AAC content located in MDAT (and picture format infos); or
  • rebuilding FTYP and MOOV atoms

Or else, is there a tool which can merge fMP4?

2

There are 2 best solutions below

1
On

It is simple to rebuild a mp4 file, if there are ism and ismc file which are related to fragmented mp4 files.

It is requested that you should know media type, codec type, codec specific data and time scale of each trak to rebuild a moov and ftyp atom.

these information can be retrieved from ism and ismc file.

you can retrieve a media type of each track from the ism file. you can retrieve codec type, codec specific data and time scale of each track from the ismc file.

simply speaking, ism/ismc files are meta data for server and client so that you can rebuild meta data(ftyp, moov atom) for a mp4 file.

0
On

Yes. It is completely possible.

You can do this with FFmpeg. Study the mov.c [MP4 demuxer] from libavformat.

You will need to complete the MP4 in memory with all data that is "missing" in the fMP4. In other words, when you need an atom that doesn't exist in fMP4 [almost all], you will have to input all information hard-coded (such information, most of them come from the manifest).

It's not easy... but for sure it's possible. I've done by myself. Unfortunately the code is not my property.

Good luck! ;-)

UPDATE: the PIFF format specification will be very useful (http://go.microsoft.com/?linkid=9682897) so one can understand what is already in the fMP4 and what is not!