c# - 用于视频广播的 wpf 应用程序

标签 c# wpf mediaelement expression-encoder broadcasting

我有一个使用 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());
    }

}

我正在使用 MediaElement 在我的服务器和客户端系统上显示网络摄像头。

在客户端

try
            {

                theMainWindow.getServerIPAddress();
                IP = theMainWindow.machineIP;
                MediaElement1.Source = new Uri("http://" + IP + ":9090/");
            }
            catch (Exception ex)
            {
            }

最佳答案

您可以适本地使用 IIS 平滑流式处理以较低的比特率 Material 开始播放,并在您的客户端缓冲区填满时逐渐增加它。 Silverlight 内置了对平滑流的支持,同样可以在 WPF 中手动实现(至少理论上如此)。

有什么特别的事情阻止你在客户端使用 SL 吗?

关于c# - 用于视频广播的 wpf 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11077470/

相关文章:

c# - 为什么 WinRT MediaElement.SetSource 不执行它应该执行的操作?

c# - CheckBox 双向绑定(bind)不起作用

c# - 运算符 '+' 不能应用于类型 'byte[]' 和 'int' 的操作数

c# - wpf中datagrid和grid的区别

c# - Win8.1 上的 MediaElement 内存泄漏

c# - 将 View (xaml) 中的 MedialElement 绑定(bind)到 ViewModel 的属性

C# 动态映射输入文件的方法

c# - 错误 "Extension method must be static"是什么意思?

c# - 源代码级别的混淆比混淆器更有效?

c# - 如何在触发器中设置属性 (WPF)