|
| 1 | +# Media Processing HTTP API (FFmpeg API) |
| 2 | + |
| 3 | +A **HTTP API** for processing video, audio, and images using **FFmpeg**. |
| 4 | + |
| 5 | +## What it does |
| 6 | + |
| 7 | +* Convert media formats (video ↔ audio, MP4 → GIF, WAV → MP3) |
| 8 | +* Resize, trim, or transcode files |
| 9 | +* Extract audio or frames from video |
| 10 | +* Run media workflows without local file handling |
| 11 | + |
| 12 | +You provide input files and FFmpeg commands; the API returns the results via **S3**, **Base64**, or a **direct HTTP stream**. |
| 13 | + |
| 14 | +## Endpoint |
| 15 | + |
| 16 | +`POST /v1/process` |
| 17 | + |
| 18 | +## Request Structure |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "s3Config": { ... }, |
| 23 | + "input": { ... }, |
| 24 | + "commands": [ ... ], |
| 25 | + "output": { ... } |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +## Inputs |
| 30 | + |
| 31 | +A map of **filename → source** (used by FFmpeg). |
| 32 | + |
| 33 | +Supported sources: |
| 34 | + |
| 35 | +* `s3`: `s3://bucket/key` |
| 36 | +* `http`: public URL |
| 37 | +* `base64`: Base64-encoded content |
| 38 | + |
| 39 | +```json |
| 40 | +{ |
| 41 | + "input.mp4": { |
| 42 | + "http": "https://example.com/video.mp4" |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +## FFmpeg Commands |
| 48 | + |
| 49 | +An array of FFmpeg argument lists, executed sequentially. |
| 50 | + |
| 51 | +```json |
| 52 | +[ |
| 53 | + ["-i", "input.mp4", "-vn", "output.mp3"] |
| 54 | +] |
| 55 | +``` |
| 56 | + |
| 57 | +Filenames reference input files or outputs from previous commands. |
| 58 | + |
| 59 | +## Output Options |
| 60 | + |
| 61 | +### Upload to S3 |
| 62 | + |
| 63 | +```json |
| 64 | +{ "s3": "s3://my-bucket/outputs/" } |
| 65 | +``` |
| 66 | + |
| 67 | +### Return Base64 |
| 68 | + |
| 69 | +```json |
| 70 | +{ "base64": true } |
| 71 | +``` |
| 72 | + |
| 73 | +### Stream via HTTP |
| 74 | + |
| 75 | +```json |
| 76 | +{ "inlineContentType": "audio/mpeg" } |
| 77 | +``` |
| 78 | + |
| 79 | +> When streaming, the first output file is returned directly and no JSON is sent. |
| 80 | +
|
| 81 | +## JSON Response |
| 82 | + |
| 83 | +```json |
| 84 | +{ |
| 85 | + "results": { |
| 86 | + "output.mp3": { |
| 87 | + "url": "...", |
| 88 | + "base64": "..." |
| 89 | + } |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +## Example |
| 95 | + |
| 96 | +```bash |
| 97 | +curl -X POST http://localhost:8080/v1/process \ |
| 98 | + -H "Content-Type: application/json" \ |
| 99 | + -d '{ |
| 100 | + "input": { |
| 101 | + "input.mp4": { "http": "https://example.com/video.mp4" } |
| 102 | + }, |
| 103 | + "commands": [ |
| 104 | + ["-i", "input.mp4", "-vn", "output.mp3"] |
| 105 | + ], |
| 106 | + "output": { "base64": true } |
| 107 | + }' |
| 108 | +``` |
| 109 | + |
| 110 | +## Docker |
| 111 | + |
| 112 | +### Image |
| 113 | + |
| 114 | +``` |
| 115 | +ghcr.io/aureum-cloud/ffmpeg-api:latest |
| 116 | +``` |
| 117 | + |
| 118 | +### Run |
| 119 | + |
| 120 | +```bash |
| 121 | +docker run -d -p 8080:8080 ghcr.io/aureum-cloud/ffmpeg-api:latest |
| 122 | +``` |
| 123 | + |
| 124 | +API available at: |
| 125 | + |
| 126 | +``` |
| 127 | +http://localhost:8080 |
| 128 | +``` |
| 129 | + |
| 130 | +## Notes |
| 131 | + |
| 132 | +* FFmpeg is bundled |
| 133 | +* No external dependencies |
| 134 | +* Temporary files are cleaned automatically |
| 135 | +* S3 credentials are supplied per request |
| 136 | +* Go binary on scratch image |
0 commit comments