使用 VLC 以尽可能低的延迟通过 RTP 流式传输桌面 [英] Stream desktop over RTP using VLC with the lowest latency possible

查看:98
本文介绍了使用 VLC 以尽可能低的延迟通过 RTP 流式传输桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试弄清楚如何使用 VLC 流式传输我的桌面(通过 LAN)并实现尽可能低的延迟(<100 毫秒).目标是让另一台计算机接收流并可能在流传输时玩游戏(即在电视旁边的 PC 上从 PC1 玩游戏).

I have been trying to figure out how to stream my desktop (over LAN) using VLC and to achieve the lowest latency possible (<100ms). The goal is to have another computer receive the stream and potentially play games while streaming (i.e playing game from PC1 on the PC beside the TV).

我应该使用哪些设置?我尝试了多种方法,但尚未成功.

What settings should I use? I have tried multiple approaches but have yet to succeed.

我也愿意使用 VLC 以外的其他东西.

I am open to using something other than VLC as well.

推荐答案

我也用 VLC 尝试过同样的方法,但始终无法获得低于 3 秒的延迟.FFmpeg 创造了奇迹,最终提供了低于 1 秒的延迟.

I have also tried the same with VLC and couldn't ever get latency bellow 3 seconds. FFmpeg did wonders and finally provided a latency bellow 1 second.

mpeg2video 和 UPD 提供了最好的结果,RTP 延迟感觉有点差但非常接近.迁移到 x264 可以提高质量以换取更多的延迟,但这实际上取决于有多少动态内容以及 CPU 的速度.我只让 x264 与 UDP 一起工作,但必须有一种方法可以使用 RTP 做到这一点.

mpeg2video and UPD provided the best results, RTP latency felt a bit worse but very close. Moving to x264 improves quality in exchange for a bit more latency, but that really depends on how much dynamic content is there and how fast the CPU is. I only got x264 working with UDP, but there must be a way to do it with RTP.

我不确定它是否适合玩.服务器将承受繁重的工作负载,延迟会很明显 - 至少在 Linux 上,不知道 Windows.

I'm not sure it's feasible for playing. The server will be under a heavy workload and latency will be noticeable - at least on Linux, don't know about windows.

在 Linux 上尝试以下命令之一:

On Linux try one of the following commands:

$ ffmpeg -f x11grab -s 1600x900 -r 50 -vcodec mpeg2video -b:v 8000 -f rtp rtp://192.168.0.10:1234

$ ffmpeg -f x11grab -s 1600x900 -r 50 -vcodec libx264 -preset ultrafast -tune zerolatency -crf 18 -f mpegts udp://192.168.0.10:1234

调整屏幕分辨率(-s )、刷新率(-r )、带宽(-b:v )、质量(-crf 18-qp 18,越低越好)和目标 ip:port.

Adjust for screen resolution (-s <your resolution>), refresh rate (-r <fps>), bandwidth (-b:v <bits/s>), quality (-crf 18 or -qp 18, the lower the better), and target ip:port.

如果运行 Windows,请使用 dshow 代替 x11grab.

If running Windows use dshow in place of x11grab.

使用 ffplay udp://192.168.0.10:1234ffplay sdp://192.168.0.10:1234 观看.

请注意,这些选项都不会播放声音.在流式传输音频时,我也无法获得如此低的延迟.这可能是可行的,我只是不知道怎么做.

Mind you that none of those options will stream sound. I was unable to get such low latencies when streaming audio as well. It might be doable, I just didn't figured out how.

响应最快的客户端是 ffplayVLC 即使将其网络缓存设置为零也引入了太多延迟 - 使用这种缓存实际上变得更糟,因为它试图过于频繁地重新同步"流.

The most responsive client was ffplay, VLC introduced too much latency even with its network cache set to zero - with such cache it actually got worse, since it tried to 'resync' the stream too often.

如果您需要更多详细信息,我做了一个 发布关于我的发现.希望能帮助到你.我感谢任何反馈.^_^

If you need further details I made a post about my findings. Hope it helps. I appreciate any feedback. ^_^

这篇关于使用 VLC 以尽可能低的延迟通过 RTP 流式传输桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