H264-mp4 format and Extract H264 SPS, pps and bitstream in the MP4 file

Source: Internet
Author: User
Tags format definition
h264-mp4 format and extract H264 SPS, pps and bitstream in the MP4 file


Skyseraph APR 1st 2012



Email:skyseraph00@163.com First, MP4 format basic concept



MP4 format corresponds to Standard MPEG-4 standard (iso/iec14496)



Second, MP4 packaging format core concept



1 MP4 package format corresponds to ISO/IEC 14496-12 (Information technology Audio-visual object code part 12th: ISO Basic Media file format/information technology Coding of audio-visual objects Par T 12:iso base media file format)



Attached--Standard free download: freely Available standards http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html






2 MP4 package format is based on the QuickTime container format definition, media description and media data separate, is now widely used in packaging H. Video and ACC Audio, is the representative of high-definition video/HDV.






All data in the 3 MP4 file is encapsulated in box (corresponding to the atom in QuickTime), that is, the MP4 file is made up of several boxes, each box has a length and type, and each box can also contain a separate sub box (called Container box).



A MP4 file will first have a "Ftyp" type of box, as a MP4 format flag and contains some information about the file, then there will be a "moov" type of box (Movie box), it is a container box, The sub Box contains the media's metadata information, and the MP4 file's media data is contained in the "Mdat" type of box (Midia Data box), and the box is container box, which can have multiple You can also not (when the media data all refer to other files), the structure of the media data is described by metadata.






4 MP4 box is stored in big-endian mode. In general, the standard box starts with a four-byte box size.




5 several nouns


Track

Represents a collection of sample, track represents a video or audio sequence for media data.

Hint Track

Special track, which does not contain media data, contains instructions for packaging other data in the track into streaming media.

Sample

For non-hint track, video sample is a single frame, or a set of consecutive video frames, and audio sample is a continuous compressed audio, collectively referred to as Sample.

For hint Track,sample, define the format of one or more streaming media packages.

Sample Table

A table that indicates the timing and physical layout of the Sampe.

Chunk

A track of a number of sample units composed of.


three, MP4 package format structure diagram 1 Example Sample



From Android Mediarecoder video recording, the platform for  T8300 and TCL968, with Mp4info view as follows:



use Eseye to view the following: The analysis by Winhex is as follows:






2 box structure diagram






Next, some of the useful h264 codes are described, others are no longer described. 3 Ftyp (File type box)



As shown in the following figure, the beginning of the four bytes of the box with a size of 24 bytes (with a header), and then the Ftyp is the box TYPE, the other is some format compatibility and other related information.



4 Mdat



As shown in the figure below, BOX ype is 6D 64 61 74, followed by 00 00 09 39 Representing Sliece length



5 AvcC



Red is box TYPE, as shown in the following illustration






iv. h264 SPS, pps acquisition in MP4 file



1 "Reference basis" ISO/IEC 14496-15 (download)



2 "Review" in H264, SPS and PPS exist in the Nalu header, and in MP4 files, SPS and PPS exist in Avcdecoderconfigurationrecord, first to locate AVCC.



3 "Definition"



① parameter set: A group of data that is rarely changed to provide decoded information for a large number of VCL Nalu.



The sequence parameter set SPS acts on a series of sequential encoded images, while the image parameter set PPS acts on one or more independent images in the encoded video sequence.



If the decoder does not receive the two parameter sets correctly, then the other Nalu cannot be decoded. They are therefore typically sent before other Nalu are sent, and are transmitted using different channels or more reliable transport protocols such as TCP, or they can be transmitted over and over again.



② about the AVCDECODERCONFIGURATIONRECORD structure is defined as






4 "Example analysis" data as shown in the AVCC diagram, now detailed analysis of the data






Therefore, the extracted SPS and PPS respectively for the 1E A6 Bayi F9 and the 38 80



v. H264 Data/nalu Slice in the MP4 file



1 "Reference" H264 Official document (download) + Bizu-Next generation video compression coding standard (download)



2 "Overview"



in the MP4 format file, H264 Slice is not segmented by 00 00 00 01来, but is stored in mdat box.



H264 basic bitstream consists of nalu of some columns. The original Nalu unit consists of: [Start code] + [Nalu header] + [Nalu payload]





Start code


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.