Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Integrate the warp client into ffmpeg (#99)
Browse files Browse the repository at this point in the history
* Add integration warp client

* i don't know

* Fix: Remove unnecessary dbus installations

* fix systemd service file

* Fix Env variables

* Add sample video

* Add some video file for testing purposes

* Dowload warp

* Install Jq and fix download errors

* Clean up the comments
  • Loading branch information
wanjohiryan authored Oct 25, 2023
1 parent 670ee46 commit c41ebe1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
46 changes: 18 additions & 28 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Usage:
#
# $ docker run --runtime=sysbox-runc -it --rm --name=syscont ghcr.io/wanjohiryan/arc3dia:base
#
# $ sudo chmod 777 ./certs
# $ docker run --runtime=sysbox-runc -it --rm --device=/dev/uinput --device=/dev/dri -v ./certs:/certs --name=arc3dia ghcr.io/wanjohiryan/arc3dia:base
#
# This will run systemd, sshd and docker;
#https://github.com/nestybox/dockerfiles/blob/master/ubuntu-jammy-systemd/Dockerfile
Expand Down Expand Up @@ -54,11 +55,11 @@ ENV LC_ALL en_US.UTF-8
ENV TZ UTC

ARG USERNAME=admin
ARG USER_UID=1000
ARG USER_UID=1000
ARG USER_GID=${USER_UID}

#
#Add dependencies
# Add dependencies
#
RUN apt-get update -y; \
apt-get upgrade -y; \
Expand All @@ -67,13 +68,10 @@ RUN apt-get update -y; \
vim \
software-properties-common \
gpg-agent \
dbus-user-session \
dbus-x11 \
libdbus-c++-1-0v5\
jq \
#
#Xvfb
xvfb \
#
#Pulseaudio
pulseaudio; \
#
Expand Down Expand Up @@ -174,45 +172,43 @@ RUN SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/
ENV LD_PRELOAD /usr/local/lib/selkies-js-interposer/joystick_interposer.so${LD_PRELOAD:+:${LD_PRELOAD}}
ENV SDL_JOYSTICK_DEVICE /dev/input/js0


#
# Make use of stopsignal (instead of sigterm) to stop systemd containers.
#
STOPSIGNAL SIGRTMIN+3

#
#Copy Warp [CLIENT] linux binary and the start script into the container
#Download the latest Warp [CLIENT] linux binary
#
RUN wget -O warp https://github.com/wanjohiryan/warp/releases/latest/download/warp-ubuntu-amd64; \
cp ./warp /usr/bin/ ;\
rm ./warp
#
#Copy the start script into the container
#
COPY temp/warp /usr/bin/
COPY docker/base/entrypoint.sh /scripts/
RUN chmod +x /scripts/entrypoint.sh /usr/bin/warp

#
#Copy the systemd.service file for starting the server
#
COPY docker/base/*.service /lib/systemd/system/

RUN ln -sf /lib/systemd/system/warp.service \
/etc/systemd/system/multi-user.target.wants/warp.service
# RUN ln -sf /lib/systemd/system/dbus.service \
# /etc/systemd/system/multi-user.target.wants/dbus-server.service

RUN ln -sf /lib/systemd/system/pulseaudio.service \
/etc/systemd/system/multi-user.target.wants/pulseaudio.service

RUN ln -sf /lib/systemd/system/xserver.service \
/etc/systemd/system/multi-user.target.wants/xserver.service
#
# For ssh, and http3 connections respectively
# Warp runs on port 4443
# For testing Warp
#

COPY temp/gameplay.mp4 /media/

#RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone

# FIXME: Remove this
#After a lot of thought, i commented out this as running the warp relay server on a local machine might not be the ideal way to do this.
#Ideally we should have the client run locally, transmit the audio and video to a remote warp relay server that will transmit the content to all available clients.

# EXPOSE 22 4443/udp 4443 80

#the volume that houses the key and cert files as `/certs/key.pem` and `/certs/cert.pem`
VOLUME [ "/certs" ]

Expand All @@ -222,12 +218,6 @@ ENV CDEPTH 24
ENV USER ${USERNAME}
ENV SHELL /bin/bash

ENV WARP_SERVER_URL "${WARP_SERVER_URL:-"https://localhost"}"
ENV WARP_SERVER_PORT "${WARP_SERVER_PORT:-4443}"

#Full server url
ENV WARP_SERVER_FULL_URL="${WARP_SERVER_URL}:${WARP_SERVER_PORT}"

#
# Run entrypoint.sh then set systemd as entrypoint.
#
Expand Down
10 changes: 10 additions & 0 deletions docker/base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

export DISPLAY="${DISPLAY:-:0}"

WARP_SERVER_HOST="${WARP_HOST:-"localhost"}"
WARP_SERVER_PORT="${WARP_PORT:-4443}"
WARP_ADDRESS="${WARP_ADDRESS:-$WARP_SERVER_HOST:$WARP_SERVER_PORT}"

# Generate a random 16 character name by default. for each container
URL_NAME="${NAME:-$(head /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 16)}"

#Full server url
export WARP_FULL_URL="${URL:-"https://$WARP_ADDRESS/$URL_NAME"}"

# Configure joystick interposer
sudo mkdir -pm755 /dev/input
sudo touch /dev/input/{js0,js1,js2,js3}
Expand Down
3 changes: 2 additions & 1 deletion docker/base/warp.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ After=pulseaudio.service
StartLimitIntervalSec=0

[Service]
ExecStart=/usr/bin/ffmpeg -hide_banner -loglevel error -s 1920x1080 -r 30 -f x11grab -i :0 -f pulse -re -i default -f mp4 -streaming 1 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset /media/arc3dia.mp4
ExecStart=/bin/bash -c "ffmpeg -hide_banner -loglevel error -s 1920x1080 -r 30 -f x11grab -i :0 -f pulse -re -i default -f mp4 -streaming 1 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | /usr/bin/warp -- ${WARP_FULL_URL}"
Restart=always
Restart=always
RestartSec=10
StandardOutput=syslog
Expand Down
Binary file added temp/gameplay.mp4
Binary file not shown.

0 comments on commit c41ebe1

Please sign in to comment.