Ano*_*han 5 c# wpf expression broadcasting video-streaming
我有一个使用Microsoft.expression.encoder和framework 4.0播放视频的WPF应用程序,但我在播放时有15秒的延迟.有任何建议减少广播时的延迟.
以下是守则
using Microsoft.Expression.Encoder.Live;
using Microsoft.Expression.Encoder;
private void button1_Click(object sender, RoutedEventArgs e)
{
try
{
EncoderDevice video = null;
EncoderDevice audio = null;
GetSelectedVideoAndAudioDevices(out video, out audio);
StopJob();
if (video == null)
{
return;
}
StopJob();
_job = new LiveJob();
if (video != null && audio != null)
{
//StopJob();
_deviceSource = null;
_deviceSource = _job.AddDeviceSource(video, audio);
_job.ActivateSource(_deviceSource);
// Finds and applys a smooth streaming preset
//_job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3);
// Creates the publishing format for the job
PullBroadcastPublishFormat format = new PullBroadcastPublishFormat();
format.BroadcastPort = 9090;
format.MaximumNumberOfConnections = 50;
// Adds the publishing format to the job
_job.PublishFormats.Add(format);
// Starts encoding
_job.StartEncoding();
}
//webCamCtrl.StartCapture();
}
catch (Exception ex)
{
WriteLogFile(this.GetType().Name, "button1_Click", ex.Message.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用MediaElement在我的服务器和客户端系统上显示网络摄像头.
在客户端
try
{
theMainWindow.getServerIPAddress();
IP = theMainWindow.machineIP;
MediaElement1.Source = new Uri("http://" + IP + ":9090/");
}
catch (Exception ex)
{
}
Run Code Online (Sandbox Code Playgroud)
小智 2
不幸的是没有解决方案(至少截至 2011 年 1 月)。根据微软的说法:
“我们在编码过程中添加了几秒的延迟,然后在服务器级别进行缓存,可以再添加 5-20 秒,最后 Silverlight 还会再缓存几秒的延迟。”
http://social.expression.microsoft.com/Forums/is/encoder/thread/898b2659-c0d5-4c84-8fba-225f58806f5d