# Encode video for Apple devices

Optimize video with h265 and HLS for iPhone, iPad, and Apple TV

Apple devices have hardware h265 decode since iPhone 7 and Apple TV 4K. For streaming, HLS is the native protocol -- AVPlayer handles it without third-party libraries.

"FitLoop" (a fitness app like Peloton) streams workout videos to iPhones, iPads, and Apple TVs.

## h265 for direct playback

For downloaded or cached videos in a native app:

### API

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

```typescript
const task = {
  input: 'https://fitloop-app.com/uploads/hiit-30.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://fitloop-app.com/uploads/hiit-30.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://fitloop-app.com/uploads/hiit-30.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>

## HLS for adaptive streaming

For streaming over variable connections (cellular, home wifi):

### API

<CodeGroup labels={["CLI", "TypeScript", "Python", "curl"]}>
```bash
ittybit adaptive \
  -i https://fitloop-app.com/uploads/hiit-30.mov \
  --format hls
```

```typescript
const task = {
  input: 'https://fitloop-app.com/uploads/hiit-30.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://fitloop-app.com/uploads/hiit-30.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://fitloop-app.com/uploads/hiit-30.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>

## CLI

```bash
# h265 for offline/cached playback
ittybit video \
  -i hiit-30.mov \
  -o hiit-30-h265.mp4 \
  --codec h265 \
  --quality high

# HLS for streaming
ittybit adaptive \
  -i hiit-30.mov \
  -o hiit-30.m3u8
```

## When to use which

| Delivery method     | Format         | Best for                              |
| ------------------- | -------------- | ------------------------------------- |
| Download / offline  | h265 mp4       | Cached content, offline mode          |
| Stream over network | HLS            | Live or on-demand, variable bandwidth |
| Both                | h265 mp4 + HLS | Apps that support download and stream |

## Apple device h265 support

| Device              | h265 hardware decode |
| ------------------- | -------------------- |
| iPhone 7+           | Yes                  |
| iPad (2017)+        | Yes                  |
| Apple TV 4K         | Yes                  |
| Mac (Apple Silicon) | Yes                  |
| Mac (Intel, 2017+)  | Yes                  |

## Resolution guidelines for Apple devices

| Target            | Resolution | Notes                       |
| ----------------- | ---------- | --------------------------- |
| iPhone (standard) | 1080p      | Full screen on iPhone 15    |
| iPhone (Pro Max)  | 1290p      | Native for Pro Max displays |
| iPad              | 1620p      | Matches iPad 10th gen       |
| Apple TV 4K       | 2160p      | Full 4K output              |

For HLS, you do not need to set resolution -- adaptive streaming generates multiple quality variants automatically.

## Pair with web fallback

If you also serve video on the web, encode an h264 version alongside h265:

```bash
# Apple devices
ittybit video \
  -i hiit-30.mov \
  -o hiit-30-h265.mp4 \
  --codec h265 \
  --quality high

# Web browsers
ittybit video \
  -i hiit-30.mov \
  -o hiit-30-h264.mp4 \
  --codec h264 \
  --quality high
```

Serve h265 to native apps via AVPlayer. Serve h264 to browsers via `<video>` tag.