From 263f91fc1166511b7b66a281dc1a9444644956e8 Mon Sep 17 00:00:00 2001 From: Micha Albert Date: Thu, 15 Aug 2024 13:07:54 -0400 Subject: [PATCH] continued wip --- docker-compose.yml | 9 ++++++--- obs/Dockerfile | 10 ++-------- obs/{setup-obs.py => setup_obs.py} | 10 +++++++++- obs/start.sh | 9 ++++----- 4 files changed, 21 insertions(+), 17 deletions(-) rename obs/{setup-obs.py => setup_obs.py} (66%) diff --git a/docker-compose.yml b/docker-compose.yml index baad3ea..1783702 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,6 @@ -version: '2' - services: web-frontend: build: - # build from Dockerfile context: ./tiling-frontend dockerfile: Dockerfile volumes: @@ -14,5 +11,11 @@ services: dockerfile: Dockerfile volumes: - tiling_frontend_build:/home/obs/html + environment: + OBSWS_PASSWORD: ${OBSWS_PASSWORD} + YT_STREAM_KEY: ${YT_STREAM_KEY} + mediamtx: + network_mode: host + image: docker.io/bluenviron/mediamtx volumes: tiling_frontend_build: diff --git a/obs/Dockerfile b/obs/Dockerfile index 8bd3fea..b3557e5 100644 --- a/obs/Dockerfile +++ b/obs/Dockerfile @@ -1,7 +1,5 @@ FROM docker.io/ubuntu:noble -ENV OBSWS_PASSWORD="" - RUN apt update && \ apt install software-properties-common -y && \ add-apt-repository ppa:obsproject/obs-studio -y && \ @@ -16,9 +14,7 @@ USER obs RUN mkdir -p /home/obs/.config/obs-studio/basic/profiles/Untitled -RUN echo -e "\n[OBSWebSocket]\nFirstLoad=false\nServerEnabled=true\nServerPort=4455\nAlertsEnabled=false\nAuthRequired=true\nServerPassword=${OBSWS_PASSWORD}\n" >> /home/obs/.config/obs-studio/global.ini - -RUN echo '{"type":"rtmp_common","settings":{"service":"YouTube - RTMPS","protocol":"RTMPS","server":"rtmps://a.rtmps.youtube.com:443/live2","bwtest":false,"key":"${YT_STREAM_KEY}","stream_key_link":"https://www.youtube.com/live_dashboard","multitrack_video_name":"Multitrack Video","multitrack_video_disclaimer":"Multitrack Video automatically optimizes your settings to encode and send multiple video qualities to YouTube - RTMPS. Selecting this option will send YouTube - RTMPS information about your computer and software setup."}}' > /home/obs/.config/obs-studio/basic/profiles/Untitled/service.json +RUN echo -e "\n[OBSWebSocket]\nFirstLoad=false\nServerEnabled=true\nServerPort=4455\nAlertsEnabled=false\nAuthRequired=false\nServerPassword=does_not_matter\n" >> /home/obs/.config/obs-studio/global.ini COPY requirements.txt /home/obs @@ -28,8 +24,6 @@ RUN /home/obs/.venv/bin/pip install -r /home/obs/requirements.txt COPY start.sh /home/obs -COPY setup-obs.py /home/obs - -RUN echo $OBSWS_PASSWORD +COPY setup_obs.py /home/obs ENTRYPOINT /home/obs/start.sh diff --git a/obs/setup-obs.py b/obs/setup_obs.py similarity index 66% rename from obs/setup-obs.py rename to obs/setup_obs.py index 09381c2..c12f7f0 100644 --- a/obs/setup-obs.py +++ b/obs/setup_obs.py @@ -2,7 +2,7 @@ import obsws_python as obs import os # pass conn info if not in config.toml -client = obs.ReqClient(host='localhost', port=4455, password=os.environ["OBSWS_PASSWORD"]) +client = obs.ReqClient(host='localhost', port=4455, password=None) scene = client.get_scene_list().scenes[0]['sceneName'] @@ -12,3 +12,11 @@ print(client.get_input_default_settings("browser_source").default_input_settings if inputs == []: client.create_input(sceneName=scene, inputName="Browser", inputKind="browser_source", inputSettings={'css': 'body { margin: 0px auto; overflow: hidden; }', 'fps': 30, 'fps_custom': True, 'height': 1080, 'is_local_file': True, 'local_file': '/home/micha/index.html', 'reroute_audio': True, 'restart_when_active': False, 'shutdown': False, 'webpage_control_level': 0, 'width': 1920}, sceneItemEnabled=True) + +client.set_stream_service_settings("rtmp_common", {'bwtest': False, 'key': 'kdm0-hum4-31wg-79se-c6us', 'protocol': 'RTMPS', 'server': 'rtmps://a.rtmps.youtube.com:443/live2', 'service': 'YouTube - RTMPS'}) + +client.start_stream() + +client.base_client.ws.close() + +print("OBS has been set up") diff --git a/obs/start.sh b/obs/start.sh index 0128d74..ba25d28 100755 --- a/obs/start.sh +++ b/obs/start.sh @@ -1,9 +1,8 @@ #!/usr/bin/bash export DISPLAY=:99 -Xvfb $DISPLAY & -obs & -sleep 1 +xvfb-run obs & +sleep 5 source /home/obs/.venv/bin/activate -python3 /home/obs/setup-obs.py - +python3 /home/obs/setup_obs.py +sleep 100