Reputation: 440
I have a requirement to cut a MP4 container H264 video encoded file into header part and content part.
Instead of dwelling into details of the header, I want to split the file with a max MP4 video header limit.
Is there any such limit exist? Does splitting initial 2/4 MB from the file will hold the header completely?
The requirement is, if the content part of the file is accessible, the video should not be recreated. Is splitting the file into header and content will help?
Upvotes: 1
Views: 5632
Reputation: 32084
According to MP4 File Format Specification, there is virtually no Header Size limit.
Some movie atoms are in variable size, so you can't set a limit.
"User Data Atoms" for example can extend the header size.
The user data atom has an atom type of 'udta'. Inside the user data atom is a list of atoms describing each piece of user data. User data provides a simple way to extend the information stored in a QuickTime movie. For example, user data atoms can store a movie’s window position, playback characteristics, or creation information.
The structure of atom within atom within atom... also implies there is virtually no limit.
I thought the limit might be 4GB, but... According to the following quote, Atom size can be even larger than 2^32 bytes:
Atom size A 32-bit integer that indicates the size of the atom, including both the atom header and the atom’s contents, including any contained atoms. Normally, the size field contains the actual size of the atom, in bytes, expressed as a 32-bit unsigned integer. However, the size field can contain special values that indicate an alternate method of determining the atom size. (These special values are normally used only for media data ('mdat') atoms.) Two special values are valid for the size field: 0, which is allowed only for a top-level atom, designates the last atom in the file and indicates that the atom extends to the end of the file. 1, which means that the actual size is given in the extended size field, an optional 64-bit field that follows the type field. This accommodates media data atoms that contain more than 2^32 bytes.
I think you better extract the elementary stream from MP4 container:
Extracting MPEG-4 Elementary Stream from MP4 Container (I am not sure linked example acctualy works).
Upvotes: 2