- Introduction to Video
- Stream video files
- Start live streaming
- Make API requests
- Play your videos
- Enable static MP4 renditions
- Download for offline editing
- Embed videos for social media
- Listen for webhooks
- Secure video playback
- Create clips from your videos
- Get images from a video
- Create timeline hover previews
- Adjust audio levels
- Add watermarks to your videos
- Add subtitles to your videos
- Minimize processing time
- Upload files directly
- Autoplay your videos
- Stream an audio-only version of your video
- Synchronize video playback
- Integrate with your CMS
Download your videos
Learn how to enable download options on your video assets for use cases like offline viewing or for post production editing.
In this guide:
Any Mux video asset can be streamed or downloaded using the MPEG-4 (.mp4) video format. There are a handful of reasons why you might want to add MP4 support to a Mux video asset:
- Allowing users to download a file for watching offline
- Embedding a video in Open Graph cards for sharing on sites like Facebook and Twitter
- Supporting very old devices, like Android < v4.0 (Less than 1% of Android users)
In all other cases you'll want to use our default HLS (.m3u8) format which provides a better viewing experience by dynamically adjusting the quality level to the viewer's connection speed. The HLS version of a video will also be ready sooner than the MP4 versions, if time to ready is important.
There's no additional cost for creating and storing MP4 files (woo!). Delivery is the same price-per-minute of video as HLS delivery.
Enable MP4 support
You can add MP4 support to an asset when creating an assetAPI by including the "mp4_support": "standard"
parameter.
{ "input": "VIDEO_URL", "playback_policy": [ "public" ], "mp4_support": "standard" }
You can also add it afterward by updating the assetAPI.
Enable MP4 support when a live stream finishes
If you want to enable MP4 support from the recorded version of a live stream soon after the live stream is finished, use the mp4_support
property in the new_asset_settings
when creating the live streamAPI.
{ "playback_policy": "public", "new_asset_settings": { "playback_policy": "public", "mp4_support": "standard" } }
Retrieving the MP4 URLs
After adding MP4 support you'll see an additional key on the asset object called static_renditions
. This is the object that will contain the information about which MP4s are available.
The static_renditions.status
parameter refers to the current status of processing the MP4s. MP4s take longer to create than our default HLS version of the video, so they will not be ready immediately when the asset status is ready
. Instead they will be ready when the static_renditions.status
is ready
, and a webhook of video.asset.static_renditions.ready
is fired.
{ ...all asset details... "mp4_support": "standard", "static_renditions": { "status": "preparing" } }
When the static_renditions.status
field is ready
you will see the details of the MP4s available in an array under the files
key.
Depending on the source video uploaded, you will have one or more options for MP4 renditions. If the source video had a low resolution (e.g. 240p) there will only be a low.mp4
file available. If the source video had a high resolution (HD, 720p+) you will have three options: low.mp4
, medium.mp4
, and high.mp4
.
{ ...all asset details... "mp4_support": "standard", "static_renditions": { "status": "ready", "files": [ { "name": "low.mp4", "ext": "mp4", "height": {MP4_HEIGHT}, "width": {MP4_WIDTH}, "bitrate": {MP4_BITRATE}, "filesize": {MP4_FILESIZE} } ] } }
Webhooks
Your application can be automatically updated with the status of MP4 downloads for an asset through webhooks.
There are four related events you can receive.
Webhook | Description |
---|---|
video.asset.static_renditions.preparing | Received when MP4 support is first requested |
video.asset.static_renditions.ready | Received when the MP4 URL(s) are available and ready for use |
video.asset.static_renditions.deleted | Received if MP4 support has been set to none via a PUT to the mp4-support endpoint |
video.asset.static_renditions.errored | Received if an unexpected error happens while making the MP4 URLs available |
Download or playback a MP4
To stream the MP4 file, make a request to the stream.mux.com URL with the asset playback ID, then a slash, then the name of the MP4 you want to stream:
https://stream.mux.com/{PLAYBACK_ID}/{MP4_FILE_NAME} -- ex. https://stream.mux.com/abcd1234/low.mp4
If you want a browser to download the MP4 file rather than attempt to stream it, you can provide a file name for the MP4 to save as via the download
query parameter:
https://stream.mux.com/{PLAYBACK_ID}/{MP4_FILE_NAME}?download={FILE_NAME} -- ex. https://stream.mux.com/abcd1234/low.mp4?download=cats
Audio-Only MP4 support
If you're using audio-only assets with MP4 support, the MP4 file name is audio.m4a and you should craft the URL with this file name.
Also, there is only one MP4 rendition option for audio-only assets.
Using signed URLs
Mux videos have two types of playback policy, public
or signed
. If your playback_id
is signed
, you will need to also sign requests made for MP4 URLs.
You can check out how to do that in our signed URLs guide.
If you run into any trouble signing MP4 requests, please reach out and we'll be able to help.
When a video is ingested into Mux we store a version of the video that's equivalent in quality to the original video (currently up to 1920x1080 pixels in frame size). We call this "the master version", or just The Master™. All of the streamed versions of the video are created from the master, and the master itself is never streamed to a video player because it's not optimized to be.
There's a few common use cases where Mux may have the only copy of the original video:
- You're using Mux live streaming and the only copy is the recorded asset after the event
- You're using Mux's direct upload feature so Mux has the only copy
- You deleted the original version from your own cloud storage, because Mux is already storing a high quality version for you
When this is the case, there's a number of reasons you may want to retrieve the master version from Mux, including:
- Allowing users to download the video and edit it in a tool like Final Cut Pro
- Archiving the video for the future, for example if you're un-publishing (deleting) a video asset from Mux
- Moving your videos to another service
Enabling master access will create a temporary URL to the master version as an MP4 file. You can use this URL to download the video to your own hosting, or provide the URL to a user to download directly from Mux.
The URL will expire after 24 hours, but you can enable master access on any asset at any time, and as many times as you need.
Enable master access
If you want the master to be available soon after a video is uploaded, use the master_access
property when creating an assetAPI.
{ "input": "VIDEO_URL", "playback_policy": [ "public" ], "master_access": "temporary" }
You can also add it afterward by updating the assetAPI.
Enable master access when a live stream finishes
If you want to download the recorded version of a live stream soon after the live stream is finished, use the master_access
property in the new_asset_settings
when creating the live streamAPI.
{ "playback_policy": "public", "new_asset_settings": { "playback_policy": "public", "master_access": "temporary" } }
Retrieving the URL to the master
After master access has been requested, a new object called master
will exist on the asset details object.
{ ...all asset details... "master_access": "temporary", "master": { "status": "preparing" } }
Making the master available is an asynchronous process that happens after an Asset is ready
, or in the case of a live streamed asset, after the live_stream_completed
event. Because of this, the master
object has a status
property that gives the current state of the master, starting with preparing
.
In most cases it should only take a few seconds to make the master available. When it's ready the status
will be updated to ready
, and a new url
property will exist on the object. This is the URL you can use to download the master yourself, or to let a user download the master.
{ ...all asset details... "master_access": "temporary", "master": { "status": "ready", "url": "https://temporary.url.to.the.master.mp4" } }
Webhooks for master access
Your application can be automatically updated with the status of master access for an asset through webhooks.
There are four related events you can receive.
Webhook | Description |
---|---|
video.asset.master.preparing | Received when master access is first requested |
video.asset.master.ready | Received when the URL to the master is available |
video.asset.master.deleted | Received if master access has been set to none via a PUT to the master-access endpoint |
video.asset.master.errored | Received if an unexpected error happens while making the master available |