You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/stream/uploading-videos/direct-creator-uploads.mdx
+32-43Lines changed: 32 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,37 +2,34 @@
2
2
pcx_content_type: example
3
3
title: Direct creator uploads
4
4
sidebar:
5
-
order: 4
6
-
5
+
order: 5
7
6
---
8
7
9
-
Direct creator uploads let your end users to upload videos directly to Cloudflare Stream, without exposing your API token to clients.
8
+
Direct creator uploads let your end users upload videos directly to Cloudflare Stream without exposing your API token to clients.
10
9
11
-
**Two options:**
10
+
- If your video is a [basic upload](/stream/uploading-videos/direct-creator-uploads/#basic-uploads) under 200 MB and users do not need resumable uploads, generate a URL that accepts an HTTP post request.
12
11
13
-
1. For videos under 200MB, [generate URLs that accept an HTTP POST request](/stream/uploading-videos/direct-creator-uploads#basic-upload-flow-for-small-videos).
14
-
2. For videos over 200 MB, or if you need to allow users to resume uploads that may be interrupted by poor network connections or users closing your app while videos are still uploading, [generate URLs that use the tus protocol](/stream/uploading-videos/direct-creator-uploads#advanced-upload-flow-using-tus-for-large-videos).
12
+
- If your video is over 200 MB or if you need to allow users to [resume interrupted uploads](/stream/uploading-videos/direct-creator-uploads/#resumable-uploads), generate a URL using the tus protocol.
15
13
16
-
## Basic upload flow, for small videos
14
+
In either case, you must specify a maximum duration to reserve for the user's upload to ensure it can be accommodated within your available storage.
17
15
18
-
Use this if your users upload videos under 200MB, and you do not need to allow resumable uploads.
16
+
## Basic uploads
19
17
20
-
### Step 1: Generate a unique one-time upload URL
18
+
Use this option if your users upload videos under 200 MB, and you do not need to allow resumable uploads.
21
19
22
-
[API Reference Docs for `/direct_upload`](/api/operations/stream-videos-upload-videos-via-direct-upload-ur-ls)
20
+
1. Generate a unique, one-time upload URL using the [Direct upload API](/api/operations/stream-videos-upload-videos-via-direct-upload-ur-ls).
A successful upload will receive a `200` HTTP status code response. If the upload does not meet
61
-
the upload constraints defined at time of creation or is larger than 200 MB in
62
-
size, you will receive a `4xx` HTTP status code response.
55
+
the upload constraints defined at time of creation or is larger than 200 MB in size, you will receive a `4xx` HTTP status code response.
63
56
64
-
## Advanced upload flow using tus, for large videos
57
+
## Resumable uploads
65
58
66
-
[tus](https://tus.io/) is a protocol that supports resumable uploads. Use TUS if your users upload videos over 200MB **or** you need to allow resumable uploads. If your users upload via a mobile app or often use your app or website using a mobile network (ex: LTE, 5G), we strongly encourage you to use TUS.
59
+
1. Create your own API endpoint that returns an upload URL.
67
60
68
-
### Step 1: Create your own API endpoint that returns an upload URL
61
+
The example below shows how to build a Worker to get a URL you can use to upload your video. The one-time upload URL is returned in the `Location` header of the response, not in the response body.
69
62
70
-
```javascript title="Example API endpoint that requests a one-time tus upload URL from Cloudflare Stream, and returns it in the location header"
@@ -96,13 +89,9 @@ export async function onRequest(context) {
96
89
}
97
90
```
98
91
99
-
Note in the example above that the one-time upload URL is returned in the `Location` header of the response, not in the response body.
100
-
101
-
### Step 2: Use this API endpoint with your tus client
92
+
2. Use this API endpoint **directly** in your tus client. A common mistake is to extract the upload URL from your new API endpoint, and use this directly. See below for a complete example of how to use the API from Step 1 with the uppy tus client.
102
93
103
-
Use this API endpoint **directly** in your tus client. A common mistake is to extract the upload URL from your new API endpoint, and use this directly. See below for a complete example of how to use the API from Step 1 with the uppy tus client.
104
-
105
-
```html title="Upload a video, using your API endpoint using the uppy tus client"
94
+
```html {35} title="Upload a video using the uppy tus client"
@@ -150,11 +139,11 @@ Use this API endpoint **directly** in your tus client. A common mistake is to ex
150
139
151
140
For more details on using tus and example client code, refer to [Resumable uploads with tus](/stream/uploading-videos/upload-video-file/#resumable-uploads-with-tus-for-large-files).
152
141
153
-
###Upload-Metadata header syntax
142
+
## Upload-Metadata header syntax
154
143
155
144
You can apply the [same constraints](/api/operations/stream-videos-upload-videos-via-direct-upload-ur-ls) as Direct Creator Upload via basic upload when using tus. To do so, you must pass the `expiry` and `maxDurationSeconds` as part of the `Upload-Metadata` request header as part of the first request (made by the Worker in the example above.) The `Upload-Metadata` values are ignored from subsequent requests that do the actual file upload.
156
145
157
-
Upload-Metadata header should contain key-value pairs. The keys are text and the values should be base64. Separate the key and values by a space, *not* an equal sign. To join multiple key-value pairs, include a comma with no additional spaces.
146
+
The `Upload-Metadata` header should contain key-value pairs. The keys are text and the values should be encoded in base64. Separate the key and values by a space, *not* an equal sign. To join multiple key-value pairs, include a comma with no additional spaces.
158
147
159
148
In the example below, the `Upload-Metadata` header is instructing Stream to only accept uploads with max video duration of 10 minutes, uploaded prior to the expiry timestamp, and to make this video private:
160
149
@@ -163,18 +152,18 @@ In the example below, the `Upload-Metadata` header is instructing Stream to only
163
152
`NjAw` is the base64 encoded value for "600" (or 10 minutes).
164
153
`MjAyNC0wMi0yN1QwNzoyMDo1MFo=` is the base64 encoded value for "2024-02-27T07:20:50Z" (an RFC3339 format timestamp)
165
154
166
-
## Tracking user upload progress
155
+
## Track upload progress
167
156
168
157
After the creation of a unique one-time upload URL, you may wish to retain the unique identifier (`uid`) returned in the response to track the progress of a user's upload.
169
158
170
159
You can do that two ways:
171
160
172
-
1. You can [search for a video](/stream/manage-video-library/searching/) with the UID
173
-
to understand it's status.
161
+
-[Search for a video](/stream/manage-video-library/searching/) with the UID to check the status.
162
+
163
+
-[Create a webhook subscription](/stream/manage-video-library/using-webhooks/) to receive notifications about the video status. These notifications include the video's UID.
174
164
175
-
2. You can [create a webhook subscription](/stream/manage-video-library/using-webhooks/) to receive notifications
176
-
regarding the status of videos. These notifications include the video's UID.
165
+
## Billing considerations
177
166
178
-
### Billing considerations
167
+
Direct Creator Upload links count towards your storage limit even if your users have not yet uploaded video to this URL. If the link expires before it is used or the upload cannot be processed, the storage reservation will be released. Otherwise, once the upload is encoded, its true duration will be counted toward storage and the reservation will be released.
179
168
180
-
* One-time upload URLs count towards your storage limit, even if your users have not yet uploaded video to this URL. For example, if you generate a one-time upload URL with a `maxDurationSeconds` value of `60`, that expires 30 minutes from now (the default value of `expiry`), until the upload URL expires, this will count as one minute of video stored. This ensures that you do not inadvertently generate upload URLs that fail for your users once you've reached your storage limit. You can add storage to your subscription anytime via the Cloudflare Dashboard, and customize the `expiry` to a duration of your choosing. We recommend setting a short duration and generating this URL on-demand, at the moment when the user needs to upload a video.
169
+
For a detailed breakdown of pricing and example scenarios, refer to [Pricing](/stream/pricing/).
Copy file name to clipboardExpand all lines: src/content/docs/stream/uploading-videos/index.mdx
+40-9Lines changed: 40 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,49 @@
2
2
title: Upload videos
3
3
pcx_content_type: navigation
4
4
sidebar:
5
-
order: 3
6
-
5
+
order: 1
7
6
---
8
7
9
-
Stream provides four ways to upload videos to cover a diverse set of use cases.
8
+
Before you upload your video, review the options for uploading a video, supported formats, and recommendations.
9
+
10
+
## Upload options
11
+
12
+
| Upload method | When to use |
13
+
|---------------|-------------|
14
+
|[Stream Dashboard](https://dash.cloudflare.com/?to=/:account/stream)| Upload videos from the Stream Dashboard without writing any code.
15
+
|[Upload from a URL](/stream/uploading-videos/upload-via-link/)| Upload videos from a URL, such as an S3 bucket or content management system.
16
+
|[Upload video file](/stream/uploading-videos/upload-video-file/)| Upload videos stored on a computer.
17
+
|[Direct creator uploads](/stream/uploading-videos/direct-creator-uploads/)| Allows end users of your website or app to upload videos directly to Cloudflare Stream.
18
+
19
+
20
+
## Supported video formats
21
+
10
22
23
+
:::note
24
+
Files must be less than 30 GB, and content should be encoded and uploaded in the same frame rate it was recorded.
|[Stream Dashboard](https://dash.cloudflare.com?to=/:account/stream)| Upload videos from the Stream Dashboard, without writing any code. |
16
-
|[Copy via link](/stream/uploading-videos/upload-via-link/)| Upload videos from a URL, such as an S3 bucket or content management system. |
17
-
|[Direct creator uploads](/stream/uploading-videos/direct-creator-uploads/)| Allow end users of your website or app to upload videos directly to Cloudflare Stream. |
18
-
|[Upload video file](/stream/uploading-videos/upload-video-file/)| Upload videos when the video file is stored on a computer. |
42
+
## Recommendations for on-demand videos
19
43
44
+
- Optional but ideal settings:
45
+
- MP4 containers
46
+
- AAC audio codec
47
+
- H264 video codec
48
+
- 60 or fewer frames per second
49
+
- Closed GOP (_Only required for live streaming._)
50
+
- Mono or Stereo audio. Stream will mix audio tracks with more than two channels down to stereo.
0 commit comments