diff --git a/squashkiwi-streaming/config/docker-compose.yml b/squashkiwi-streaming/config/docker-compose.yml index f6d7c38..ad10e45 100644 --- a/squashkiwi-streaming/config/docker-compose.yml +++ b/squashkiwi-streaming/config/docker-compose.yml @@ -37,23 +37,15 @@ services: timeout: 10s retries: 3 - # FFmpeg transcoder for H265 to H264 + # FFmpeg transcoder for H265 to H264 with score overlay transcoder: - image: linuxserver/ffmpeg:latest + build: ./transcoder + image: ${PROJECT_NAME}-transcoder:latest container_name: ${PROJECT_NAME}-transcoder restart: unless-stopped network_mode: host - command: > - -re - -rtsp_transport tcp - -i rtsp://localhost:8554/court - -c:v libx264 - -preset ultrafast - -tune zerolatency - -b:v 2M - -f rtsp - -rtsp_transport tcp - rtsp://localhost:8554/court_h264 + volumes: + - score-data:/tmp:rw depends_on: - mediamtx @@ -67,6 +59,7 @@ services: - mediamtx volumes: - ${RECORDINGS_FOLDER}:/recordings + - score-data:/tmp:rw environment: - SQUASHKIWI_API=${SQUASHKIWI_API} - COURT_ID=${COURT_ID} @@ -146,6 +139,7 @@ volumes: nginx-cache: prometheus-data: grafana-data: + score-data: networks: default: diff --git a/squashkiwi-streaming/config/transcoder/Dockerfile b/squashkiwi-streaming/config/transcoder/Dockerfile new file mode 100644 index 0000000..f5135b7 --- /dev/null +++ b/squashkiwi-streaming/config/transcoder/Dockerfile @@ -0,0 +1,13 @@ +FROM linuxserver/ffmpeg:latest + +# Install fonts for text overlay +RUN apk add --no-cache ttf-dejavu + +# Copy transcoder script +COPY transcoder.sh /transcoder.sh +RUN chmod +x /transcoder.sh + +# Create score file directory +RUN mkdir -p /tmp + +ENTRYPOINT ["/transcoder.sh"] \ No newline at end of file diff --git a/squashkiwi-streaming/config/transcoder/transcoder.sh b/squashkiwi-streaming/config/transcoder/transcoder.sh new file mode 100644 index 0000000..8674f45 --- /dev/null +++ b/squashkiwi-streaming/config/transcoder/transcoder.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Transcoder with live score overlay for SquashKiwi streaming + +# Create initial score file if it doesn't exist +SCORE_FILE="/tmp/score.txt" +if [ ! -f "$SCORE_FILE" ]; then + echo "Waiting for match..." > "$SCORE_FILE" +fi + +# Start ffmpeg with drawtext filter for score overlay +exec ffmpeg \ + -re \ + -rtsp_transport tcp \ + -i rtsp://localhost:8554/court \ + -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:\ +textfile='$SCORE_FILE':\ +reload=1:\ +fontcolor=white:\ +fontsize=24:\ +box=1:\ +boxcolor=black@0.7:\ +boxborderw=5:\ +x=10:\ +y=10" \ + -c:v libx264 \ + -preset ultrafast \ + -tune zerolatency \ + -b:v 2M \ + -f rtsp \ + -rtsp_transport tcp \ + rtsp://localhost:8554/court_h264 \ No newline at end of file