/// <summary> /// AnnexB formatted h264 bitstream /// </summary> /// <param name="streamInfo"></param> /// <returns></returns> public static AMMediaType H264_AnnexB(InputstreamInfo streamInfo) { int width = (int)streamInfo.Width; int height = (int)streamInfo.Height; if (streamInfo.ExtraData.Length > 0) { var codecData = new H264CodecData(streamInfo.ExtraData); SPSUnit spsUnit = new SPSUnit(codecData.SPS); width = spsUnit.Width(); height = spsUnit.Height(); } VideoInfoHeader2 vi = new VideoInfoHeader2(); vi.SrcRect.right = width; vi.SrcRect.bottom = height; vi.TargetRect.right = width; vi.TargetRect.bottom = height; int hcf = HCF(width, height); vi.PictAspectRatioX = width / hcf; vi.PictAspectRatioY = height / hcf; vi.BmiHeader.Width = width; vi.BmiHeader.Height = height; vi.BmiHeader.Planes = 1; vi.BmiHeader.Compression = FOURCC_H264; AMMediaType amt = new AMMediaType(); amt.majorType = MediaType.Video; amt.subType = MediaSubType.H264; amt.temporalCompression = true; amt.fixedSizeSamples = false; amt.sampleSize = 1; amt.SetFormat(vi); return amt; }
public void SetFormat(VideoInfoHeader2 vih) { if (vih != null) { int cb = Marshal.SizeOf(vih); IntPtr _ptr = Marshal.AllocCoTaskMem(cb); try { Marshal.StructureToPtr(vih, _ptr, true); SetFormat(_ptr, cb); formatType = FormatType.VideoInfo2; } finally { Marshal.FreeCoTaskMem(_ptr); } } }
public Mpeg2VideoInfo() { hdr = new VideoInfoHeader2(); dwSequenceHeader = null; dwStartTimeCode = 0; cbSequenceHeader = 0; dwProfile = 0; dwLevel = 0; dwFlags = 0; }