# Optimize video for mobile apps

Produce compact, fast-loading video for iOS and Android playback

"Pocket" (a short-form video app like TikTok) needs video optimized for mobile -- small files, fast starts, appropriate resolution for phone screens.

## API

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

```typescript
const task = {
  input: 'https://pocket-app.com/uploads/video.mov',
  kind: 'video',
  options: {
    width: 1080,
    codec: 'h265',
    quality: 'medium',
    format: 'mp4',
  },
};

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://pocket-app.com/uploads/video.mov",
    "kind": "video",
    "options": {
        "width": 1080,
        "codec": "h265",
        "quality": "medium",
        "format": "mp4",
    },
}

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

```bash
TASK='{
  "input": "https://pocket-app.com/uploads/video.mov",
  "kind": "video",
  "options": {
    "width": 1080,
    "codec": "h265",
    "quality": "medium",
    "format": "mp4"
  }
}'

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

</CodeGroup>

H.265 is natively supported on iOS and modern Android. 1080px wide is full resolution on most phone screens.

## CLI

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

## Resolution guide for mobile

| Device class    | Width | Notes                            |
| --------------- | ----- | -------------------------------- |
| Budget phones   | 720   | Saves bandwidth, still sharp     |
| Standard phones | 1080  | Most common phone resolution     |
| Tablets         | 1280  | Good balance of quality and size |

## Mobile feed optimization

For infinite-scroll feeds, optimize for fast loading:

```bash
ittybit video \
  -i video.mov \
  -o feed.mp4 \
  --width 720 \
  --quality low \
  --fps 30
```

Lower quality + lower resolution = fast loads on cellular connections.

## Thumbnail for the feed

```bash
ittybit image \
  -i video.mov \
  -o thumb.webp \
  --start 1 \
  --width 720
```

Load thumbnails first, then stream video when the user scrolls to it.