private void CreateH264Decoder() { HResult hr; // create H.264 decoder var comobject = new ResamplerMediaComObject(); decodertransform = (IMFTransform)comobject; // setup input media type for decoder MFExtern.MFCreateMediaType(out decinputmediatype); // setup media type manualy IMFMediaType testdecinputmediatype, testdecoutputmediatype; decinputmediatype.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video); decinputmediatype.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, MFMediaType.H264); decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, (int)MFVideoInterlaceMode.Progressive); MFExtern.MFSetAttributeSize(decinputmediatype, MFAttributesClsid.MF_MT_FRAME_SIZE, VIDEO_SAMPLE_WIDTH, VIDEO_SAMPLE_HEIGHT); uint fixedSampleSize = VIDEO_SAMPLE_WIDTH * (16 * ((VIDEO_SAMPLE_HEIGHT + 15) / 16)) + VIDEO_SAMPLE_WIDTH * (VIDEO_SAMPLE_HEIGHT / 2);//for Y, U and V decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_SAMPLE_SIZE, fixedSampleSize); decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_DEFAULT_STRIDE, VIDEO_SAMPLE_WIDTH); decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_FIXED_SIZE_SAMPLES, 1); decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_ALL_SAMPLES_INDEPENDENT, 1); MFExtern.MFSetAttributeRatio(decinputmediatype, MFAttributesClsid.MF_MT_PIXEL_ASPECT_RATIO, 1, 1); hr = decodertransform.SetInputType(0, decinputmediatype, 0); decodertransform.GetInputAvailableType(0, 0, out testdecinputmediatype); // setup media type for output of decoder MFExtern.MFCreateMediaType(out decoutputmediatype); decoutputmediatype.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video); decoutputmediatype.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, MFMediaType.IYUV); MFExtern.MFSetAttributeSize(decoutputmediatype, MFAttributesClsid.MF_MT_FRAME_SIZE, VIDEO_SAMPLE_WIDTH, VIDEO_SAMPLE_HEIGHT); MFExtern.MFSetAttributeRatio(decoutputmediatype, MFAttributesClsid.MF_MT_FRAME_RATE, 30, 1); MFExtern.MFSetAttributeRatio(decoutputmediatype, MFAttributesClsid.MF_MT_PIXEL_ASPECT_RATIO, 1, 1); decoutputmediatype.SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, 2); hr = decodertransform.SetOutputType(0, decoutputmediatype, 0); decodertransform.GetOutputAvailableType(0, 0, out testdecoutputmediatype); decodertransform.GetInputStatus(0, out mftStatus); if (mftStatus != MFTInputStatusFlags.AcceptData) { Debug.WriteLine("DECODER NOT ACCEPT INPUT DATA"); return; } else { Debug.WriteLine("PROCESS INPUT DONE>>>> " + mftStatus); } decodertransform.ProcessMessage(MFTMessageType.CommandFlush, (IntPtr)null); decodertransform.ProcessMessage(MFTMessageType.NotifyBeginStreaming, (IntPtr)null); decodertransform.ProcessMessage(MFTMessageType.NotifyStartOfStream, (IntPtr)null); }