虚幻引擎像素流送(Pixel Streaming)允许你从任何有屏幕的联网设备(例如计算机,手机,平板电脑等)播放虚幻项目。使用像素流的好处是,输出设备不需要处理所有的场景、物理仿真和交互,只需要有一个屏幕和互联网连接。
·启用像素流插件
·在虚幻编辑器中打开项目。
·在虚幻编辑器的主菜单中选择 编辑(Edit) > 插件(Plugins) 。
·在 图像(Graphics) 下找到 像素流送(Pixel Streaming) 插件并勾选 启用(Enabled) 框。

- 点击 立即重启(Restart Now) 重启项目并应用修改。
返回虚幻编辑器,从主菜单中选择 编辑(Edit) > 项目设置(Project Settings) 。 如果项目中有角色,而您希望启用触控设备的输入(如手机和平板电脑)在关卡中移动此角色,则可能需要在屏幕上显示触摸控制器。
在 引擎(Engine) > 输入类型(Input category) 下启用 固定显示触控界面(Always Show Touch Interface) 设置。

此项为任选,并非所有项目强制要求。然而,在第三人称面板之类的项目中,这能确保拥有触控设备的用户能对流送的应用程序进行控制(前提是项目的玩家控制器支持输入)。
·在主菜单中选择 编辑(Edit) > 编辑器偏好(Editor Preferences...)
·在 关卡编辑器(Level Editor) > 播放(Play) 中找到 额外启动参数(Additional Launch Parameters) 设置,并将其值设为 -AudioMixer -PixelStreamingIP=localhost -PixelStreamingPort=8888
。

·打包Windows项目。从虚幻编辑器的主菜单中选择 文件(Files) > 打包项目(Package Project) > Windows > Windows (64-bit) 。

在快捷方式属性(Shortcut Properties) 窗口的快捷方式(Shortcut) 选项卡中,在目标(Target) 域的末尾附加文本-AudioMixer -PixelStreamingIP=localhost -PixelStreamingPort=8888
并点击确认。

官网提供三种获取像素流服务器的方法:
- 从以下地址直接访问github仓库:https://github.com/EpicGames/PixelStreamingInfrastructure
- 在你偏好的终端中执行
git clone --branch UE5.1 https://github.com/EpicGames/PixelStreamingInfrastructure.git
(确保你安装了git)。 - 找到
\Engine\Plugins\Media\PixelStreaming\Resources\WebServers
并运行get_ps_servers
命令(确保将相应的.bat
脚本用于Windows,将相应的.sh
脚本用于Linux)。这会自动将相关像素流送基础设施分支提取到该文件夹中。
我这里用的是Ue5.1版本
我们需要在Samples\PixelStreaming\WebServers\SignallingWebServer\platform_scripts\cmd
这里面进行相应的设置,首先运行setup.ps1,其次运行Start_SignallingServer.ps1
开启信令服务器。首次运行服务器时其将下载需要的所有依赖性。服务器启动,能够接收连接后,控制台窗口中将出现以下命令行:
WebSocket listening to Streamer connections on :8888
WebSocket listening to Players connections on :80
Http listening on *: 80
接下来我们再去运行我们打包完成的项目可执行文件,然后再输入我们本机的地址127.0.0.1,就可以加载以下的界面了。

二,公网部署
我们已经在以上阶段进行了本机的像素流测试,并且应该已经成功了。
现在我们需要准备一个云服务器,并且开启一部分端口号,我这里使用的是腾讯云服务器

UDP:22,3389,80,443,20,21,19303,19302,3478,8888,81,82
TCP:22,3389,80,443,20,21,19303,19302,3478,8888,81,82
现在我们需要把打包出来项目中的Sample文件中PixelStreaming文件上传到云服务器上

我们需要打开上传文件的config.json2文件

打开文件进行相应的更改

然后点击run_local.bat文件

然后再运行运行Start_SignallingServer.ps1开启信令服务器

然后在配置我们本地的可执行项目,将本地ip改成公网Ip

然后点击运行,现在显示我的界面进入了

现在就可以用我们的公网Ip进行登录了

如果想要多设备进行登录,就需要使用我们的Matchmaker文件里面的配置。
下一篇文章,将会讲解多设备登录的情况,并且实现