First, the analysis of the FLV data
We acquire a flv file to a simple analysis of the data format flv
This is not the focus of this article, this is skipped. I believe we control the flv standard documents
can understand the the flv data format, and I want to learn this
knowledge friend first completion of this step is also highly
recommended.
RTMP uplink h264 video stream
The tools I use is Notepad + + (and install the binary view plug-in)
If you have to do the first step, it is not difficult to see that rtmp flv video stream is the one after the Video tag - FLV tag in the removal of the head, leaving only the video tag content.
Our control flv standard document-by-analysis
17:1-keyframe 7-avc
00: AVC sequence header - AVC packet type
00 00 00: composition time, AVC when all 0s, meaningless
Because AVC packet type = AVC sequence header, next step is AVCDecoderConfigurationRecord of the contents of the
profile_compatibility = 00
Followed by another new a videotag package data
17:1-keyframe 7-avc
01: AVC NALU
00 00 00: composition time, AVC when all 0s, meaningless
Because AVCPacket type = AVC NALU, the next step is one or more NALU
Each
NALU package front has (lengthSizeMinusOne & 3) +1 bytes of NAL
packet length description (previously mentioned, remember), previously
calculated for the four bytes
00 00 00 02: 2 ?? - NALU length
09 10: NAL package
Insert NALU knowledge, the first five of the first byte of each NALU marked the NAL package type, NAL nal_unit_type
# Define NALU_TYPE_SLICE 1 # Define NALU_TYPE_DPA a 2 # Define NALU_TYPE_DPB a 3 The # define NALU_TYPE_DPC 4 # Define NALU_TYPE_IDR a 5 The # define NALU_TYPE_SEI 6 # Define NALU_TYPE_SPS a 7 The # define NALU_TYPE_PPS 8 The # define NALU_TYPE_AUD 9 / / access delimiters # define NALU_TYPE_EOSEQ 10 # Define NALU_TYPE_EOSTREAM a 11 The # define NALU_TYPE_FILL 12
09 & 0x1f = 9, the access unit delimiter
We resolve SPS header bytes 67, 67 & 0x1F = 7, pps head byte 68,68 & 0x1f = 8, just to correspond on .
00000029: Description next NAL package length 41
06
00 11 80 00 af c8 00 00 03 00 00 03 00 00 af c8 00 00 03 00 00 40 01 0c
00 00 03 00 00 03 00 90 80 08 00 00 03 00 08 80:06 & 0x1f = 6 - SEI
00 00 3c D0: next NAL packet length
65 88 80 . .....: 65 & 0x1f = 5 - I frame data
See 00003d80 line, in front of up to 53 4f 7f are on a video tag content, pull 658,880 said earlier that I frame data, 27 is a video tag
27:2-inter frame, P frame , 7-CodecID = AVC
01: AVCPacket type = AVC NALU
00 00 00: composition time, AVC when all 0s, meaningless
000000020930: with the above analysis of the same pull 2 bytes nal package, access unit delimiter
11:17 000000 bytes NAL package
06 01 0c 00 00 80 00 00 90 80 18 00 00 03 00 08 80:06 & 0x1f = 6-SEI
00 00 46 85: NAL packet data length
41 9a 02 . .....: 41 & 0x1f = 1, P frame data
Third, the conversion
Roughly summarized under flv h264 stream, according to the order
1, a video tag, the information contained in: SPS, PPS, access unit delimiter, SEI, I frame packet
2, one or a plurality of video tag, containing information: access unit delimiter, SEI, P-frame packet for a plurality of
Cycle 1, 2
It should be noted, do this step conversion, we need from videotag , get to, a
NAL package can, it is the I-frames, P-frames and other types, in fact,
we do not need to care about here just to better analyze the data.
h264 NALU and NALU between 000,001 (00,000,001) separated, composition h264 format
1,00 00 00 01 SPS 00 00 00 01 PPS 00 00 00 01 Access Unit separator character 00 00 00 01 SEI 00 00 00 01 I frame 00 00 00 01 P frame 00 00 00 01 P frame . ..... (P frame variable number )
Cycle 1
Access unit delimiter and SEI is not necessary, h264 in binary form write to a file, use the Elecard StreamEye can broadcast, download address
No comments:
Post a Comment