# Create HLS streams

Generate adaptive bitrate streams for video playback

"Chalkboard" (a course platform like Teachable) hosts 2-hour lectures. Students on slow connections need adaptive bitrate streaming -- the player adjusts quality based on bandwidth.

## API

<CodeGroup labels={["CLI", "TypeScript", "Python", "curl"]}>
```bash
ittybit adaptive \
  -i https://chalkboard-app.com/courses/cs101/lecture-1.mov \
  --format hls
```

```typescript
const task = {
  input: 'https://chalkboard-app.com/courses/cs101/lecture-1.mov',
  kind: 'adaptive_video',
  options: {
    format: 'hls',
  },
};

const res = await fetch('https://api.ittybit.com/jobs', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.ITTYBIT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(task),
});
const data = await res.json();
```

```python

task = {
    "input": "https://chalkboard-app.com/courses/cs101/lecture-1.mov",
    "kind": "adaptive_video",
    "options": {
        "format": "hls",
    },
}

res = requests.post(
    "https://api.ittybit.com/jobs",
    headers={"Authorization": f"Bearer {api_key}"},
    json=task,
)
data = res.json()
```

```bash
TASK='{
  "input": "https://chalkboard-app.com/courses/cs101/lecture-1.mov",
  "kind": "adaptive_video",
  "options": {
    "format": "hls"
  }
}'

curl -X POST https://api.ittybit.com/jobs \
  -H "Authorization: Bearer $ITTYBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$TASK"
```

</CodeGroup>

This produces an HLS manifest (`.m3u8`) with multiple quality variants. The player picks the right one automatically.

## CLI

```bash
ittybit adaptive \
  -i lecture-1.mov \
  -o lecture-1.m3u8
```

## Trim before streaming

Only need the first 30 minutes of a 2-hour recording:

```bash
ittybit adaptive \
  -i lecture-1.mov \
  -o lecture-1.m3u8 \
  --start 0 \
  --end 1800
```

## When to use HLS

| Scenario                                | Format |
| --------------------------------------- | ------ |
| Long-form content (lectures, webinars)  | HLS    |
| Short clips (< 2 min)                   | MP4    |
| Downloads / offline                     | MP4    |
| Live-ish playback on varied connections | HLS    |

For short videos, a single MP4 is simpler and works everywhere. HLS pays off when content is long and viewers have varying bandwidth.