Add transcode/packaging worker, job slugs, deletes and zip downloads
Build and publish / cleanup (pull_request) Successful in 17s
Build and publish / test (pull_request) Skipped
Build and publish / build (pull_request) Skipped
Build and publish / pypi (pull_request) Skipped

Worker:
- manage.py run_worker polls the database for pending transcode jobs (ffmpeg)
  and packaging jobs (Bento4 mp4fragment + mp4hls). Jobs are claimed with a
  conditional UPDATE, a heartbeat thread marks progress, stale jobs are failed,
  and SIGTERM returns an interrupted job to the queue.
- SQLite runs in WAL mode with IMMEDIATE transactions and a busy timeout so the
  web server and worker can share the database.
- transcode.py exposes a reusable transcode() and the HW->CPU fallback works.
- Docker image includes ffmpeg and a checksum-verified Bento4 SDK.

Jobs and storage:
- TranscodeJob and PackagingJob have slugs, set explicitly on creation; outputs
  go to transcodes/<slug>/ and packages/<slug>/hls/. Migrations regenerated.
- Uploads into transcodes/ and packages/ are refused; the uploader defaults to
  the videos/raw folder.

UI:
- New packaging job button on transcode jobs.
- Delete views for packaging jobs, transcode jobs, uploaded files and content
  entries, each removing files before records and refusing while referenced.
  TranscodeJob.asset is now SET_NULL so deleting a source keeps its jobs.
- Streamed zip downloads for completed transcode jobs and packages, rooted at
  the job slug; the content page lists packages with download buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shaun Kruger
2026-12-03 16:34:44 -07:00
co-authored by Claude Opus 5.5
parent 1e7483d9c6
commit 73b549cb18
36 changed files with 2292 additions and 271 deletions
+23
View File
@@ -11,11 +11,32 @@ COPY privatestudio ./privatestudio
RUN mkdir -p privatestudio/static/bundle && npm run build
FROM debian:trixie-slim AS bento4
# Bento4 tools for HLS packaging (mp4fragment, mp4hls).
ARG BENTO4_VERSION=1-6-0-641
ARG BENTO4_SHA256=d48dc6b164941212e5614237b4d9aeff81d4d111ee8b1508892764078a0870e8
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSLo /tmp/bento4.zip "https://www.bok.net/Bento4/binaries/Bento4-SDK-${BENTO4_VERSION}.x86_64-unknown-linux.zip" \
&& echo "${BENTO4_SHA256} /tmp/bento4.zip" | sha256sum -c - \
&& unzip -q /tmp/bento4.zip -d /tmp \
&& mkdir -p /opt/bento4 \
&& cp -r "/tmp/Bento4-SDK-${BENTO4_VERSION}.x86_64-unknown-linux/bin" "/tmp/Bento4-SDK-${BENTO4_VERSION}.x86_64-unknown-linux/utils" /opt/bento4/
FROM python:3.13-slim-trixie
# Version used by setuptools_scm, since .git is not copied into the image.
ARG VERSION=0.0.0
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY --from=bento4 /opt/bento4 /opt/bento4
ENV PATH="/opt/bento4/bin:${PATH}"
RUN useradd --create-home privatestudio
EXPOSE 8000
@@ -41,6 +62,8 @@ RUN python manage.py collectstatic --noinput --clear
VOLUME ["/data"]
# Run the job worker from the same image with the same /data volume:
# docker run -v privatestudio-data:/data <image> python manage.py run_worker
# Migrating at startup keeps "docker run" simple. Use a release step instead if
# you run more than one container against the same database.
CMD set -xe; \