Skip to main content
Media parsers are a natural fit for disposable microVMs. This example snapshots a prepared FFmpeg toolchain, copies one input file into a networkless worker, and exports only the transcoded result.

Transcode media

1

Prepare FFmpeg

Create one script to prepare the reusable toolchain:
prepare-ffmpeg.sh
Create the workload script that each worker will run:
transcode-video.sh
Install both scripts in the guest, then run the preparation script as the entrypoint:
Capture the prepared toolchain:
Verify the snapshot before using it:
2

Start an offline worker

Copy the input into the running worker:
Make the copied input read-only:
3

Transcode the file

Run the bounded transcode as the unprivileged media user:
The worker boots before the input is copied because rootfs patches cannot be combined with --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-duration according to the longest media you accept.
  • Limit concurrent workers at the application layer so users cannot exhaust host CPU.
  • Keep --no-net unless 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.