使用表达编码器传输网络摄像头或屏幕截图时减少延迟

发布于 2024-11-11 17:51:05 字数 1856 浏览 4 评论 0原文

我有 10 秒的延迟,我需要实时或至少 1 秒。它不通过互联网。是否可以减少 WPF 中的缓冲时间?

服务器代码:

            job = new LiveJob();
        Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
        EncoderDevice device = devices[0]; 
        LiveDeviceSource source = job.AddDeviceSource(device, null);
        source.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties
                                                   {
                                                       CaptureCursor = true,
                                                       CaptureLargeCursor = false,
                                                       FrameRate = 6,
                                                       CaptureLayeredWindow = true,
                                                       Height = 600,
                                                       Width = 800,
                                                       Left = 0,
                                                       Top = 0,
                                                   };
        job.ActivateSource(source);
        // Finds and applys a smooth streaming preset
        job.ApplyPreset(LivePresets.VC1256kDSL16x9);
        // Sets up variable for fomat data
        var format = new PullBroadcastPublishFormat {BroadcastPort = 8080};
        job.PublishFormats.Add(format);
        job.StartEncoding();

玩家代码:

 <Window x:Class="XescPlayer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="600" Width="800">
    <Grid>
        <MediaElement Name="VideoControl" Source="http://localhost:8080" />
    </Grid>
</Window>

I've got a delay of 10 seconds, I need real-time or at least 1second. It doesn't go through the Internet. Is it possible to reduce buffer time in WPF?

Server code:

            job = new LiveJob();
        Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
        EncoderDevice device = devices[0]; 
        LiveDeviceSource source = job.AddDeviceSource(device, null);
        source.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties
                                                   {
                                                       CaptureCursor = true,
                                                       CaptureLargeCursor = false,
                                                       FrameRate = 6,
                                                       CaptureLayeredWindow = true,
                                                       Height = 600,
                                                       Width = 800,
                                                       Left = 0,
                                                       Top = 0,
                                                   };
        job.ActivateSource(source);
        // Finds and applys a smooth streaming preset
        job.ApplyPreset(LivePresets.VC1256kDSL16x9);
        // Sets up variable for fomat data
        var format = new PullBroadcastPublishFormat {BroadcastPort = 8080};
        job.PublishFormats.Add(format);
        job.StartEncoding();

Player Code:

 <Window x:Class="XescPlayer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="600" Width="800">
    <Grid>
        <MediaElement Name="VideoControl" Source="http://localhost:8080" />
    </Grid>
</Window>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文