Skip to content

Commit 160df2e

Browse files
author
Pakhi Sinha
committed
[Stream] Audio downloads feat update
1 parent 7c5a750 commit 160df2e

File tree

1 file changed

+53
-12
lines changed

1 file changed

+53
-12
lines changed

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

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
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 use 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: The `/downloads` endpoint defaults to creating an MP4 download.
1514
16-
You can enable downloads for an uploaded video once it is ready to view by making an HTTP request to the `/downloads` endpoint.
15+
You can enable MP4 support on a per video basis by following the steps below:
16+
17+
1. Enable MP4 support by making a POST request to the `/downloads` or `/downloads/default` endpoint
18+
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.
19+
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.
20+
21+
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.
1722

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

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.
25+
## Generate downloadable M4A files
2126

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

28-
```json title="Response"
41+
```json title="Response MP4"
2942
{
3043
"result": {
31-
"default": {
44+
"default": {
3245
"status": "inprogress",
3346
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/default.mp4",
3447
"percentComplete": 75.0
@@ -39,10 +52,33 @@ https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/do
3952
"messages": []
4053
}
4154
```
55+
And for an M4A file:
56+
57+
```json title="Request M4A"
58+
curl -X POST \
59+
-H "Authorization: Bearer <API_TOKEN>" \
60+
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/downloads/audio
61+
```
62+
63+
```json title="Response M4A"
64+
{
65+
"result": {
66+
"audio": {
67+
"status": "inprogress",
68+
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/audio.m4a",
69+
"percentComplete": 75.0
70+
}
71+
},
72+
"success": true,
73+
"errors": [],
74+
"messages": []
75+
}
76+
```
77+
4278

4379
## Get download links
4480

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.
81+
You can view all available downloads for a video by making a `GET` HTTP request to the downloads API.
4682

4783
```bash title="Request"
4884
curl -X GET \
@@ -53,6 +89,11 @@ https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/<VIDEO_UID>/do
5389
```json title="Response"
5490
{
5591
"result": {
92+
"audio": {
93+
"status": "ready",
94+
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/audio.m4a",
95+
"percentComplete": 100.0
96+
}
5697
"default": {
5798
"status": "ready",
5899
"url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/default.mp4",

0 commit comments

Comments
 (0)