Skip to Content
Mux Docs: Home

Enable static MP4 renditions

Enable static MP4 renditions on your video assets for offline viewing and other use cases.

Why enable MP4 support

Any Mux video asset can be streamed or downloaded using the MPEG-4 video (.mp4) format or audio (.m4a) format.

This allows users to download a file for watching offline which is useful for:

  • Supporting very old devices, like Android < v4.0 (Less than 1% of Android users)
  • Supporting assets that are very short in duration (e.g., < 10s) on certain platforms
  • Embedding a video in Open Graph cards for sharing on sites like Facebook and Twitter

It also allows users to download M4A audio files, which may be useful for:

  • Feeding into transcription services
  • Delivering a streamable audio-only file to an audio element
  • Downloading an audio-only file, useful for things like podcasts

In the majority of 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.

How to enable MP4 support

There is no additional cost for creating and storing MP4 files. Delivery for video has the same price-per-minute as HLS delivery.

You can add MP4 support to an asset when creating an assetAPI by including the "mp4_support: <option>" parameter. The supported options are:

  • capped-1080p: Produces a single MP4 file with the video resolution up to 1080p.
  • audio-only: Produces a single M4A (audio-only MP4) file for a video asset.
  • audio-only,capped-1080p: Produces both M4A and MP4 files for assets with video and audio, only the MP4 file for video-only assets, or only the M4A file for audio-only assets.
  • standard (deprecated). Depending on the source video resolution, produces up to three MP4 files with different levels of resolution. We strongly recommend using one of the previous options, depending on your use case.

The files produced by each mp4_support option depends on the source asset type:

mp4_support optionvideo assetvideo-only assetaudio-only asset
capped-1080pcapped-1080p.mp4capped-1080p.mp4audio.m4a
audio-onlyaudio.m4aerroraudio.m4a
audio-only,capped-1080paudio.m4a and capped-1080p.mp4capped-1080p.mp4audio.m4a
standardlow.mp4, medium.mp4, high.mp4low.mp4, medium.mp4, high.mp4audio.m4a

The standard option will always produce a low.mp4 file. The medium.mp4 and high.mp4 (780p or 1080p) files may be produced depending on the source video resolution.

Example of a CreateAsset request with mp4_support enabled with the capped-1080p option:

{
"input": "INPUT_URL",
"playback_policy": [
"public"
],
"encoding_tier": "smart",
"mp4_support": "capped-1080p"
}

You can also add it afterward by updating the assetAPI. If you already have an asset enabled with the standard option and want to generate new static renditions with one of the capped-1080p, audio-only or audio-only,capped-1080p options, make the following two UpdateMP4Support API requests:

  1. Update request with the mp4_support option set to none to first delete the existing static renditions
  2. Update request with the mp4_support option set to one of the capped-1080p, audio-only, or audio-only,capped-1080p options

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": "capped-1080p"
}
}

Create the MP4 streaming URL

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": "capped-1080p",
"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. The example below shows the files for the audio-only,capped-1080 option:

{
...all asset details...
"mp4_support": "capped-1080p",
"static_renditions": {
"status": "ready",
"files": [
{
"name": "audio.m4a",
"ext": "m4a",
"bitrate": {M4A_BITRATE},
"filesize": {M4A_FILESIZE}
},
{
"name": "capped-1080p.mp4",
"ext": "mp4",
"height": {MP4_HEIGHT},
"width": {MP4_WIDTH},
"bitrate": {MP4_BITRATE},
"filesize": {MP4_FILESIZE}
}
]
}
}

Creating the MP4 Streaming URL

The MP4 or M4A streaming URL is compiled using the playback ID and one of the static_renditions.

https://stream.mux.com/{PLAYBACK_ID}/{capped-1080p.mp4, audio.m4a}
--
ex. https://stream.mux.com/abcd1234/capped-1080p.mp4
ex. https://stream.mux.com/abcd1234/audio.m4a

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 it via the download query parameter:

https://stream.mux.com/{PLAYBACK_ID}/{MP4_FILE_NAME}?download={FILE_NAME}
--
ex. https://stream.mux.com/abcd1234/capped-1080p.mp4?download=cats

For the deprecated standard option, the file names will be low.mp4, medium.mp4, high.mp4.

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.

WebhookDescription
video.asset.static_renditions.preparingReceived when MP4 support is first requested
video.asset.static_renditions.readyReceived when the MP4 URL(s) are available and ready for use
video.asset.static_renditions.deletedReceived if MP4 support has been set to none via a PUT to the mp4-support endpoint
video.asset.static_renditions.erroredReceived if an unexpected error happens while making the MP4 URLs available

Audio M4A support

  • For an audio-only asset: All mp4_support options will only produce a single M4A audio.m4a file.
  • For a video asset: The audio-only or audio-only,capped-1080p mp4_support options will produce an audio.m4a file.
  • For a video-only asset: The audio-only,capped-1080p option will only produce a capped-1080p.mp4 file. MP4 generation will error for the audio-only option.

Signed URLs with MP4 video

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 to Mux Support and we'll be able to help.

Was this page helpful?