Ghost Stream API

Video optimization API. Upload a video, get back an optimized 360p AV1 file.

Limits: Max 100MB file size, max 60s duration, 10 requests per IP per hour.

Endpoints

POST /api/optimize

Upload a video for optimization. Returns a job ID for polling.

curl -X POST https://calm-fulfillment-production-a42a.up.railway.app/api/optimize \
  -F "video=@my_video.mp4"

Response (202):

{
  "id": "opt_abc123",
  "status": "processing",
  "original_size": 15000000,
  "poll_url": "/api/optimize/opt_abc123"
}

GET /api/optimize/:id

Check processing status. Poll until status is "complete" or "error".

curl https://calm-fulfillment-production-a42a.up.railway.app/api/optimize/opt_abc123

Response (processing):

{
  "id": "opt_abc123",
  "status": "processing",
  "progress": 45,
  "original_size": 15000000
}

Response (complete):

{
  "id": "opt_abc123",
  "status": "complete",
  "original_size": 15000000,
  "optimized_size": 1200000,
  "reduction_pct": 92,
  "download_url": "/api/optimize/opt_abc123/download",
  "metrics": {
    "compression_ratio": "12.5x",
    "output_resolution": "640x360",
    "encoder": "AV1 CRF 35"
  }
}

GET /api/optimize/:id/download

Download the optimized 360p AV1 file.

curl -O https://calm-fulfillment-production-a42a.up.railway.app/api/optimize/opt_abc123/download

Integration Example

// JavaScript — Upload and poll
async function optimizeVideo(file) {
  const formData = new FormData();
  formData.append('video', file);

  // Upload
  const upload = await fetch('/api/optimize', { method: 'POST', body: formData });
  const { id, poll_url } = await upload.json();

  // Poll until complete
  while (true) {
    await new Promise(r => setTimeout(r, 2000));
    const status = await fetch(poll_url).then(r => r.json());
    if (status.status === 'complete') return status;
    if (status.status === 'error') throw new Error(status.error);
  }
}

Note: This API performs AV1 encoding only (no neural upscaling on the server). The Ghost Stream model runs client-side in the browser via WebGPU. Use the benchmark repo for full VMAF metrics with model inference.

Other Endpoints

GET /api/health — Health check

POST /api/results — Submit benchmark results (internal)

GET / — Dashboard UI