delcourtfl / stream-play-server

Remote Gaming Application in Go using WebRTC for low latency
MIT License
9 stars 2 forks source link
ffmpeg game-streaming-server gaming go golang hacktoberfest js media-streaming remote-desktop remote-gaming-server vigem webrtc

Stream Play Server (SPS)

SPS Logo

Stream Play Server (SPS) is a WebRTC-powered media server for real-time video streaming and remote control of Windows applications enabling Remote Gaming in a simple web browser environment.

Demo

Small video showing the usage of SPS using a phone with one controller connected to play a game (Biped) remotely

Demo with Biped game

Features

Description

SPS Diagram

Handles real-time communication and media streaming to/between peers in a WebRTC-based application (Media Processing and Input Management)

Intermediary for WebRTC clients to exchange session information and coordinate the establishment of direct peer-to-peer connections

User-facing part of the WebRTC application that runs in the web browser (User Interface)

Main page Admin page
Main Admin
http://ip\_address http://ip\_address/admin/
There are 3 tabs available for the media stream, controller setup and connection setup The 5 log files are checked every 10 seconds to display the subprocesses states

Custom Installation

Prerequisites :

Installation steps :

  1. Clone the repository.
    git clone https://github.com/delcourtfl/stream-play-server.git
  2. Navigate to the project directory.
    cd stream-play-server
  3. Install the dependencies before running (optionnal).
    go get ./...
  4. Launch the SPS application.
    go run .

Usage

Set the ip address and port used in the config.json file before running (if no window name is provided the app list every visible windows and ask for the user input) :

{
    "ip_address": "192.168.68.108",
    "port": "3000",
    "window_name": ""
}

(optional) Modify the ffmpeg commands to suit your needs (capture.go) :

ffmpegCmdVideo, err = launchCommand(
    "ffmpeg",
    []string{
        "-stats_period", "10",
        "-f", "gdigrab",
        "-thread_queue_size", "1024",
        "-framerate", "30",
        "-i", "title="+windowTitle,
        "-vf", "scale=-1:720",
        "-c:v", "libx264",
        "-preset", "ultrafast",
        "-tune", "zerolatency",
        "-crf", "25",
        "-pix_fmt", "yuv420p",
        "-an",
        "-f", "rtp", "rtp://127.0.0.1:5004?pkt_size=1200",
    },
    "../logs/video.log",
)
...
// Adding Audio streaming introduce latency and needs to be fixed
ffmpegCmdAudio, err = launchCommand(
    "ffmpeg",
    []string{
        "-stats_period", "10",
        "-f", "dshow",
        "-i", "audio=Mixage stéréo (Realtek(R) Audio)",
        "-c:a", "libopus",
        "-application", "lowdelay",
        "-vbr", "off",
        "-compression_level", "0",
        "-frame_duration", "20",
        "-vn",
        "-f", "rtp", "rtp://127.0.0.1:5005",
    },
    "../logs/audio.log",
)

Start the application :

go run . -ui

Once the application is running some commands are available :

1

For the user interface multiple steps are also needed :

Technologies Used

Areas of Improvement

This project is a work in progress and as such there are areas that are still being refined and improved. This repository is open to any contributions, suggestions and recommendations for improvements and fixes.

Current issues :

License

MIT License

Acknowledgement