Mux
Mux provides a streaming video analytics platform which includes a feature-rich API to deliver streaming video at scale as well as a drop-in component that you can put in your web application to play Mux assets.
You will need
- A Mux account
- An AWS account
- A running Hydrolix deployment
- An existing Project/Table in your Hydrolix cluster for Mux data.
Basic Steps
- (optional) Generate Data for Mux
- Create Kinesis Stream
- Enable Mux Export to Kinesis Stream
- Configure Kinesis Stream to Accept Mux Data Export
- Configure Hydrolix Ingest from Kinesis Stream
Step 1: (optional) Generate Data for Mux
Get an API Access Token
Authentication via the Mux Video API requires using a token key pair that consists of a Token ID and Token Secret.
You can generate an API Access Token within the Settings page of your Mux account. Go to Settings -> Access Tokens and select Generate new token
.
Within the New access token
modal, do the following:
- Select an environment (e.g.
Development
) - Set the
Mux Video
permission set toRead
andWrite
. - Give your access token an identifiable name (e.g.
Video asset token
).
Click Generate token
. You will be presented with your new Access Token ID and Secret Key.
Store the token ID and Secret Key somewhere secure. These will be needed in the next step.
POST a Video to Mux
Videos stored in Mux are called assets. To create your first video asset, you need to send a POST request to the /assets
endpoint and set the input value to the URL of a video file that's accessible online. You can do so:
- You can directly upload within the Mux UI.
- You can send a POST request directly to the /assets endpoint (see below).
- By using one of the Mux API SDKs in your preferred language.
You can use publicly accessible videos from Mux if you do not have one of your own. Using the URL of one of those sample videos and your generated token ID and secret key, you can POST a video to your Mux account using the following cURL request:
curl https://api.mux.com/video/v1/assets \
-H "Content-Type: application/json" \
-X POST \
-d '{ "input": "https://muxed.s3.amazonaws.com/leds.mp4", "playback_policy": "public", "video_quality": "basic" }' \
-u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
{
"data":
{
"video_quality":"basic",
"test":true,
"status":"preparing",
"playback_ids":[{
"policy":"public",
"id":"Swx69x01JYONM01OfnvnofDg00FK6q01dwSR3Qnc00602JTFo"
}],
"mp4_support":"none",
"max_resolution_tier":"1080p",
"master_access":"none",
"ingest_type":"on_demand_url",
"id":"ougvIls64YEBCR9SIS7vVtrc7h59oQBpdMNHRjDl009g", //<-- this is your asset ID
"encoding_tier":"baseline",
"created_at":"1728944698"
}
}
The HTTP response contains the asset ID which you will use to verify the asset's status in the next step
Confirm Ready
Status for Asset
Ready
Status for AssetMux video processing can take anywhere from a few seconds to a few minutes (or longer) depending on the size of the file and rate of data transfer over the network.
When the video is ready for playback, the asset status changes to Ready
. One way to check the asset status is to poll the asset API using the asset ID returned in the previous step.
You can also obtain the asset ID within the Mux web UI by visiting https://dashboard.mux.com/organizations/{org_id}/environments/{env_name}/video/assets
.
Once you have your asset ID, you can request the asset status with the following cURL request:
curl https://api.mux.com/video/v1/assets/{ASSET_ID} \
-H "Content-Type: application/json" \
-u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
{
"data": {
...
"status": "ready",
...
}
}
Checking asset status programmatically and at higher volume is better accomplished via webhooks. Mux can send a webhook notification as soon as the asset is ready. See the Mux webhooks guide for details.
Add Mux videos to Web Application
To generate the data you'll be storing in Hydrolix, you need to integrate your Mux asset with Mux Data. You can do this programmatically by:
- Employing Mux Player as a drop-in web application component.
- Using one of Mux's client-side SDKs.
- Using a sandbox implementation of the Mux Player with your Mux asset.
This tutorial uses the sandbox implementation.
To integrate your Mux asset with the sandbox:
- Fork the sandbox.
- Replace the existing value for
playbackId
with your asset's playback ID.
Your video should show within the Mux sandbox preview. Playing this video within the Mux sandbox will generate observability data in Mux.
Step 2: Create Kinesis Stream
To ingest Mux data into Hydrolix, you'll need to use a Kinesis Stream.
Set Up the Kinesis Stream
Navigate to the Amazon Kinesis dashboard.
Mux data originates in
us-east-1
While you can create your Kinesis stream in any AWS region, the data Mux sends originates in
us-east-1
and you can avoid additional transfer charges by choosing this region for your Kinesis stream.
Select Create data stream.
Enter a name for your Kinesis stream (e.g. mux-hdx-export-stream
).
Under Data stream capacity -> Capacity mode, select On-demand. You can come back later and change it to Provisioned if your data stream proves predictable and consistent.
Select Create data stream at the bottom of the page.
Open your new data stream's page and keep this page handy (or copy the ARN somewhere safe) as we'll be using it in the next step.
Step 3: Enable Mux Export to Kinesis Stream
Mux data can be exported as rollups or as a near real-time, continuous stream. Rollup exports can be configured from the Mux UI or Export API, while a continuous stream must be configured by contacting the Mux team. In this step, you will configure Mux export for rollup View data.
In the Mux UI:
- navigate to Settings -> Streaming Exports and select New streaming export.
- Select the Environment that contains the Mux data you want to export.
- For Export Data, select Video Views.
- For Export Format, choose JSON. Hydrolix does not support protobuf serialization on ingest data. Only JSON-formatted exports from Mux will be accepted.
- For Service, select Amazon Kinesis Data Streams.
- Enter the Kinesis Data Stream ARN configured in step 2.
Pause here. You will need the External ID in the following step. Keep this modal open and proceed to the next step.
Step 4: Configure Kinesis Stream to Accept Mux Data Export
Create an IAM Policy
For the Kinesis stream to accept incoming Mux data, an IAM policy and role need to be configured that authorizes Mux to write to the Kinesis stream.
- Navigate to the IAM Policies page.
- Select Create Policy.
- Select the JSON tab.
- Paste in the following policy, replacing the placeholder ARN with your Kinesis stream ARN from the previous step.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kinesis:ListShards",
"kinesis:PutRecord",
"kinesis:PutRecords"
],
"Resource": [
"arn:aws:kinesis:{region}:{account-id}:stream/{stream-name}"
]
}
]
}
- Select Next.
- Enter a name for your policy in the Policy Name field (such as
mux-kinesis-hdx-export-access
). - Write a Description in the corresponding field as a reminder of why the policy exists. For example:
Export policy to enable streaming Mux data into Hydrolix via AWS Kinesis.
- Select the Create policy button.
Create an IAM Role
- Navigate to IAM Roles.
- Select the Create role button.
- Under Trusted entity type, choose AWS account.
- Select Another AWS account and enter Mux’s AWS account ID: 910609115197.
- Under Options, make sure Require external ID is checked, and paste in the External ID that Mux provided to you in Step 3.
- Select Next.
- Find the name of the policy you created in the previous step (for example
mux-kinesis-hdx-export-access
) and select the checkbox next to your policy. This applies the custom policy created in the previous step to the role you are creating. - Select the Next button to proceed.
- For Role name, enter a name for your role (example: mux-data-kinesis-external-access-role).
- Write a Description in the corresponding field as a reminder of why the policy exists. For example:
Role for the Mux external AWS account that grants access to an AWS Kinesis stream to write streaming View data
. - Select the Create role button.
Finish Creating the Mux Stream Export
- Return to the tab in which you were creating a new streaming export in Mux.
- Enter the IAM Role ARN configured in step 4. It should now look similar to the following:
- Select Enable export.
Within a few minutes, you should see data in the Kinesis dashboard for your configured data stream:
Step 5: Configure Hydrolix to Read from Kinesis Stream
Follow the steps to Configure a Checkpoint Database. This will create a checkpoint database for your Hydrolix Kinesis peers using DynamoDB or GCP datastore.
Register this catch-all transform with the Hydrolix table you'll be ingesting Mux data into. You can create a new transform to restructure your data in Hydrolix in the future, but we will use the catch-all transform for now just to get your data into Hydrolix.
Alternatively, if the Mux team has configured your stream for real-time export, you can use one of Hydrolix's default transforms with your exported data. Within your Hydrolix cluster UI, select + Add new -> Table transform and input the following (Note: the values for Transform name, Select table, and Description can differ):
Select Add transform. On the next page, if when you select Publish transform you receive the following error message:
{
"validation": {
"message": {
"sample_data": "Content type should match with transform's type: json"
}
}
}
Remove the sample data and try publishing the transform again.
Follow the step to Configure the Hydrolix Kinesis Source and Scale the Kinesis Service which will ingest data from your kinesis stream into Hydrolix.
Updated 29 days ago