view medi/README.md @ 217:7ef4c9d2a72d hg-web

[DO NOT PUSH] Random values.
author MrJuneJune <me@mrjunejune.com>
date Sun, 25 Jan 2026 10:44:04 -0800
parents
children
line wrap: on
line source

# medi

Media upload and processing server. Upload images and videos, get optimized WebP images and HLS video streams.

## Features

- **Image Upload**: Converts to WebP format with configurable quality
- **Video Upload**: Converts to HLS streaming format with thumbnails
- **Background Processing**: Non-blocking uploads with status polling
- **Web UI**: Drag-and-drop upload interface
- **REST API**: Programmatic access to upload and retrieve media

## Running

```bash
# Build and run
bazel run //medi:medi

# Run on custom port
bazel run //medi:medi -- 3000
```

Server starts at `http://localhost:8080` by default.

## API

### Upload Media

```bash
POST /api/upload
Content-Type: multipart/form-data

# Response
{
  "id": "1706123456_12345_0",
  "type": "image",
  "status": "processing"
}
```

### Get Media Info

```bash
GET /api/media/{id}

# Response (completed image)
{
  "id": "1706123456_12345_0",
  "type": "image",
  "status": "completed",
  "webp": "/media/1706123456_12345_0/image.webp",
  "original": "/media/1706123456_12345_0/original.jpg"
}

# Response (completed video)
{
  "id": "1706123456_12345_1",
  "type": "video",
  "status": "completed",
  "hls": "/media/1706123456_12345_1/video.m3u8",
  "thumbnail": "/media/1706123456_12345_1/video_thumb.jpg",
  "original": "/media/1706123456_12345_1/original.mp4"
}
```

### List All Media

```bash
GET /api/media

# Response
{
  "items": [
    {"id": "1706123456_12345_0", "type": "image"},
    {"id": "1706123456_12345_1", "type": "video"}
  ]
}
```

## Output Structure

```
uploads/          # Temporary upload storage (deleted after processing)
media/            # Processed media
├── {id}/
│   ├── original.{ext}   # Original uploaded file
│   ├── image.webp       # (images) WebP conversion
│   ├── video.m3u8       # (videos) HLS playlist
│   ├── video_000.ts     # (videos) HLS segments
│   └── video_thumb.jpg  # (videos) Thumbnail
```

## Supported Formats

### Images
JPG, JPEG, PNG, GIF, WebP, BMP, TIFF, HEIC, AVIF

### Videos
MP4, MOV, AVI, MKV, WebM, FLV, WMV, M4V, 3GP

## Dependencies

- `//seobeo:seobeo` - HTTP server
- `//media_processor:media_processor` - Media processing
- FFmpeg (system installed)

## Building

```bash
bazel build //medi:medi
```