1 Summary
MPEG-4 Part 14 or MP4 file format, formally ISO/IEC 14496-14:2003, is a multimedia container format standard specified as a part of MPEG-4. It is most commonly used to store digital video and digital audio streams, especially those defined by MPEG, but can also be used to store other data such as subtitles and still images. Like most modern container formats, MPEG-4 Part 14 allows streaming over the Internet. A separate hint track is used to include streaming information in the file. The official filename extension for MPEG-4 Part 14 files is .mp4, thus the container format is often referred to simply as MP4.
Note:MPEG-4 Part 14 -- MP4 file format(formally ISO/IEC 14496-14:2003) is a container format;MPEG-4 Part 2 -- MPEG-4 Visual (formally ISO/IEC 14496-2) is a video compression technology developed by MPEG.
1.1 Relative file extension
The common but non-standard use of the extensions .m4a and .m4v is due to the popularity of Apple’s iPod, iPhone, and iTunes Store.
1.2 Common-used data stream
Almost any kind of data can be embedded in MPEG-4 Part 14 files through private streams. The registered codecs for MPEG-4 Part 12-based files are published on the website of MP4 Registration authority (mp4ra.org),[20] but most of them are not widely supported by MP4 players. The widely-supported codecs and additional data streams are:[citation needed]
2 MPEG4文件结构
MP4文件中包含与媒体数据时间序列相关的时间、结构、媒体信息。MP4文件主要包括三个部分:场景描述符流(BIFS)(Binary Format for Scenes)、对象描述符OD(Object Descriptor)、流和流映射表(基本流ID或URL与物理位置间的映射)。
MP4文件游atom组合和嵌套而成,比如movie atom 包含track atom,track atom包含media atom。The lowest level is leaf atom,which contains non-atom data.The atom layout is(An MPEG-4 file is made of a number of discrete units called atoms (well, they were called atoms in the first version of the specification, now they are prosaically called 'boxes').):
Atom size:A 32-bits interger that indicates the size of atom,including both the autom header and the contents,including any contained atoms.Normally,the size field contains the actual size in bytes;However, the size field can contain special values to indicates an alterlate method of determining the atom size.If the size field is set to 0,which allowed only for a top level atom,this is the last atom of the file and it extends to the last of the file.If it is set to 1,then the actual size is given in the extended size field ,an 64-bits field that follow the type field.
Type:A 32-bits interger that contains the type of the atom.This can often be usefully treated as a four-character field with a mnemonic value,such as ‘moov’(0x6D6F6F76)for a movie atom,or ‘track’(0x74726168)for a track atom.Knowing an atoms’s type allows you to interpret it’s data.An atom’s data can be arranged as any arbitrary collection of fields,tables,or other atom.If your application encounters a atom of an unknown type,it should not attempt to inerpret the atom’s data.Use the atom’s size to skip it.
2.1 Common used atom(box)
所有atom的大体布局如下:
2.1.1 Movie atom(box)
Movie atom 通常包含一个Movie Header atom(mvhd),定义整个movie的time scale和duration;包含至少一个track atom;另外还存在一些可选的atom,如下图所示:
2.1.2 Movie header atom
定义整个movie的time scale和duration.
Layout如下所示:
2.1.3 Track Atom
Atom define a single track of movie.A movie consist of on or more tracks.At least one media track.
2.1.4 Track header atom
2.1.5 Media atom
Media atom describe and define a track’s media type and sample data.The media atom contains information that specify the media type,such as audio or video;the time scale,the track duration,and so on.
2.1.6 Media header atom
2.1.7 Media information atom
Including Video information atom and sound information atom.
2.2 An example
下面这个工具的下载地址:http://blog.chinaunix.net/u2/61880/showart_1101088.html
References:
http://en.wikipedia.org/wiki/MPEG-4_Part_2
http://en.wikipedia.org/wiki/MPEG-4_Part_14
http://www.digitalpreservation.gov/formats/fdd/fdd000155.shtml
ISO_IEC_14496-14-2003.pdf
qtff-2001.pdf(most important)
流媒体MP4文件的核心技术综述.pdf