# Encode video with H.265/HEVC

Use H.265 for smaller files with broad device support

"Vault" (a video backup app like Backblaze) wants to compress archived footage. H.265 (HEVC) produces files ~30% smaller than H.264 and plays natively on Apple devices and modern Android.

## API

<CodeGroup labels={["CLI", "TypeScript", "Python", "curl"]}>
```bash
ittybit video \
  -i https://vault-app.com/archives/family-video.mov \
  --codec h265 \
  --format mp4 \
  --quality high
```

```typescript
const task = {
  input: 'https://vault-app.com/archives/family-video.mov',
  kind: 'video',
  options: {
    codec: 'h265',
    format: 'mp4',
    quality: 'high',
  },
};

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://vault-app.com/archives/family-video.mov",
    "kind": "video",
    "options": {
        "codec": "h265",
        "format": "mp4",
        "quality": "high",
    },
}

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

```bash
TASK='{
  "input": "https://vault-app.com/archives/family-video.mov",
  "kind": "video",
  "options": {
    "codec": "h265",
    "format": "mp4",
    "quality": "high"
  }
}'

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

</CodeGroup>

## CLI

```bash
ittybit video \
  -i family-video.mov \
  -o family-video-h265.mp4 \
  --codec h265 \
  --quality high
```

## When to use H.265 vs H.264

|                 | H.264        | H.265                           |
| --------------- | ------------ | ------------------------------- |
| File size       | Baseline     | ~30% smaller                    |
| Browser support | Universal    | Safari, Edge, Chrome (partial)  |
| Mobile support  | Everything   | iOS, modern Android             |
| Encode speed    | Fast         | Slower                          |
| Best for        | Web playback | Apps, Apple ecosystem, archives |

## H.265 for mobile apps

If your app plays video in a native player (not a browser), H.265 is the sweet spot -- smaller than H.264, better supported than AV1 on mobile:

```bash
ittybit video \
  -i upload.mov \
  -o mobile.mp4 \
  --codec h265 \
  --width 1080 \
  --quality high
```

## Dual encode for web + mobile

```bash
ittybit video \
  -i upload.mov \
  -o web.mp4 \
  --codec h264 \
  --quality high

ittybit video \
  -i upload.mov \
  -o mobile.mp4 \
  --codec h265 \
  --quality high
```