Media Engine
AI-powered video metadata extraction API for small TV stations and content creators. Provides a "file in → JSON out" API that extracts metadata, transcripts, faces, scenes, objects, CLIP embeddings, OCR text, and camera motion from video files.
Installation
# Apple Silicon Mac
pip install media-engine[mlx]
pip install https://github.com/harperreed/mlx_clip/archive/refs/heads/main.zip
# NVIDIA GPU
pip install media-engine[cuda]
# CPU only
pip install media-engine[cpu]
# Speaker diarization (optional, run after platform install)
pip install pyannote-audio
pip install --upgrade torch torchaudio torchvision
# Start the server
meng-server
Requirements: Python 3.12+, ffmpeg
Note: Speaker diarization requires a HuggingFace token with access to the pyannote models. Set
hf_tokenin~/.config/polybos/config.json. pyannote-audio pins an older torch version, so the two-step install above prevents a torch downgrade.
Features
- Metadata extraction - Duration, resolution, codec, GPS, device info (modular per-manufacturer)
- Transcription - Whisper with speaker diarization
- Face detection - DeepFace with embedding clustering
- Scene detection - PySceneDetect content-aware boundaries
- Object detection - YOLO or Qwen VLM
- CLIP embeddings - Per-scene similarity search
- OCR - PaddleOCR text extraction
- Motion analysis - Camera pan/tilt/zoom detection
- Shot type - Aerial, interview, b-roll classification
Quick Start
Docker (Recommended)
# Clone and run
git clone https://github.com/thetrainroom/media-engine.git
cd media-engine
# Start the server
docker compose up -d
# Test
curl http://localhost:8001/health
Mount your media folder:
MEDIA_PATH=/path/to/videos docker compose up -d
For NVIDIA GPU support (uses Dockerfile.cuda):
docker compose --profile gpu up -d
Or build manually:
docker build -f Dockerfile.cuda -t media-engine-gpu .
docker run -p 8001:8001 --gpus all -v /path/to/media:/media media-engine-gpu
Apple Silicon (Recommended: Native)
Docker on macOS runs in a Linux VM without Metal/MPS access. For GPU acceleration on Apple Silicon, run natively:
pip install media-engine[mlx]
pip install https://github.com/harperreed/mlx_clip/archive/refs/heads/main.zip
meng-server
A Dockerfile.mlx is provided for consistency, but will use CPU in Docker:
docker compose --profile mlx up -d
Development Installation
# Mac Apple Silicon
make install-mlx
# NVIDIA GPU
make install-cuda
# CPU only
make install-cpu
# Speaker diarization (optional)
make install-diarization
# Run server with hot reload
uvicorn media_engine.main:app --reload --port 8001
Or without Make:
pip install -e ".[mlx]" # or cuda, cpu
pip install https://github.com/harperreed/mlx_clip/archive/refs/heads/main.zip # mlx only
pip install pyannote-audio # optional: speaker diarization
pip install --upgrade torch torchaudio torchvision # restore torch version
API Usage
Extract metadata from a video
curl -X POST http://localhost:8001/extract \
-H "Content-Type: application/json" \
-d '{
"file": "/media/video.mp4",
"enable_metadata": true,
"enable_transcript": true,
"enable_faces": false,
"enable_scenes": true,
"enable_objects": false,
"enable_clip": false,
"enable_ocr": false,
"enable_motion": false
}'
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/extract |
POST | Extract features from video |
/extractors |
GET | List available extractors |
Supported Devices
The metadata extractor automatically detects camera/device type:
| Manufacturer | Models | Features |
|---|---|---|
| DJI | Mavic, Air, Mini, Pocket, Osmo, Action | GPS from SRT, color profiles |
| Sony | PXW, FX, Alpha, ZV series | XML sidecar, S-Log, GPS |
| Canon | Cinema EOS, EOS R | XML sidecar |
| Apple | iPhone, iPad | QuickTime metadata, GPS |
| Blackmagic | Pocket, URSA, BRAW | ProApps metadata, BRAW detection |
| RED | DSMC2, V-RAPTOR, KOMODO | R3D native support |
| ARRI | ALEXA, ALEXA Mini, AMIRA | ARRIRAW detection |
| Insta360 | X3, X4, ONE RS, GO 3 | 360 video detection |
| FFmpeg | OBS, Handbrake, etc. | Encoder detection |
Adding new manufacturers is easy - create a module in media_engine/extractors/metadata/.
Architecture
media_engine/
├── main.py # FastAPI app
├── config.py # Settings and platform detection
├── schemas.py # Pydantic models
└── extractors/
├── metadata/ # Modular per-manufacturer
│ ├── dji.py
│ ├── sony.py
│ ├── apple.py
│ └── ...
├── transcribe.py # Whisper (MLX/CUDA/CPU)
├── faces.py # DeepFace + embeddings
├── scenes.py # PySceneDetect
├── objects.py # YOLO
├── objects_qwen.py # Qwen VLM
├── clip.py # CLIP embeddings
├── ocr.py # PaddleOCR
└── motion.py # Optical flow analysis
Configuration
Settings are stored in ~/.config/polybos/config.json:
{
"whisper_model": "large-v3",
"fallback_language": "en",
"hf_token": null,
"face_sample_fps": 1.0,
"object_sample_fps": 2.0,
"ocr_languages": ["en", "no", "de", "fr", "es"]
}
Set hf_token to enable speaker diarization (requires accepting license at pyannote).
Development
# Install dev dependencies
pip install -e ".[dev]"
# Lint
ruff check media_engine/
# Type check
pyright media_engine/
# Test
export TEST_VIDEO_PATH=/path/to/test.mp4
pytest tests/
Contributing
Contributions welcome! To add support for a new camera manufacturer:
- Create
media_engine/extractors/metadata/yourmanufacturer.py - Implement
detect()andextract()methods - Register with
register_extractor("name", YourExtractor()) - Import in
metadata/__init__.py
See existing modules for examples.
License
MIT
Metadata
Release files for media-engine 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| media_engine-0.3.6.tar.gz | 203.4 kB | With provenance | Details for media_engine-0.3.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| media_engine-0.3.6-py3-none-any.whl | Python 3 | none | any | Details for media_engine-0.3.6-py3-none-any.whl |
Total release size: 381.0 kB
Release files / media_engine-0.3.6.tar.gz
| Download URL | media_engine-0.3.6.tar.gz |
|---|---|
| Size | 203.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f3c9b709c4fabde7a3e950f068e0578fddb55333f360956caaa383ab5e25110
|
|
BLAKE2b-256 checksum How to use checksums |
f5c6627dfdb5ca6de3ac09cfbad031252989f20eff12efef8a2cf5d29f7058ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / media_engine-0.3.6-py3-none-any.whl
| Download URL | media_engine-0.3.6-py3-none-any.whl |
|---|---|
| Size | 177.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
001137c56f6d1c968a5325f3afea2b897768a5ddf99ae23d82a27f931c3a0430
|
|
BLAKE2b-256 checksum How to use checksums |
d5b3fdcf8e3d92172bbbba25d062535ff4d9eb33930926339ef0971bf08e5284
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for media-engine 0.3.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for media_engine-0.3.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.