Getting started with the MP4 file format


Free Download Mp4Gain
picture

Getting started with the MP4 file format

Mp4 Normalizer

The main content of this article includes what is MP4, the basic structure of MP4 files, the basic structure of Box, the introduction of common and important boxes, the difference between ordinary MP4 and fMP4, and how to parse MP4 files through code.

MP4 Normalizer

Writing Background: Recently, I often answer questions on live streams and short videos from teammates, such as “flv.js implementation principle”, “Why the mp4 file provided by the design partner cannot be played in the browser, but can be played normally locally”, “MP4 compatibility is very good, can be used for live streaming”, etc.

In the response process, it is found that the introduction of the MP4 protocol is often involved. I briefly understood and took notes on this article before. I’ll tidy it up a bit here, and by the way, it will be used as a reference document for the team. If there are any errors or omissions, please point them out.

What is MP4?
First, the package format is presented. Multimedia encapsulation format (also called container format) refers to placing video data, audio data, etc. in a file according to certain rules. Common MKV, AVI and MP4 presented in this article are all package formats.

MP4 is one of the most common package formats and is widely used due to its cross-platform nature. The suffix for MP4 files is .mp4 and basically all major players and browsers support the MP4 format.

MP4 file format is mainly defined by MPEG-4 Part 12 and MPEG-4 Part 14. Among them, MPEG-4 Part 12 defines the ISO basic media file format for storing time-based media content. MPEG-4 Part 14 actually defines the MP4 file format and expands on the basis of MPEG-4 Part 12.

For students involved in work related to live broadcasts, audio and video, an understanding of the MP4 format is necessary. Below is a brief introduction.

MP4 File Format Overview
MP4 files are made up of multiple frames, each frame stores different information, and there is a tree structure between the frames, as shown in the figure below.

There are many types of boxes, the following are 3 most important top level boxes:

ftyp: file type box, which describes the MP4 specification and the version with which the file complies;
moov: Movie Box, the media metadata information, there is only one.
mdat: Media data box, which stores the actual media data, usually there are several;

Although there are many types of boxes, the basic structure is the same. The next section will first introduce the box structure and then explain common boxes in more detail.


Free Download Mp4Gain
picture


Mp4Gain Main Window
picture


Mp4Gain Features
picture


Free Download Mp4Gain
picture

Author: R. Arias

R. Arias is the author of this article and has extensive experience for more than 30 years as a recording engineer and audio specialist, as well as more than 20 years of experience creating algorithms related to audio and video. Linkedin