mux-video

$npx mdskill add joelhooks/joelclaw/mux-video

Upload, manage, and embed videos via Mux's API and CLI for video hosting tasks.

  • Handles video uploads, asset creation, encoding status checks, playback embedding, and webhook events.
  • Integrates with Mux API, CLI, and webhook infrastructure using stored credentials.
  • Triggers on specific phrases like 'upload video to mux' or tasks involving Mux video hosting.
  • Executes operations via API calls and presents results through agent outputs or integrations.

SKILL.md

.github/skills/mux-videoView on GitHub ↗
---
name: mux-video
displayName: Mux Video
description: "Upload, manage, and embed videos via Mux. Covers direct uploads, API asset management, webhook event flow, playback embedding, and the Mux CLI. Use when uploading video, creating assets, checking encoding status, embedding playback, or handling Mux webhook events."
version: 0.1.0
author: joel
tags:
  - video
  - mux
  - media
  - webhooks
---

# Mux Video

Upload, manage, and embed videos through Mux's API and CLI. Integrates with joelclaw's webhook infrastructure and Inngest event pipeline.

## When to Use

Triggers on: "upload video to mux", "create mux asset", "embed mux video", "check video status", "mux playback", "direct upload", "video encoding", "mux webhook", or any task involving video hosting via Mux.

## Credentials

Stored in agent-secrets:
- `mux_token_id` — API token ID
- `mux_token_secret` — API token secret
- `mux_signing_key_id` — URL signing key ID
- `mux_signing_secret` — webhook signing secret (per-endpoint, HMAC)

Lease credentials:
```bash
secrets lease mux_token_id
secrets lease mux_token_secret
```

Or use env vars `MUX_TOKEN_ID` and `MUX_TOKEN_SECRET`.

## Core Operations

### Create Asset from URL

Ingest a video from a public URL:
```bash
curl https://api.mux.com/video/v1/assets \
  -X POST \
  -H "Content-Type: application/json" \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET} \
  -d '{
    "input": [{"url": "https://example.com/video.mp4"}],
    "playback_policy": ["public"],
    "video_quality": "plus"
  }'
```

Video quality tiers: `basic` (fastest/cheapest), `plus` (default, good quality), `premium` (highest).

### Direct Upload (browser/client-side)

Two-step process:

**Step 1: Create authenticated upload URL (server-side)**
```bash
curl https://api.mux.com/video/v1/uploads \
  -X POST \
  -H "Content-Type: application/json" \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET} \
  -d '{
    "new_asset_settings": {
      "playback_policies": ["public"],
      "video_quality": "plus"
    },
    "cors_origin": "*"
  }'
```

Response includes `data.url` (resumable upload endpoint) and `data.id` (upload ID).

**Step 2: PUT the file to the URL (client-side)**
```bash
curl -X PUT "${UPLOAD_URL}" \
  -H "Content-Type: video/mp4" \
  --data-binary @video.mp4
```

