> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Upload a video asset

> Upload video files to Livepeer Studio for transcoding and VOD playback. Covers direct upload, URL-based import, and tus resumable upload.

> [!TIP]
>
> Asset creation returns a tus upload endpoint for resumable uploads. For files over 200 MB, use tus -- it survives connection interruptions without restarting.

***

Uploading an asset transcodes the file to adaptive bitrate HLS and makes it available for VOD playback. The API supports direct upload, URL-based import, and resumable upload via the tus protocol.

Create and Upload

## Step 1 -- Create an asset and get upload URL

```typescript theme={null}
import { Livepeer } from 'livepeer';

const client = new Livepeer({ apiKey: process.env.LIVEPEER_API_KEY });

const response = await client.asset.create({
  name: 'product-demo.mp4',
});

const asset = response.asset;
console.log('Asset ID:', asset.id);
console.log('Upload URL (tus):', response.tusEndpoint);
```

## Step 2 -- Upload the file

**Direct upload (small files \< 200 MB):**

```typescript theme={null}
const fs = require('fs');

await fetch(response.uploadUrl, {
  method: 'PUT',
  headers: { 'Content-Type': 'video/mp4' },
  body: fs.readFileSync('./product-demo.mp4'),
});
```

**Resumable upload with tus (recommended for large files):**

```bash theme={null}
npm install tus-js-client
```

```typescript theme={null}
import * as tus from 'tus-js-client';

const upload = new tus.Upload(file, {
  endpoint: response.tusEndpoint,
  uploadSize: file.size,
  onError: (error) => console.error('Upload failed:', error),
  onProgress: (bytesUploaded, bytesTotal) => {
    console.log(`${((bytesUploaded / bytesTotal) * 100).toFixed(1)}% uploaded`);
  },
  onSuccess: () => console.log('Upload complete'),
});

upload.start();
```

**URL-based import:**

```typescript theme={null}
const response = await client.asset.create({
  name: 'imported-video.mp4',
  url: 'https://your-storage.com/video.mp4',
});
```

Check Status

## Step 3 -- Wait for transcoding

Poll for status or use the `asset.ready` webhook:

```typescript theme={null}
// Poll approach
let asset;
do {
  await new Promise(r => setTimeout(r, 5000)); // wait 5 seconds
  const response = await client.asset.get(assetId);
  asset = response.asset;
} while (asset.status.phase === 'processing' || asset.status.phase === 'waiting');

if (asset.status.phase === 'ready') {
  const playbackUrl = `https://livepeercdn.studio/asset/hls/${asset.playbackId}/index.m3u8`;
  console.log('Ready:', playbackUrl);
} else {
  console.error('Failed:', asset.status.error);
}
```

Transcoding time varies by file size: a 10-minute HD file typically takes 2-3 minutes.

## Related pages

> [card] [Playback](/v2/developers/guides/video/playback.md)
>
> Embed the playback URL after transcoding is complete.

> [card] [Webhooks](/v2/developers/guides/video/webhooks.md)
>
> Subscribe to `asset.ready` and `asset.failed` to avoid polling.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.