PMP format details

Source: Internet
Author: User

PMP format details: the famous jonny has designed PMP format so that you can use small P to enjoy high-quality audio and video;
But with the version advances, the appearance of PMP1.0, PMP2.0, PMP-AVC, these terms and concepts may make everyone very confused, now, I will explain the meaning of these terms based on my research and understanding.

PMP format]
PMP is a video and audio Encapsulation Format designed by jonny. Like AVI, PMP is only an encapsulated container format.
PMP format only has two versions, one is 1.0 and the other is 2.0.

PMP1.0 is a simple version. It only supports encapsulation of MP4V streams (xvid, divx) and MP3 streams (CBR is required and the sampling rate is 44100 ),
Starting from the file header, the sequence structure is as follows:

4 Bytes: it must be a "pmpm", pmp sign;
4-byte: version number, 0, indicating Version 1.0
4 Bytes: Total number of 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: Maximum video frame size
Total number of video frames x 4 Bytes: The index of each video frame. Each index has 4 bytes. The lowest bit indicates whether the key frame is used. The remaining 31 bit indicates the frame size.
Video data: the number of bytes, which can be calculated by the above index;
Four bytes: The data size of the audio frame (because the cbr mode is used, the data size of all audio frames is the same, but the size of the key frame is one byte larger than that of the normal frame)
4 Bytes: Total number of audio Frames
Total number of audio frames x 1 byte: The index of each audio frame. Each index has 1 byte, the key frame is 1, and the normal frame is 0. Note: actual size of each frame = data size of the audio frame + index value;
Audio Data: The number of bytes, calculated from the index above;

From the above analysis, the PMP1.0 format has many shortcomings, and there is no logo space for videos and audios. That is to say, the encoding formats of videos and audios are fixed and various streams cannot be encapsulated,
At the same time, because the video and audio data are not staggered, the file pointer is moved back and forth during playback, the video frame is moved to the front, and the read audio frame is moved to the back;

At the beginning of PMP2.0, jonny realized the shortcomings of 1.0 and redesigned the file format structure. I personally think this change is quite good:
Starting from the file header, the sequence structure is as follows:

4 Bytes: it must be a "pmpm", pmp sign;
4-byte: version number, 1, indicating version 2.0
4 Bytes: Video Format Mark, this is an improvement, to support encapsulation of a variety of video streams to provide assurance, 0 represents MP4V stream (xvid, divx), 1 represents AVC stream (PMP-AVC is actually PMP2.0 format, only the AVC stream is encapsulated)
4 Bytes: Total number of 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-byte: audio format flag. To enable encapsulation of various audios in the future, only mp3 streams are supported. The value is 0;
4 Bytes: the number of audio streams included. This guarantees the encapsulation of multiple audio tracks. If two audio tracks are encapsulated in a pmp file, this value is 2.
4 Bytes: the maximum number of audio frames attached to each frame of the video. Because PMP2.0 uses the video/audio staggered storage mode, a frame of video is put together with the corresponding several frames of audio, this is a maximum value;
4 Bytes: audio scale, 1152 by default
4 Bytes: audio rate, 44100 by default
4 Bytes: whether the audio is stereo. 0 indicates single sound, and 1 indicates stereo sound;
Total number of video frames × 4 Bytes: The index of each video frame. Each index has 4 bytes. The lowest bit indicates whether the key frame is used, the remaining 31 bits indicate the frame size (note that the frame size here is different from the frame size in the 1.0 format. refer to the following description)
Video/audio mixing data: jonny has made an interesting design, mixing a video frame with its corresponding audio frame as a data frame; so how can this problem be mixed? Let's analyze it:
Calculate the time stamp of each video frame and the time stamp of each audio frame. videotime = videonum/videofps, audiotime = audionum/audiofps (both videonum and audionum start from 0)
The time stamp of the first video frame is 0/videofps = 0, and the time stamp of the second video frame is 1/videofps. Then, connect the first video frame with all audio frames with a timestamp less than 1/videofps to form a data frame, and so on;
Then add n Bytes to the front of each data frame, n = 1 + 4 + 4 + 4 + 4 × Number of frames mixed by each audio track × number of audio tracks,
The meaning of the n Bytes is as follows:
1 byte: Number of frames in the current data frame that are mixed by each audio track;
4 Bytes: time difference between the first audio frame and the video frame to be mixed;
4 Bytes: the time difference between the last audio frame and the video frame;
4 Bytes: the video frame size;
4× Number of frames mixed for each audio track × number of audio tracks: size of each audio frame mixed

PMP playback]
From the above analysis, we know that PMP has two formats (1.0, 2.0), and because the stream encapsulated in the 2.0 format is different, the so-called pmp2.0 and pmp-avc are different;
All, we need a different player (pmp-mod1, pmp-mod2, pmp-avc) to play these files;

Because pmp1.0 and pmp2.0 format files are too different, if you want to implement the two types of files at the same time on small p, the code compilation will be complicated and the efficiency may be reduced.
At the same time, due to the insufficiency of the pmp1.0 format, we recommend that you discard the pmp1.0 format. The original pmp1.0 format can be converted to the 2.0 format through remux;
As for the pmp-mp4v and pmp-avc files, I personally think that they can be placed in a program supported, because their encapsulation is the same, but the stream inside is different;
You only need to decode different decoders.

[Post]
The purpose of writing this article is to help you understand the differences between pmp formats.
I want to have time and capability to make a pmp-mod for everyone and support pmp2.0 (including pmp-mp4v, pmp-avc), but actually I am busy now, there is not much effort to write this.
Therefore, another purpose of writing this article is to share my research, hoping that a technical expert can use this article to write a new pmp-mod, supports pmp2.0 format playback (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.