This example shows how to extract a single video frame with ffmpeg-python behind a FastAPI endpoint on Wasmer Edge.
https://python-ffmpeg-example.wasmer.app
main.py performs three steps for each request to /process:
- Download – Streams the source video URL into a temporary file using
requests. - Extract – Runs
ffmpeg.input(..., ss=time).output(..., vframes=1, vcodec="mjpeg")to grab a JPEG at the requested timestamp (defaults to 1 s). - Respond – Reads the generated image, encodes it as base64, and injects it into a simple HTML template.
Temporary files are cleaned up after each request, and errors are surfaced as HTTPException responses.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# ensure ffmpeg CLI is installed (brew install ffmpeg, apt install ffmpeg, etc.)
uvicorn main:app --host 0.0.0.0 --port 8000Visit http://127.0.0.1:8000/ for the UI or call /process?url=...&time=2 to test.
- Bundle
main.py,requirements.txt, and any static assets. - Provide an ffmpeg binary in your Wasmer build (e.g., via
wasmer.tomlpackages). - Deploy and open
https://<your-subdomain>.wasmer.app/process?url=...to generate screenshots.