email这么多,在线解决.
在button的click事件中加入:(前提是你装有Media 编码器9)
// 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();Top
29 楼 hunter4500(hunter4500) 回复于 2003-07-18 15:34:10 得分 0
还有,引用中加上windows media encoder
代码前加上using WMEncoderLib;Top
多个摄像头的参考
int lPreviewStream;
string sDeviceString;
// Create a WMEncoder object.
Encoder = new WMEncoder();
// Retrieve a device control plug-in info manager object from WMEncoder.
DCPlugMgr = Encoder.DeviceControlPluginInfoManager;
// Loop through the connected digital devices on the system such as DV cameras and VTRs.
for (int i = 0; i < DCPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = DCPlugMgr.Item(i);
// Find the first device plug-in that support resources.
if (PlugInfo.SchemeType=="DeviceControl" && PlugInfo.Resources == true)
{
sDeviceString = PlugInfo.Item(0);
}
break;
}
// Add an audio source and a video source.
SrcGrpColl = Encoder.SourceGroupCollection;
SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add("SG_1");
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcAud.SetInput(sDeviceString, "Device", "");
SrcVid.SetInput(sDeviceString, "Device", "");
参考2:
// Create a WMEncoder object.
WMEncoder Encoder = new WMEncoder();
// Retrieve source and device plug-in info manager objects from WMEncoder.
IWMEncSourcePluginInfoManager SrcPlugMgr = Encoder.SourcePluginInfoManager;
IWMEncDeviceControlPluginInfoManager DCPlugMgr = Encoder.DeviceControlPluginInfoManager;
// Loop through all the audio and video devices on the system.
IWMEncPluginInfo PlugInfo;
for (int i = 0; i < SrcPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = SrcPlugMgr.Item(i);
// Find the device plug-ins that support resources.
if (PlugInfo.SchemeType == "DEVICE" && PlugInfo.Resources == true)
{
// Loop through the resources in the current plug-in.
for (int j = 0; j<PlugInfo.Count; j++)
{
// Add audio resources to the cboAudioSource combo box.
if (PlugInfo.MediaType == WMENC_SOURCE_TYPE.WMENC_AUDIO) cboAudioSource.Items.Add(PlugInfo.Item(j));
// Add video resources to the cboVideoSource combo box.
if (PlugInfo.MediaType == WMENC_SOURCE_TYPE.WMENC_VIDEO) cboVideoSource.Items.Add(PlugInfo.Item(j));
}
}
}
// This section shows how to enumerate digital devices such as DV cameras and VTRs.
// Loop through the connected digital devices on the system.
for (int i = 0; i < DCPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = DCPlugMgr.Item(i);
// Loop through the resources in the current plug-in
// and add them to the cboDevices combo box.
if (PlugInfo.SchemeType=="DeviceControl" && PlugInfo.Resources == true)
{
for (int j = 0; j< PlugInfo.Count; j++) cboDevices.Items.Add(PlugInfo.Item(j));
}
}