Window Media Encoder 捕捉音频视频

需要保存视频头录像及麦克录音,试了很多库,如ffmpeg,最后还是用微软自己的WME搞定,需要安装 Window Media Encoder sdk及media视频编码器9系列。

使用时,需引入using WMEncoderLib;

WMEncoderApp EncoderApp = new WMEncoderApp(); IWMEncoder Encoder = EncoderApp.Encoder; EncoderApp.Visible =true; IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection; IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcAud.SetInput("Default_Audio_Device", "Device", ""); SrcVid.SetInput("Default_Video_Device", "Device", ""); IWMEncProfile Pro; IWMEncProfileCollection ProColl = Encoder.ProfileCollection; for (int i = 0; i < ProColl.Count; i++) { Pro = ProColl.Item(i); if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)") { SrcGrp.set_Profile(Pro); break; } } Encoder.Start(); Encoder.Stop();

其中 encoder.start()开始编码,encoder.stop()停止编码。当停止编码后,media encoder主界面EncoderApp还是存在的,无法关闭,可以kill掉对应的进程

你可能感兴趣的:(windows,video,kill,NetWork,微软,audio)