Transcode media
1
Prepare FFmpeg
Create one script to prepare the reusable toolchain:Create the workload script that each worker will run:Install both scripts in the guest, then run the preparation script as the entrypoint:Capture the prepared toolchain:Verify the snapshot before using it:
prepare-ffmpeg.sh
transcode-video.sh
2
Start an offline worker
3
Transcode the file
Run the bounded transcode as the unprivileged The worker boots before the input is copied because rootfs patches cannot be combined with
media user:--from-snapshot. The root-owned input directory prevents the unprivileged media process from replacing the copied file, while /out is the only workload-owned data directory. The untrusted transcode command sets its own process, file-descriptor, and per-file limits.4
Export the result
Prepare a fresh artifact directory on the host:Stop the worker before exporting its output:Copy the result to the host:Validate the exported file:Stopping the worker before export removes any process that could race the artifact path. The fresh private directory, regular-file check, and 1 GiB host-side size check keep the exported file within the transcode command’s per-file limit.The laboratory smoke test generated a two-second H.264 video and
ffprobe verified its duration and size.5
Clean up
Remove the prepared sandbox and worker:Remove the reusable toolchain snapshot:The checked output remains in the artifact directory configured above until you remove it.
Bound the workload
- Validate the input size before creating the sandbox.
- Set
--max-durationaccording to the longest media you accept. - Limit concurrent workers at the application layer so users cannot exhaust host CPU.
- Keep
--no-netunless the worker must retrieve remote media; copy or stream validated input through a controlled host service instead. - Export only checked regular files from a stopped worker rather than the worker’s entire filesystem.