The URL is resumable — large files can be uploaded in chunks. Use [UpChunk](https://github.com/muxinc/upchunk) for browser uploads.

### List Assets
```bash
curl https://api.mux.com/video/v1/assets \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
```

### Get Asset Details
```bash
curl https://api.mux.com/video/v1/assets/${ASSET_ID} \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
```

### Delete Asset
```bash
curl -X DELETE https://api.mux.com/video/v1/assets/${ASSET_ID} \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
```

### Auto-Generated Captions
```bash
curl https://api.mux.com/video/v1/assets \
  -X POST \
  -H "Content-Type: application/json" \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET} \
  -d '{
    "input": [{"url": "https://example.com/video.mp4"}],
    "playback_policy": ["public"],
    "auto_generated_captions": [{"language": "en"}]
  }'
```

## Playback

### Embed URL
Once an asset is ready and has a playback ID:
```
https://stream.mux.com/${PLAYBACK_ID}.m3u8
```

### Thumbnail/Poster
```
https://image.mux.com/${PLAYBACK_ID}/thumbnail.jpg
https://image.mux.com/${PLAYBACK_ID}/thumbnail.jpg?time=10
https://image.mux.com/${PLAYBACK_ID}/animated.gif?start=5&end=10
```

### Mux Player (Web Component)
```html
<mux-player
  playback-id="${PLAYBACK_ID}"
  metadata-video-title="My Video"
  accent-color="#FF0000"
></mux-player>
```

Install: `npm install @mux/mux-player-react` for React, or use the web component directly.

### React Component
```tsx
import MuxPlayer from "@mux/mux-player-react";

<MuxPlayer
  playbackId={playbackId}
  metadata={{ video_title: "My Video" }}
  accentColor="#FF0000"
/>
```

## Webhook Events

Mux webhooks are registered at: `https://panda.tail7af24.ts.net/webhooks/mux`

The webhook provider (`packages/system-bus/src/webhooks/providers/mux.ts`) handles HMAC-SHA256 verification and normalizes events into the Inngest pipeline.

### Key Events

| Mux Event | Inngest Event | When |
|-----------|---------------|------|
| `video.asset.created` | `mux/asset.created` | Asset record created |
| `video.asset.ready` | `mux/asset.ready` | Encoding complete, playable |
| `video.asset.errored` | `mux/asset.errored` | Encoding failed |
| `video.upload.created` | `mux/upload.created` | Direct upload URL created |
| `video.upload.asset_created` | `mux/upload.asset_created` | Upload completed, asset created |
| `video.upload.cancelled` | `mux/upload.cancelled` | Upload cancelled or timed out |
| `video.asset.live_stream_completed` | `mux/asset.live_stream_completed` | Live stream recording ready |

### Event Payload Structure
```json
{
  "type": "video.asset.ready",
  "data": {
    "id": "asset_id",
    "playback_ids": [{"id": "playback_id", "policy": "public"}],
    "status": "ready",
    "duration": 120.5,
    "passthrough": "your_custom_id",
    "tracks": [...]
  }
}
```

The `passthrough` field carries your custom identifier through the entire pipeline — use it to correlate uploads with your application records.

### Building Inngest Functions for Mux Events

```typescript
// Example: Notify when video is ready
const onVideoReady = inngest.createFunction(
  { id: "mux-video-ready", name: "Mux Video Ready" },
  { event: "mux/asset.ready" },
  async ({ event, step }) => {
    const { data } = event;
    const playbackId = data.playback_ids?.[0]?.id;
    const duration = data.duration;

    // Your logic here — update DB, notify user, etc.
    await step.run("notify", async () => {
      // ...
    });
  }
);
```

## passthrough Pattern

Always set `passthrough` when creating assets or uploads. This is your correlation ID that flows through all webhook events:

```bash
curl https://api.mux.com/video/v1/assets \
  -X POST \
  -H "Content-Type: application/json" \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET} \
  -d '{
    "input": [{"url": "https://example.com/video.mp4"}],
    "playback_policy": ["public"],
    "passthrough": "my-unique-correlation-id"
  }'
```

## Rules

- **Always use `passthrough`** for tracking — it's your only way to correlate webhooks back to your records.
- **Don't poll for status** in production — use webhooks. Mux has rate limits.
- **Webhook signing secret is per-endpoint** — it's the secret you get when registering the webhook URL in the Mux dashboard, NOT the API token secret or signing key.
- **Video quality tiers affect cost** — `basic` for drafts/previews, `plus` for production, `premium` only when needed.
- **Direct upload URLs expire** — default 1 hour timeout. Create them on-demand, not ahead of time.
- **Playback IDs are stable** — once an asset is ready, the playback ID doesn't change. Safe to cache/store.

More from joelhooks/joelclaw

SkillDescription
add-skillCreate new joelclaw skills with the idiomatic process — repo-canonical, symlinked, git-tracked, slogged. Triggers on 'add a skill', 'create skill', 'new skill', 'canonical skill', 'make a skill for', or any request to formalize a process or domain into a reusable skill.
adr-skillCreate and maintain Architecture Decision Records (ADRs) optimized for agentic coding workflows. Use when you need to propose, write, update, accept/reject, deprecate, or supersede an ADR; bootstrap an adr folder and index; consult existing ADRs before implementing changes; or enforce ADR conventions. This skill uses Socratic questioning to capture intent before drafting, and validates output against an agent-readiness checklist.
agent-discovery"Optimize websites, docs, and product surfaces for agent discoverability and operator UX. Use when working on agent SEO/AEO/GEO, crawl policy, markdown or JSON projections, llms.txt, sitemap.md, AGENTS.md guidance, content negotiation, accessibility for browser agents, or any request to make a site easier for pi, OpenCode, Claude Code, ChatGPT, Perplexity, or other agent harnesses to find and use."
agent-loopStart, monitor, and cancel durable multi-agent coding loops via Inngest. Use when the user wants to run autonomous coding workloads, execute a PRD with multiple stories, kick off an AFK coding session, have agents implement features from a plan, or manage running loops. Triggers on "start a coding loop", "run this PRD", "implement these stories", "go AFK and code this", "check loop status", "cancel the loop", "joelclaw loop", or any request for autonomous multi-story code execution.
agent-mail>-
agent-workloads"Compatibility alias for the canonical `workflow-rig` front door. Use when older prompts mention `agent-workloads` or when you need the legacy workload-planning guidance; for new work, load `workflow-rig` first."
clawmail>-
cli-design"Design and build agent-first CLIs with HATEOAS JSON responses, context-protecting output, and self-documenting command trees. Use when creating new CLI tools, adding commands to existing CLIs (joelclaw, slog), or reviewing CLI design for agent-friendliness. Triggers on 'build a CLI', 'add a command', 'CLI design', 'agent-friendly output', or any task involving command-line tool creation."
codex-prompting"Use this skill for any request to trigger, coordinate, or craft prompts for Codex. Use when user says 'send to codex', 'use codex', 'prompt codex', 'ask codex', 'delegate to codex', 'run in codex', or asks for a Codex-first execution handoff."
content-publish"Publish content to joelclaw.com via the Convex-first pipeline. Covers the full lifecycle: draft → review → publish → revalidate → verify. Handles secret leasing, tag conventions, content types (article, tutorial, note, essay), and verification gates. Use when: 'write article about X', 'publish article <slug>', 'draft a tutorial', 'publish this', 'push to convex', or any content publishing task."