使用者工具

網站工具


program:net:捕捉攝影機内容

使用 C# 捕捉攝影機内容

//在button的click事件中加入:(前提是你装有Media 编码器9) 
//記得 using WMEncoderLib;
 
// Create WMEncoderApp and WMEncoder objects. 
WMEncoderApp EncoderApp = new WMEncoderApp();
IWMEncoder Encoder = EncoderApp.Encoder;
 
// Display the predefined Encoder UI. 
EncoderApp.Visible = true;
 
// Specify the source for the input stream. 
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", "");
 
// Specify a profile. 
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;
    }
}
 
// Create a broadcast. 
IWMEncBroadcast BrdCst = Encoder.Broadcast;
BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, 8080);
 
// Start the encoding process. 
Encoder.PrepareToEncode(true);
Encoder.Start();
program/net/捕捉攝影機内容.txt · 上一次變更: 2019/11/16 08:12 由 127.0.0.1