|
2 | 2 | title: How-to Get Media Assets |
3 | 3 | --- |
4 | 4 |
|
| 5 | +Media assets are media recordings that are created one of several ways: |
| 6 | + |
| 7 | +- **[Stream Recordings](/millicast/distribution/stream-recordings/):** Media captured by enabling _recording_ on a token, the entire stream from first to last frame is stored in the cloud as a single-layer "mezzanine" recording, usually stored in an MP4 container |
| 8 | +- **[Live-to-VOD clips](/millicast/distribution/stream-recordings/live-clipping/):** These assets are "clipped" out of a live streaming workflow as a servable HLS manifest that can be used for distribution and replays of the stream. These are referred to as "live clips" or "live clipping". You can also extract a single MP4 mezzanine "clip" appropriate for social sharing or archive |
| 9 | +- **[Media Uploads](/millicast/distribution/stream-recordings/how-to-upload-media-assets/):** Files that are pre-transcoded before upload for distribution and are served over Dolby's CDN |
| 10 | + |
5 | 11 | With [Stream Recordings](/millicast/distribution/stream-recordings/index.mdx) you will want to be able to retrieve and operate on any media assets that are created. You can do this manually using the [Streaming Dashboard](/millicast/streaming-dashboard/index.mdx) or automate workflows using the [Media Assets](/millicast/api/media-assets-list-media-assets.api.mdx) REST endpoints. There are also [Media Webhooks](/millicast/webhooks/media.md) available for building event-driven integrations. |
6 | 12 |
|
7 | | -## Recordings in the Dashboard |
| 13 | +_Note: At this time, **Stream Recordings** are currently visible in the dashboard, for **live-to-vod** and **media uploads**, you must use the API to retrieve your assets. Creating live-to-vod assets requires consultation with the Dolby team to enable the workflow._ |
| 14 | + |
| 15 | +## Stream Recordings in the Dashboard |
8 | 16 |
|
9 | 17 | You can find recordings by visiting the [Streaming Dashboard](/millicast/streaming-dashboard/index.mdx). |
10 | 18 |
|
11 | | -### Find Recordings by Token |
| 19 | +### Find Stream Recordings by Token |
12 | 20 |
|
13 | | -To find recordings for a specific token, open your Publish token from the **Live Broadcast** section and click the **Settings** button to open the management screen. Select the **Recordings tab** from the top of the panel. Each thumbnail is displayed with a reference to your recording. A newly created recording can take a few seconds to several minutes to render, depending on length. Once the recording has been processed, you can view it. You can click on the **More Files** button to see all the files recorded with the respective token. |
| 21 | +To find stream recordings for a specific token, open your Publish token from the **Live Broadcast** section and click the **Settings** button to open the management screen. Select the **Recordings tab** from the top of the panel. Each thumbnail is displayed with a reference to your stream recording. A newly created stream recording can take a few seconds to several minutes to render, depending on length. Once the stream recording has been processed, you can view it. You can click on the **More Files** button to see all the files recorded with the respective token. |
14 | 22 |
|
15 | 23 | import RecTokenRecordings from '../../assets/img/0f4fe76-rec-token-recordings.png'; |
16 | 24 |
|
@@ -82,7 +90,7 @@ If you delete a recording or clip it is immediate and permanent. We are unable t |
82 | 90 |
|
83 | 91 | ## Finding Media by API |
84 | 92 |
|
85 | | -The [Media Assets](/millicast/api/media-assets-list-media-assets.api.mdx) API can help you with automating workflows with recordings and clips. |
| 93 | +The [Media Assets](/millicast/api/media-assets-list-media-assets.api.mdx) API can help you with automating workflows with stream recordings, live-to-vod clips, and media uploads. |
86 | 94 |
|
87 | 95 | import GettingStartedRESTAPI from '../../callouts/_getting_started_rest_apis.md'; |
88 | 96 |
|
@@ -146,9 +154,9 @@ If you delete a recording or clip it is immediate and permanent. We are unable t |
146 | 154 |
|
147 | 155 | Using the [Media Assets](/millicast/api/media-assets-list-media-assets.api.mdx) API you can identify the cloud storage location where recordings and clips are stored. |
148 | 156 |
|
149 | | -### How-to Retrieve a Recording |
| 157 | +### How-to Retrieve a Media Asset |
150 | 158 |
|
151 | | -Recordings will typically be stored on Dolby's servers and made available for retrieval. You'll need to know the `mediaAssetId` of the item you want to download. |
| 159 | +Media Assets are typically stored on Dolby's servers and made available for retrieval. You'll need to know the `mediaAssetId` of the item you want to download. This includes all media types including stream recordings, live-to-vod clips, and media uploads. |
152 | 160 |
|
153 | 161 | #### Example GET Response |
154 | 162 |
|
@@ -201,10 +209,114 @@ This is an example of a JSON response from the [/media/asset/\{mediaAssetId\}](/ |
201 | 209 | }, |
202 | 210 | "download": { |
203 | 211 | "downloadUrl": "string", |
204 | | - "downloadExpiresOn": "2024-10-01T18:47:26.836Z" |
| 212 | + "downloadExpiresOn": "2024-10-01T18:47:26.836Z", |
| 213 | + "url": "string" |
205 | 214 | } |
206 | 215 | } |
207 | 216 | } |
208 | 217 | ``` |
209 | 218 |
|
210 | | -The `downloadUrl` gives you the storage location where a file is available to download using whichever software or libraries are most appropriate for your application needs. |
| 219 | +The `downloadUrl` gives you the storage location where a file is available to download using whichever software or libraries are most appropriate for your application needs. Generally this is a short-lived encrypted link intended for a one-time download. |
| 220 | + |
| 221 | +After your `downloadUrl` expires call the [/media/asset/\{mediaAssetId\}](/millicast/api/media-assets-read-media-asset.api.mdx) endpoint to retrieve a new one. |
| 222 | + |
| 223 | +## Managing Media Security |
| 224 | + |
| 225 | +If you want to construct download URLs without repeated API calls, or want fine-grain control over access to media assets, use the base `url` field and media distributions. These links are usually of the form `https://cdn.optiview.dolby.com/vod/...` and are intended to be served over Dolby's CDN. In order to use this you need to configure a **Media Distribution**. |
| 226 | + |
| 227 | +### Media Distributions |
| 228 | + |
| 229 | +A _media distribution_ is an object defining security settings for a subset of media assets on your account. |
| 230 | +You may have multiple media distributions with different security settings. |
| 231 | +Create and manage media distributions using the [Media Distributions](/millicast/api/media-distributions-create-media-distribution.api.mdx) API. |
| 232 | + |
| 233 | +Each media asset can be associated with one media distribution in one of the following ways: |
| 234 | + |
| 235 | +1. Specify the `mediaDistributionId` when creating a live-to-vod clip using the [Create Media Asset](/millicast/api/media-assets-create-media-asset.api.mdx) endpoint. |
| 236 | +2. Update the `mediaDistributionId` on an existing media asset using the [Update Media Asset](/millicast/api/media-assets-update-media-asset.api.mdx) endpoint. |
| 237 | +3. Set a default media distribution for your account using the [Create Media Distribution](/millicast/api/media-distributions-create-media-distribution.api.mdx) or [Update Media Distribution](/millicast/api/media-distributions-update-media-distribution.api.mdx) endpoint. Any new media assets created on your account will be associated with the default media distribution. |
| 238 | + |
| 239 | +If a media asset is not associated with a media distribution it cannot be viewed using the base `url`. There is no default media distribution created for you. This is because your assets would be unsecured if we made the distribution public and in order to create secure playback (assets protected by a JWT viewer token), you must provide a secret when creating the media distribution. |
| 240 | + |
| 241 | +### Unsecured Playback |
| 242 | + |
| 243 | +An unsecured media distribution is one with no security keys. Create an unsecured media distribution using the following curl command. |
| 244 | + |
| 245 | +```curl |
| 246 | +curl --request POST \ |
| 247 | + --url https://api.millicast.com/api/v3/media/distributions \ |
| 248 | + --header 'Authorization: Bearer abc123' \ |
| 249 | + --data ' |
| 250 | +{ |
| 251 | + "name": "myUnsecuredDistribution" |
| 252 | +} |
| 253 | +' |
| 254 | +``` |
| 255 | + |
| 256 | +To view a media asset associated with this distribution, simply use the `url` field from the [Read Media Asset](/millicast/api/media-assets-read-media-asset.api.mdx) response. You will see that the asset `url` is publicly readable by anyone with the link. |
| 257 | + |
| 258 | +### Secured Playback |
| 259 | + |
| 260 | +If you want to secure your media assets so that a signed JWT is required to view them, create a secured media distribution with your secret key. |
| 261 | + |
| 262 | +```curl |
| 263 | +curl --request POST \ |
| 264 | + --url https://api.millicast.com/api/v3/media/distributions \ |
| 265 | + --header 'Authorization: Bearer abc123' \ |
| 266 | + --data ' |
| 267 | +{ |
| 268 | + "name": "mySecuredDistribution", |
| 269 | + "security": { |
| 270 | + "keys": [ |
| 271 | + { |
| 272 | + "name": "mySecurityKey", |
| 273 | + "key": "abcdefghijklmnopqrstuvwxyz1234567890" |
| 274 | + } |
| 275 | + ] |
| 276 | + } |
| 277 | +} |
| 278 | +' |
| 279 | +``` |
| 280 | + |
| 281 | +Retrieve the `id` of your security key from the response. Keep a record of your secret key since you will not be able to retrieve it again via the OptiView APIs. |
| 282 | + |
| 283 | +Any media assets associated with a media distribution with a security key cannot be viewed without a valid JWT. |
| 284 | + |
| 285 | +Create a JWT with a payload including the `id` of your media distribution security key as `mediaKeyId`, an expiry time and optionally a mediaAssetId. Use your secret key to sign the JWT. |
| 286 | +Below is an example JWT payload. |
| 287 | + |
| 288 | +``` |
| 289 | +{ |
| 290 | + "mediaKeyId": "4d2ec682-12aa-4d20-b7d2-ffcf1825f735", |
| 291 | + "mediaAssetId": "718f44d9319044fa908a5c6e6f70e26d", |
| 292 | + "exp": 1770330326 |
| 293 | +} |
| 294 | +``` |
| 295 | + |
| 296 | +You may omit the `mediaAssetId` if you wish to create a token that is valid for all media assets associated with this media distribution. |
| 297 | + |
| 298 | +Retrieve the base download `url` from the [Read Media Asset](/millicast/api/media-assets-read-media-asset.api.mdx) response. |
| 299 | +Append the JWT as a `token` query parameter. The resulting url will look like |
| 300 | + |
| 301 | +``` |
| 302 | +https://cdn.optiview.dolby.com/vod/{organisationId}/{mediaAssetId}/{filename}.{fileExtension}?token={jwt} |
| 303 | +``` |
| 304 | + |
| 305 | +You may add a second security key to a media distribution for the purpose of key rotation. Either key can be used to sign your JWTs. |
| 306 | + |
| 307 | +## Predictable Paths |
| 308 | + |
| 309 | +Generally the url to download a media asset looks like |
| 310 | + |
| 311 | +``` |
| 312 | +https://cdn.optiview.dolby.com/vod/{organisationId}/{mediaAssetId}/{filename}.{fileExtension} |
| 313 | +``` |
| 314 | + |
| 315 | +When creating or uploading a media asset you may provide a `customPath` that will replace the `mediaAssetId` in the download path. |
| 316 | +The resulting url will look like |
| 317 | + |
| 318 | +``` |
| 319 | +https://cdn.optiview.dolby.com/vod/{organisationId}/{customPath}/{filename}.{fileExtension} |
| 320 | +``` |
| 321 | + |
| 322 | +Using custom paths enables prediction of the download url path without reading the `mediaAssetId` from the API response. This is commonly used in order to give 3rd parties predicable access to regular recordings without having them integrate with an API. In this case the `customPath` might be a date or `eventName-date`. |
0 commit comments