rtmp協議傳送mp3和aac裸流的方法
Video Tags
如果TAG包中的TagType==9時,就表示這個TAG是video.
StreamID之後的資料就表示是VideoTagHeader,VideoTagHeader結構如下:
Field | Type | Comment |
Frame Type | UB [4] | Type of video frame. The following values are defined: 1 = key frame (for AVC, a seekable frame) 2 = inter frame (for AVC, a non-seekable frame) 3 = disposable inter frame (H.263 only) 4 = generated key frame (reserved for server use only) 5 = video info/command frame |
CodecID | UB [4] | Codec Identifier. The following values are defined: 2 = Sorenson H.263 3 = Screen video 4 = On2 VP6 5 = On2 VP6 with alpha channel 6 = Screen video version 2 7 = AVC |
AVCPacketType | IF CodecID == 7 UI8 |
The following values are defined: |
CompositionTime | IF CodecID == 7 SI24 |
IF AVCPacketType == 1 Composition time offset ELSE 0 See ISO 14496-12, 8.15.3 for an explanation of composition times. The offset in an FLV file is always in milliseconds. |
VideoTagHeader的頭1個位元組,也就是接跟著StreamID的1個位元組包含著視訊幀型別及視訊CodecID最基本資訊.表裡列的十分清楚.
VideoTagHeader
AVCPacketType 和 CompositionTime。AVCPacketType 表示接下來 VIDEODATA (AVCVIDEOPACKET)的內容:
IF AVCPacketType == 0 AVCDecoderConfigurationRecord(AVC sequence header)
IF AVCPacketType == 1 One or more NALUs (Full frames are required)
AVCDecoderConfigurationRecord.包含著是H.264解碼相關比較重要的sps和pps資訊,再給AVC解碼器送資料 流之前一定要把sps和pps資訊送出,否則的話解碼器不能正常解碼。而且在解碼器stop之後再次start之前,如seek、快進快退狀態切換等,都 需要重新送一遍sps和pps的資訊.AVCDecoderConfigurationRecord在FLV檔案中一般情況也是出現1次,也就是第一個 video tag.
AVCDecoderConfigurationRecord的定義在ISO 14496-15, 5.2.4.1中,這裡不在詳細貼,