PMP Format Details _ Application Skills

Source: Internet
Author: User
Tags mixed
PMP format: The famous Jonny Design PMP format, so that you can use small p to enjoy high-quality audio and video;
But as the version of the advance, there are PMP1.0, PMP2.0, PMP-AVC, these nouns and concepts may be confusing to everyone, now, I based on my research and understanding to explain the meaning of these nouns.

"PMP Format"
PMP is the Jonny design of the video audio package format, like AVI, just a packaged container format
PMP format now has only two versions, one is 1.0, one is 2.0

PMP1.0 is a relatively rudimentary version that only supports encapsulating mp4v streams (XviD, DivX) and MP3 streams (and requires CBR with a sampling rate of 44100),
Starting from the file header, the order structure is as follows:

4 bytes: Must be "PMPM", PMP logo;
4 bytes: Version number, 0, indicating version is 1.0
4 bytes: Total video Frames
4 bytes: Video width
4 bytes: Video height
4 bytes: Video scale
4 bytes: Video rate, note: Video frame rate fps = Rate/scale
4 bytes: size of maximum video frame
Total video frames x4: Index per frame, 4 bytes per index, lowest bit bit to indicate whether KeyFrames, and the remaining 31 bit to indicate frame size
Video data: Byte number, from the above index calculation can be drawn;
4 bytes: The data size of the audio frame (because of the CBR mode, all the audio frame data are the same size, but the key frame size is more than the normal frame size of one byte)
4 bytes: Total number of audio frames
Total Audio Frames X1: Index of audio per frame, 1 bytes per index, key frame 1, normal frame 0, note: The actual size of each frame = audio frame data size + index value;
Audio data: Byte number, calculated from the above index;

From the above analysis, PMP1.0 format has a lot of deficiencies, no video and audio logo bit, that is, fixed dead video and audio encoding format, can not encapsulate all kinds of flow,
At the same time, because the video and audio data are not interleaved storage, the playback program in the playback, the file pointer moving back and forth, reading the video frame moved to the front, read the audio frame and moved to the back;

PMP2.0 began, Jonny estimated that 1.0 of the deficiencies, redesigned the format of the file structure, I personally think this change is very good:
Starting from the file header, the order structure is as follows:

4 bytes: Must be "PMPM", PMP logo;
4 bytes: Version number, 1, indicating version is 2.0
4 bytes: Video format flag, this is an improvement, to support the encapsulation of a variety of video streams to provide assurance, 0 for mp4v stream (XviD, DivX), 1 for the AVC flow (PMP-AVC is actually PMP2.0 format, but only encapsulates the AVC flow)
4 bytes: Total video Frames
4 bytes: Video width
4 bytes: Video height
4 bytes: Video scale
4 bytes: Video rate, note: Video frame rate fps = Rate/scale
4 bytes: Audio format flag, also in order to support the encapsulation of a variety of audio to provide assurance, now only support MP3 flow, the value of 0;
4 bytes: Contains the number of audio streams, to support multiple track packaging provides a guarantee, if a PMP encapsulated two tracks, the value is 2
4 bytes: The maximum number of audio frames that come with each frame of video, as PMP2.0 uses a video-Audio interleaved method, a frame of video and corresponding several frames of audio together, which is a maximum value;
4 bytes: Audio scale, default is 1152
4 bytes: Audio rate, default is 44100
4 bytes: Audio whether stereo, 0 for single sound, 1 for stereo;
Total video frames x4: Index per frame, 4 bytes per index, lowest bit bit for keyframe, and 31 bit for frame size (note that the frame size and the frame size of the 1.0 format are different, see below for the explanation)
Video Audio Mix data: Here, Jonny made a more interesting design, the 1 video frame and its corresponding audio frame mixed up as a data frame; then how exactly is the mixing method, we analyze:
First calculate the timestamp of each video frame and the timestamp of each audio frame, videotime = videonum/videofps, Audiotime = Audionum/audiofps (Videonum and audionum all starting from 0)
Then the first video frame timestamp is 0/videofps = 0, while the second video frame timestamp is 1/videofps, then the first video frame and all the time stamp is less than 1/videofps of the audio frame together, into a data frame, so the analogy goes;
Then add n bytes to the front of each data frame, n=1+4+4+4+4x the number of frames per track to be mixed with x tracks,
The meaning of these n bytes is as follows:
1 bytes: The number of frames per track to be mixed in this data frame;
4 bytes: The time difference between the first audio frame and the video frame being mixed;
4 bytes: The time lag between the last audio frame and the video frame being mixed;
4 bytes: The size of the video frame;
4x per track mixed frame number x track number: size of each mix of audio frames

"PMP Play"
From the above analysis, we know that PMP has two formats (1.0,2.0), and because of the 2.0 format of the package of different flows, there are so-called pmp2.0 and PMP-AVC differences;
All, we need different players (PMP-MOD1, PMP-MOD2, PMP-AVC) to play these files;

Because the differences between pmp1.0 and pmp2.0 format files are too great, if you want to implement both of these in small p, code writing can be more complex and the efficiency may be reduced
At the same time due to the lack of pmp1.0 format, I recommend that you give up the pmp1.0 format, the original pmp1.0 format of the film can be converted into 2.0 through the REMUX format;
As for pmp-mp4v and PMP-AVC files, I personally think that they can be put in a program to support, because their package is the same, but the flow is not the same inside;
Only need to decode the different decoder.

Something
The purpose of this article is to let you know the difference between the various formats of PMP.
I wish I had the time and the ability to do a pmp-mod for everyone, support pmp2.0 (including PMP-MP4V,PMP-AVC), but in fact, I am busy with my work and I don't have much energy to write this.
So, the other purpose of writing this is to share my research, hoping that there will be a technology master who can write a new pmp-mod that supports pmp2.0 format (including pmp-mp4v and PMP-AVC).

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.