# peer-stream **Repository Path**: cachalotlee/peer-stream ## Basic Information - **Project Name**: peer-stream - **Description**: 虚幻引擎UE5 像素流,和官方臃肿不堪的像素流SDK相比,我们在官方的基础上做了大量的优化和精简,开发出了轻量、零依赖、开箱即用的软件套装,前端的peer-stream.js基于WebComponentsAPI,后端signal.js基于NodeJS和npm/ws。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 7 - **Created**: 2024-04-30 - **Last Updated**: 2024-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # UE5 Pixel Streaming SDK [中文](README-zh.md) [English](README.md) Compared to EpicGame's heavily-designed SDK for Pixel Streaming, peer-stream.js is a lightweight WebRTC library with 0 dependency, containing a frontend component (using WebComponents API), along with a signaling server (using NodeJS). - peer-stream.js: browser SDK for player. - signal.js: node.js signaling server. - .signal.js: signal.js with env variables. - test.html: browser web page. ## Demo ```s # install WebSocket npm install ws@8.5.0 # start Signaling Server PORT=88 node signal.js # start packaged UE5 start path/to/UE5.exe -PixelStreamingURL="ws://localhost:88" # visit webpage start http://localhost:88/test.html ``` ## Env Variables for signal.js | env | type | default | usage | | -------- | -------- | --------- | -------------------------------------------------- | | PORT | number | 88 | WebSocket/HTTP port for player & UE5 | | UE5_* | string[] | [] | run command when player connected (UE5 auto start) | | one2one | bool | false | one-to-one mapping for player & UE5 | | token | string | '' | WebSocket password | | limit | number | +Infinity | limit max number of players connected | | throttle | bool | false | WebSocket throttle, prevent frequent reconnection | ### Load Balance `signal.js` accept multi UE5 & player connections, where each UE5 maps to multi-players with load-balancing. Turn `one2one` on to keep one-to-one mapping. Provide `UE5_*` to start UE5 automatically. More detailed example in `.signal.js`. ## Unreal Engine enable the plugin: ```s Plugins > Built-In > Graphics > Pixel Streaming > Enabled Editor Preferences > Level Editor > Play > Additional Launch Parameters start path/to/UE5.exe -{key}={value} ``` common startup options: ```s -PixelStreamingURL="ws://localhost:88" -RenderOffScreen -Unattended -GraphicsAdapter=0 -ForceRes -Windowed -ResX=1280 -ResY=720 -AudioMixer -AllowPixelStreamingCommands -PixelStreamingEncoderRateControl=VBR ``` ## peer-stream.js HTML: ```html ``` or JavaScript: ```html ``` ### Messages sending messages: ```js // object will be JSON.stringify() ps.emitMessage(msg: string | object); ``` receiving messages: ```js ps.addEventListener("message", e => { // JSON.parse(e.detail) }); ``` ## Requirement - Google Chrome 90+ - Unreal Engine 5.0.3 - NodeJS 14+ - npm/ws 8.0+ ## © MIT License Copyright (c) 2020-2022 XOSG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.