Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rebuilding MP4 file from fragmented MP4 "mdat" atom?

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?

like image 225
Velcro Avatar asked Aug 10 '12 09:08

Velcro


People also ask

What is a fragmented MP4?

A fragmented MP4 file consists of the usual MovieBox with the TrackBoxes to signal which media streams are available. A Movie Extends Box (mvex) is used to signal that the movie is continued in the fragments. Another advantage is that fragments can be stored in different files.

What is MOOV atom in MP4?

MOOV Relocator is a well documented small library written in PHP to relocate (or move) the MOOV-Atom of MP4-Files from the end to the beginning of a file. In H. 264-based video formats (mp4, m4v) the metadata is called a "moov atom".

What is mdat atom?

The MDAT atom contains actual audio and video data. The MOOV atom contains information about how to extract data from MDAT, it gives references to chunks (samples).

What is atom MP4?

An atom is a self-contained data unit containing information about the video file. The moov atom, aka movie atom, defines the timescale, duration, and display characteristics of the movie, as well as sub-atoms containing information for each track in the movie.


1 Answers

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!

like image 113
Wagner Patriota Avatar answered Oct 14 '22 02:10

Wagner Patriota