Start dockerizing OBS

This commit is contained in:
Micha Albert 2024-08-05 14:02:41 -04:00
parent 8308b22d89
commit af43bbc916
No known key found for this signature in database
GPG key ID: 33149159A417BBCE
10 changed files with 114 additions and 2 deletions

18
docker-compose.yml Normal file
View file

@ -0,0 +1,18 @@
version: '2'
services:
web-frontend:
build:
# build from Dockerfile
context: ./tiling-frontend
dockerfile: Dockerfile
volumes:
- tiling_frontend_build:/usr/src/app/dist
obs:
build:
context: ./obs
dockerfile: Dockerfile
volumes:
- tiling_frontend_build:/home/obs/html
volumes:
tiling_frontend_build:

35
obs/Dockerfile Normal file
View file

@ -0,0 +1,35 @@
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 && \
apt update && \
apt install ffmpeg obs-studio -y
RUN apt install python3-pip python3-venv xvfb -y
RUN useradd -ms /bin/bash obs
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
COPY requirements.txt /home/obs
RUN python3 -m venv /home/obs/.venv
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
ENTRYPOINT /home/obs/start.sh

1
obs/requirements.txt Normal file
View file

@ -0,0 +1 @@
obsws-python

14
obs/setup-obs.py Normal file
View file

@ -0,0 +1,14 @@
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"])
scene = client.get_scene_list().scenes[0]['sceneName']
inputs = client.get_scene_item_list(name=scene).scene_items
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)

9
obs/start.sh Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/bash
export DISPLAY=:99
Xvfb $DISPLAY &
obs &
sleep 1
source /home/obs/.venv/bin/activate
python3 /home/obs/setup-obs.py

View file

@ -5,4 +5,5 @@ requests
python-dotenv python-dotenv
prisma prisma
fastapi-utils fastapi-utils
httpx httpx
obsws-python

View file

@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*

View file

@ -0,0 +1,16 @@
FROM docker.io/oven/bun:slim AS base
WORKDIR /usr/src/app
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --production
FROM base AS release
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
RUN bun --bun run build

Binary file not shown.

View file

@ -25,5 +25,8 @@
"hls.js": "^1.5.13", "hls.js": "^1.5.13",
"unocss": "^0.61.3", "unocss": "^0.61.3",
"vite-plugin-singlefile": "^2.0.2" "vite-plugin-singlefile": "^2.0.2"
} },
"trustedDependencies": [
"svelte-preprocess"
]
} }