Skip to Content
Mux Docs: Home
Welcome to the new Mux Docs.
The old version is still available here

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 (.mp4) video 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

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": "standard" parameter.

{
  "input": "INPUT_URL",
  "playback_policy": [
    "public"
  ],
  "mp4_support": "standard"
}

You can also add it afterward by updating the assetAPI.

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"
  }
}

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": "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}
      }
    ]
  }
}

Creating the MP4 Streaming URL

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

https://stream.mux.com/{PLAYBACK_ID}/{high, medium, or low}.mp4
--
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 it 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

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-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.

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

Was this page helpful?