forked from ChimeraOS/chimera
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some considerations - This will need SLS installed. Will provide our own configuration. - Currently uses FFmpeg with hardcoded values as explained in ChimeraOS#44 discussion. To test from the repo, copy `./config/sls.conf` to `~/.local/share/steam-buddy/settings/sls.conf` and start steam-buddy: ``` $ ./steam-buddy ``` Then after logging in into steam-buddy got to the url: `[steam-buddy-url]/streaming/net/start` to start streaming, and `[steam-buddy-url]/streaming/net/stop` to stop. To consume the stream you can do: ``` $ ffplay -fflags nobuffer -i "srt://[steam-buddy-url]:8080?streamid=live.gameros/live/stream" ```
- Loading branch information
Showing
5 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
srt { #SRT | ||
worker_threads 1; | ||
worker_connections 300 ; | ||
|
||
log_file logs/error.log ; | ||
log_level info; | ||
|
||
record_hls_path_prefix /tmp/mov/sls; | ||
|
||
server { | ||
listen 8080; | ||
latency 20; #ms | ||
|
||
domain_player live.gameros ; | ||
domain_publisher uplive.gameros; | ||
backlog 100; #accept connections at the same time | ||
idle_streams_timeout 10;#s -1: unlimited | ||
app { | ||
app_player live ; | ||
app_publisher live ; | ||
|
||
record_hls off;#on, off | ||
record_hls_segment_duration 10; #unit s | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import os | ||
import shlex | ||
import datetime as dt | ||
import subprocess as sp | ||
|
||
|
||
class StreamServer: | ||
|
||
def __init__(self, sls_conf_file): | ||
self.sls_conf_file = sls_conf_file | ||
self._ffmpeg_cmd = "ffmpeg" | ||
self._sls_cmd = "sls" | ||
self._sls = None | ||
self._ffmpeg = None | ||
|
||
def __generate_sls_conf(self): | ||
pass | ||
|
||
def __start_sls(self): | ||
if self._sls is None: | ||
self._sls = sp.Popen([self._sls_cmd, '-c', self.sls_conf_file]) | ||
else: | ||
raise(Exception("Error starting SLS: Already started")) | ||
|
||
def __stop_sls(self): | ||
self._sls.terminate() | ||
try: | ||
self._sls.wait(5) | ||
except sp.TimeoutExpired: | ||
self._sls.kill() | ||
self._sls = None | ||
|
||
def __start_ffmpeg(self, local=False): | ||
command_line = "" | ||
VCODEC = "libx264" | ||
VCODEC_OPTIONS = "-preset ultrafast -tune zerolatency" | ||
VSIZE = "1920x1080" | ||
ACODEC = "libmp3lame" | ||
ACODEC_OPTIONS = "" | ||
FPS = "60" | ||
|
||
if local: | ||
STREAM = "~/screen" + dt.datetime.now() +".mp4" | ||
else: | ||
STREAM = '"srt://localhost:8080?streamid=uplive.gameros/live/stream"' | ||
|
||
command_line = self._ffmpeg_cmd + " " + \ | ||
"-f x11grab -framerate " + FPS + " -i :0 " + \ | ||
"-f alsa -ac 2 -i pulse " + \ | ||
"-vcodec " + VCODEC + " " + VCODEC_OPTIONS + " " + \ | ||
"-acodec " + ACODEC + " " + ACODEC_OPTIONS + " " + \ | ||
"-video_size " + VSIZE + " " + \ | ||
"-flush_packets 0 " + \ | ||
"-f mpegts " + \ | ||
STREAM | ||
args = shlex.split(command_line) | ||
if self._ffmpeg is None: | ||
self._ffmpeg = sp.Popen(args) | ||
else: | ||
raise(Exception("Error starting FFMpeg: Already started")) | ||
|
||
def __stop_ffmpeg(self): | ||
self._ffmpeg.terminate() | ||
try: | ||
self._ffmpeg.wait(5) | ||
except sp.TimeoutExpired: | ||
self._ffmpeg.kill() | ||
self._ffmpeg = None | ||
|
||
def stream_to_lan(self): | ||
self.__start_sls() | ||
self.__start_ffmpeg() | ||
|
||
def stop_stream(self): | ||
self.__stop_ffmpeg() | ||
self.__stop_sls() |