使用Windows Media编码器和Win Media Services进行实时广播视频 [英] Live Broadcast Video using Windows Media Encoder and Win Media Services
本文介绍了使用Windows Media编码器和Win Media Services进行实时广播视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在一个项目中,我需要使用Win Media Encoder 9,Win Media Services,Win Server 2003,Asp.net 3.5/4.0,C#来直播视频.
我在使用Win Media Encoder sdk代码到我的Web应用程序时遇到了很多问题,例如Credentails问题,无法获取网络等等.
即使我启动win媒体编码器向导,它也会使我的用户名和密码无效.任何人都可以帮助我.
I am working on a project where i need to broadcast Live videos using win Media Encoder 9,Win Media Services,Win server 2003,Asp.net 3.5/4.0,C#.
i am facing much problems using win media Encoder sdk codes into my web application like Credentails issue,Unable to acquire network and much more.
Even when i launch win media encoder wizard it throws me username and pwd invalid.Can anyone help me out.
public static void Main()
{
try
{
// Create WMEncoderApp and WMEncoder objects.
WMEncoderApp EncoderApp = new WMEncoderApp();
WMEncoder wmEncoder = new WMEncoder();
IWMEncoder Encoder = EncoderApp.Encoder;
wmEncoder.OnAcquireCredentials += new _IWMEncoderEvents_OnAcquireCredentialsEventHandler(wmEncoder_OnAcquireCredentials);
// Display the predefined Encoder UI.
EncoderApp.Visible = true;
// Specify the source for the input stream.
IWMEncSourceGroupCollection SrcGrpColl = wmEncoder.SourceGroupCollection;
IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("Test");
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 = wmEncoder.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;
}
}
string strServerName = "ServerName:PortNumber";
string strPubPoint = "23";
string strPubTemplate = "Live";
//Broadcast a Live Event
IWMEncPushDistribution PushDist = (IWMEncPushDistribution)wmEncoder.Broadcast;
IWMEncBroadcast BrdCst = wmEncoder.Broadcast;
BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, 82);
//BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_PUSH_DISTRIBUTION, 82);
// Set the push distribution variables.
//string MyNSCFile = "\\SNGS-DEMO\\Test\\MyPubPoint.nsc";
//string MyNSCURL = "\\SNGS-DEMO\\Test\\MyPubPoint.nsc";
// string MyASXFile = "\\SNGS-DEMO\\Test\\MyPubPoint.asx";
PushDist.AutoRemovePublishingPoint = true;
// Generate the announcement file.
PushDist.ServerName = strServerName;
PushDist.PublishingPoint = strPubPoint;
PushDist.Template = strPubTemplate;
// PushDist.GenerateMulticastInfoFile(MyNSCFile);
// PushDist.GenerateAnnouncementFile(MyNSCURL, MyASXFile);
// Retrieve the IWMSPublishingPoints object.
//PubPoints = winMServer.PublishingPoints;
// Create a new WMSServer object.
winMServer = new WMSServer();
winMServer.AllowClientsToConnect = true;
// Retrieve the IWMSPlugin object for the
// WMS Publishing Points ACL Authorization plug-in.
//Plugin = winMServer.EventHandlers["WMS Publishing Points ACL Authorization"];
// Retrieve the administrative interface for the
// WMS Publishing Points ACL Authorization plug-in.
//IWMSACLCheckAdmin ACLCheckAdmin = (IWMSACLCheckAdmin)Plugin.CustomInterface;
// Retrieve the list of access control entries.
//IWMSAccessControlList AccessCtrlList = ACLCheckAdmin.AccessControlList;
//// Specify the push distribution variables, including the Windows Media
//// server name, publishing point, and announcement files.
wmEncoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(wmEncoder_OnStateChange);
wmEncoder.OnSourceStateChange += new _IWMEncoderEvents_OnSourceStateChangeEventHandler(wmEncoder_OnSourceStateChange);
//Server Credentials
wmEncoder.PrepareToEncode(true);
wmEncoder.Start();
}
catch (Exception e)
{
// TODO: Handle exceptions.
}
}
推荐答案
选中此项可能会找到帮助
http://www.c-sharpcorner.com/uploadfile/scottlysle/csharpwebvideo04212007133218pm/csharpwebvideo.aspx [ ^ ]
Check this you may find some help
http://www.c-sharpcorner.com/uploadfile/scottlysle/csharpwebvideo04212007133218pm/csharpwebvideo.aspx[^]
这篇关于使用Windows Media编码器和Win Media Services进行实时广播视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文