用于视频广播的 WPF 应用程序
本文关键字:应用程序 WPF 视频广播 用于 | 更新日期: 2023-09-27 18:37:27
我有一个使用 Microsoft.expression.encoder 和框架 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());
}
}
我正在使用MediaElement在我的服务器和客户端系统上显示网络摄像头。
在客户端
try
{
theMainWindow.getServerIPAddress();
IP = theMainWindow.machineIP;
MediaElement1.Source = new Uri("http://" + IP + ":9090/");
}
catch (Exception ex)
{
}
你可以
使用 IIS 平滑流式处理以较低的比特率材料开始播放,并在客户端缓冲区填满时逐渐增加它。Silverlight内置了对平滑流式处理的支持,并且可以在WPF中手动实现(至少在理论上)。
有什么特别的事情阻止您在客户端使用 SL 吗?