Skip to content

Commit 2008f31

Browse files
imakelaaPakhi SinhaToriLindsay
authored
[Stream] Audio downloads feat update (#24576)
* [Stream] Audio downloads feat update * Apply suggestions from review - Downloads update Co-authored-by: ToriLindsay <[email protected]> --------- Co-authored-by: Pakhi Sinha <[email protected]> Co-authored-by: ToriLindsay <[email protected]>
1 parent c20a695 commit 2008f31

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

src/content/docs/stream/viewing-videos/download-videos.mdx

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,49 @@
11
---
2-
title: Download videos
2+
title: Download video or audio
33
pcx_content_type: how-to
44
sidebar:
55
order: 6
66
---
77

8-
When you upload a video to Stream, it can be streamed using HLS/DASH. However, for certain use-cases (such as offline viewing), you may want to download the MP4. You can enable MP4 support on a per video basis by following the steps below:
8+
When you upload a video to Stream, it can be streamed using HLS/DASH. However, for certain use-cases, you may want to download the MP4 or M4A file.
9+
For cases such as offline viewing, you may want to download the MP4 file. Whereas, for downstream tasks like AI summarization, if you want to extract only the audio, downloading an M4A file may be more useful.
910

10-
1. Enable MP4 support by making a POST request to the `/downloads` endpoint (example below)
11-
2. Save the MP4 URL provided by the response to the `/downloads` endpoint. This MP4 URL will become functional when the MP4 is ready in the next step.
12-
3. Poll the `/downloads `endpoint until the `status` field is set to `ready` to inform you when the MP4 is available. You can now use the MP4 URL from step 2.
11+
## Generate downloadable MP4 files
1312

14-
## Generate downloadable files
13+
:::note
14+
The `/downloads` endpoint defaults to creating an MP4 download.
15+
:::
1516

16-
You can enable downloads for an uploaded video once it is ready to view by making an HTTP request to the `/downloads` endpoint.
17+
You can enable MP4 support on a per video basis by following the steps below:
18+
19+
1. Enable MP4 support by making a POST request to the `/downloads` or `/downloads/default` endpoint.
20+
2. Save the MP4 URL provided by the response to the endpoint. This MP4 URL will become functional when the MP4 is ready in the next step.
21+
3. Poll the `/downloads` endpoint until the `status` field is set to `ready` to inform you when the MP4 is available. You can now use the MP4 URL from step 2.
22+
23+
You can enable downloads for an uploaded video once it is ready to view by making an HTTP request to either the `/downloads` or `/downloads/default` endpoint.
1724

1825
To get notified when a video is ready to view, refer to [Using webhooks](/stream/manage-video-library/using-webhooks/#notifications).
1926

20-
The downloads API response will include all available download types for the video, the download URL for each type, and the processing status of the download file.
27+
## Generate downloadable M4A files
2128

22-
```bash title="Request"
29+
To enable M4A support on a per video basis, follow steps similar to that of generating an MP4 download, but instead send a POST request to the `/downloads/audio` endpoint.
30+
31+
## Examples
32+
33+
The downloads API response will include download type for the video, the download URL, and the processing status of the download file.
34+
35+
Separate requests would be needed to generate a downloadable MP4 and M4A file, respectively. For example:
36+
37+
```bash title="Request MP4"
2338
curl -X POST \
2439
-H "Authorization: Bearer <API_TOKEN>" \
2540
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/downloads
2641
```
2742

28-
```json title="Response"
43+
```json title="Response MP4"
2944
{
3045
"result": {
31-
"default": {
46+
"default": {
3247
"status": "inprogress",
3348
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/default.mp4",
3449
"percentComplete": 75.0
@@ -39,10 +54,33 @@ https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/do
3954
"messages": []
4055
}
4156
```
57+
And for an M4A file:
58+
59+
```json title="Request M4A"
60+
curl -X POST \
61+
-H "Authorization: Bearer <API_TOKEN>" \
62+
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/downloads/audio
63+
```
64+
65+
```json title="Response M4A"
66+
{
67+
"result": {
68+
"audio": {
69+
"status": "inprogress",
70+
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/audio.m4a",
71+
"percentComplete": 75.0
72+
}
73+
},
74+
"success": true,
75+
"errors": [],
76+
"messages": []
77+
}
78+
```
79+
4280

4381
## Get download links
4482

45-
You can view all available downloads for a video by making a `GET` HTTP request to the downloads API. The response for creating and fetching downloads are the same.
83+
You can view all available downloads for a video by making a `GET` HTTP request to the downloads API.
4684

4785
```bash title="Request"
4886
curl -X GET \
@@ -53,6 +91,11 @@ https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/do
5391
```json title="Response"
5492
{
5593
"result": {
94+
"audio": {
95+
"status": "ready",
96+
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/audio.m4a",
97+
"percentComplete": 100.0
98+
}
5699
"default": {
57100
"status": "ready",
58101
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/default.mp4",

0 commit comments

Comments
 (0)