commit 922d00f52f4ccc20f47af406e12d3c763d75cb8d Author: Tim Date: Sun Apr 5 21:24:05 2026 +0200 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f509e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6220ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM jrottenberg/ffmpeg:7.1.1-alpine320 + +# no glibc +RUN apk add --no-cache su-exec + +RUN mkdir -p /output + +COPY stream-archive.sh /stream-archive.sh +RUN chmod +x /stream-archive.sh + +VOLUME ["/output"] + +ENTRYPOINT ["/stream-archive.sh"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..bbc6eab --- /dev/null +++ b/compose.yaml @@ -0,0 +1,13 @@ +services: + ffmpeg-archive: + build: . + container_name: ffmpeg-archive + environment: + - INPUT=${INPUT:-rtsp://your-stream-url} + # uses strftime for naming + - OUTPUT=${OUTPUT:-/output/%Y-%m-%d_%H-%M-%S.mkv} + - PUID=${PUID:-1000} + - PGID=${PGID:-1000} + volumes: + - ${RECORDINGS_DIR:-./recordings}:/output + restart: unless-stopped \ No newline at end of file diff --git a/stream-archive.sh b/stream-archive.sh new file mode 100644 index 0000000..24f1d13 --- /dev/null +++ b/stream-archive.sh @@ -0,0 +1,32 @@ +#!/bin/sh +set -e + +PUID=${PUID:-1000} +PGID=${PGID:-1000} + +# Create group if GID doesn't exist +if ! getent group "$PGID" > /dev/null 2>&1; then + addgroup -g "$PGID" archivegroup +fi +GROUP_NAME=$(getent group "$PGID" | cut -d: -f1) + +# Create user if UID doesn't exist +if ! getent passwd "$PUID" > /dev/null 2>&1; then + adduser -D -H -u "$PUID" -G "$GROUP_NAME" archiveuser +fi + +chown "$PUID:$PGID" /output + +echo "[stream-archive] Running as UID=${PUID} GID=${PGID}" +echo "[stream-archive] INPUT = ${INPUT}" +echo "[stream-archive] OUTPUT = ${OUTPUT}" + +exec su-exec "$PUID:$PGID" ffmpeg \ + -i "${INPUT}" \ + -c copy \ + -f segment \ + -reset_timestamps 1 \ + -segment_format mkv \ + -segment_time 3600 \ + -strftime 1 \ + "${OUTPUT}"