DirectShow中H.264 SourceFilter的Pin配置

对DirectShow SourceFilter,要在Pin上输出H.264码流,需要注意如下设置:

majortype: MEDIATYPE_Video {73646976-0000-0010-8000-00AA00389B71}
subtype: MEDIATYPE_AVC1 {31435641-0000-0010-8000-00AA00389B71}

 

FormatType要设置为FORMAT_MPEG2_VIDEO,对应的结构体为MPEG2VIDEOINFO

下面是一个分辨率为960x528的H.264 High Profile/Level 5.1视频例子


formattype: FORMAT_MPEG2_VIDEO {E06D80E3-DB46-11CF-B4D1-00805F6CBBEA}
bFixedSizeSamples: 0
bTemporalCompression: 0
lSampleSize: 1
cbFormat: 167

 

VIDEOINFOHEADER2:
rcSource: (0,0)-(0,0)
rcTarget: (0,0)-(0,0)
dwBitRate: 0
dwBitErrorRate: 0
AvgTimePerFrame: 417082

VIDEOINFOHEADER2:
dwInterlaceFlags: 0x00000000
dwCopyProtectFlags: 0x00000000
dwPictAspectRatioX: 20
dwPictAspectRatioY: 11
dwControlFlags: 0x00000000
dwReserved2: 0x00000000

 

BITMAPINFOHEADER:
biSize: 40
biWidth: 960
biHeight: 528
biPlanes: 1
biBitCount: 24
biCompression: avc1
biSizeImage: 0
biXPelsPerMeter: 1
biYPelsPerMeter: 1
biClrUsed: 0
biClrImportant: 0

 

MPEG2VIDEOINFO:
dwStartTimeCode: 0
cbSequenceHeader: 35 //dwSequenceHeader的长度
dwProfile:0x0000004d //high profile
dwLevel: 0x00000033 //0x33就是10禁止51,对应level 5.1
dwFlags: 0x00000004

 

dwSequenceHeader的格式:

[BigEndian格式的16位 SPS长度] + SPS + [[BigEndian格式的16位 PPS长度] +PPS

 

下面是完整的MPEG2VIDEOINFO结构体内容

pbFormat:
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00 3a 5d 06 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00 14 00 00 00 0b 00 00 00
0040: 00 00 00 00 00 00 00 00 28 00 00 00 c0 03 00 00 
0050: 10 02 00 00 01 00 18 00 61 76 63 31 00 00 00 00 
0060: 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 
0070: 00 00 00 00 23 00 00 00 4d 00 00 00 33 00 00 00 
0080: 04 00 00 00|00 1b 67 4d 40 33 96 64 07 80 87 7f 
0090: e0 00 20 00 22 00 0c ba 76 02 62 5a 01 1e 30 65

00a0: 40 00 04 68 ee 3c 80

你可能感兴趣的:(c,video,h.264)