Skip to content

Mux Element Properties ​

This documentation covers all available element properties. View MUX documentation asset properties.

Complete Variable Reference ​

Query-Only Variables (for filtering assets) ​

These variables can only be used in queries to filter MuxAsset elements, not accessed as properties on individual assets.

Basic Asset Properties ​

Upload and Processing Properties ​

Playback and Rendition Properties ​

Quality and Resolution Properties ​

Custom Data Properties ​

Track Properties (Query-Only) ​

Metadata Properties (Query-Only) ​

Folder and Volume Properties ​

Standard Element Query Methods ​

  • id - Filter by element ID
  • offset - Offset results
  • limit - Limit number of results
  • orderBy - Order results

Example Usage:

twig
{# Access basic properties #}
{{ asset.assetId }}
{{ asset.duration }}
{{ asset.aspectRatio }}
{{ asset.isLive }}

{# Access track information #}
{% for track in asset.tracks %}
    {{ track.type }} - {{ track.name }}
{% endfor %}

{# Access playback id #}
{{ asset.playback_ids[0].id }}

{# Access metadata #}
{{ asset.meta.title }}
{{ asset.meta.creatorId }}

{# Check if asset is ready #}
{% if asset.assetStatus == 'ready' %}
    {# Asset is ready for playback #}
{% endif %}

{# Audio-only (tracks present, no video track) #}
{% if asset.isAudioOnly %}
    {# Skip video-only UI (thumbnails, aspect ratio, video renditions) #}
{% endif %}

Static Renditions ​

"Highest" is mutually exclusive with specific resolutions. To switch types (e.g. Highest to 1080p), first uncheck and save to delete, then select the new resolution and save again. Note static renditions will not upscale.

getStaticRenditionUrl() builds the download URL for public and signed assets (it adds the token for signed ones), so you don't need separate templates.

twig
{% set muxAsset = craft.mux.one() %}

{# First rendition #}
{% set file = muxAsset.static_renditions.files[0] ?? null %}
{% if file %}
    <a href="{{ muxAsset.getStaticRenditionUrl(file.name, muxAsset.title ~ '.' ~ file.ext) }}" download>Download Video/Audio</a>
{% endif %}

{# Every rendition #}
{% for file in muxAsset.static_renditions.files ?? [] %}
    <a href="{{ muxAsset.getStaticRenditionUrl(file.name, muxAsset.title ~ '.' ~ file.ext) }}" download>Download ({{ file.resolution ?? file.name }})</a>
{% endfor %}

The second argument is the file name the browser saves the download as. Leave it out to play the file in the browser instead.

Methods ​

hasVideoTrack() boolean ​

Returns true when tracks contains a track with type video.

twig
{% if muxAsset.hasVideoTrack() %}
    {# Video (or muxed) asset #}
{% endif %}

isAudioOnly boolean ​

Derived: tracks are present and none have type video. Also available as getIsAudioOnly(). Exposed in GraphQL as isAudioOnly.

twig
{% if muxAsset.isAudioOnly %}
    {# Audio file — no video thumbnail or aspect ratio #}
{% endif %}

getPlaybackId(policy) string|null ​

Returns the first playback ID, or null while the asset is still processing or if it errored. Pass 'public' or 'signed' to get the first playback ID with that policy, for assets that have both.

twig
{% set muxAsset = craft.mux.one() %}
{% set playbackId = muxAsset.getPlaybackId() %}
{% if playbackId %}
    {# getPlaybackToken() is null for public videos, so this works for both #}
    {% set token = muxAsset.getPlaybackToken('v') %}
    <mux-player
        playback-id="{{ playbackId }}"
        {% if token %}playback-token="{{ token }}"{% endif %}
    ></mux-player>
{% endif %}

{% set signedId = muxAsset.getPlaybackId('signed') %}
{% set publicId = muxAsset.getPlaybackId('public') %}

getPlaybackIdData(policy) array|null ​

Like getPlaybackId(), but returns the whole entry: {id: '…', policy: 'public'|'signed'}.

securePlayback boolean ​

true when the asset's first playback ID is signed.

twig
{% set muxAsset = craft.mux.one() %}
{% if muxAsset.securePlayback %}{% endif %}

Signed Playback Methods ​

These methods work for public and signed playback IDs. For a signed ID they add a token; for a public ID they return a plain URL (and tokens are null). See Signed Playback for how tokens, modifiers and lifetimes work.

All of them take these optional trailing arguments:

ArgumentDefaultDescription
expiresInsignedTokenLifetime (24 hours)Minimum token lifetime in seconds, capped at maxSignedTokenLifetime. Ignored for public IDs.
policyfirst playback ID'public' or 'signed', to choose a playback ID when the asset has both

They return null when the asset has no playback ID yet, or when the playback ID is signed and no signing key exists.

hasSigningKey() boolean ​

true when a key exists under Mux → Signed Keys, so tokens can be created.

twig
{% if muxAsset.securePlayback and not muxAsset.hasSigningKey() %}
    {# Signed video that can't be played yet #}
{% endif %}

getPlaybackToken(type, modifiers, expiresIn, policy, keyId) string|null ​

Returns a token (JWT) for <mux-player> or for building URLs yourself. Returns null for a public playback ID.

ArgumentDefaultDescription
type'v'v video (stream, captions, downloads), t thumbnail, g gif, s storyboard
modifiers{}Modifiers for that type, e.g. {time: 2, width: 1280}, plus an optional playback_restriction_id
expiresIn24 hoursSee above
policyfirst playback IDSee above
keyIdoldest signing keyA specific key from Mux → Signed Keys
twig
<mux-player
    playback-id="{{ muxAsset.getPlaybackId() }}"
    playback-token="{{ muxAsset.getPlaybackToken('v') }}"
    thumbnail-token="{{ muxAsset.getPlaybackToken('t', {time: 2}) }}"
    storyboard-token="{{ muxAsset.getPlaybackToken('s') }}"
></mux-player>

getStreamUrl(modifiers, expiresIn, policy) string|null ​

HLS URL: https://stream.mux.com/{id}.m3u8. Modifiers: max_resolution, min_resolution, rendition_order, redundant_streams, roku_trick_play, default_subtitles_lang, asset_start_time, asset_end_time, program_start_time, program_end_time.

twig
{# For a custom HLS player (hls.js, Video.js) or Safari's native <video> #}
{% set src = muxAsset.getStreamUrl({max_resolution: '720p'}) %}

getThumbnailUrl(modifiers, format, expiresIn, policy) string|null ​

Still image: https://image.mux.com/{id}/thumbnail.{format}. format is webp (default), jpg or png. Modifiers: time, width, height, fit_mode, rotate, flip_v, flip_h.

twig
<img src="{{ muxAsset.getThumbnailUrl({width: 640, height: 360, fit_mode: 'smartcrop', time: 2}, 'jpg') }}" alt="">

thumb(width, height, fit_mode, format) string|null ​

Shortcut for getThumbnailUrl(). Defaults: 300, 169, 'smartcrop', 'webp'.

twig
<img src="{{ muxAsset.thumb(640, 360) }}" alt="">

getAnimatedUrl(modifiers, format, expiresIn, policy) string|null ​

Animated preview: https://image.mux.com/{id}/animated.{format}. format is gif (default) or webp. Modifiers: start, end (max 10 seconds long), width, height (max 640), fps (max 30).

twig
<img src="{{ muxAsset.getAnimatedUrl({width: 320, start: 0, end: 4, fps: 12}) }}" alt="">

getStoryboardUrl(format, expiresIn, policy) string|null ​

Timeline storyboard: https://image.mux.com/{id}/storyboard.{format}. format is vtt (default), json, jpg, png or webp.

twig
{{ muxAsset.getStoryboardUrl() }}

getTextTrackUrl(trackId, expiresIn, policy) string|null ​

Captions/subtitles (WebVTT): https://stream.mux.com/{id}/text/{trackId}.vtt.

twig
{% for track in muxAsset.tracks|filter(t => t.type == 'text') %}
    <a href="{{ muxAsset.getTextTrackUrl(track.id) }}">{{ track.name }} captions</a>
{% endfor %}

getStaticRenditionUrl(name, download, expiresIn, policy) string|null ​

MP4/M4A file: https://stream.mux.com/{id}/{name}, e.g. highest.mp4, 1080p.mp4, audio.m4a. download is an optional file name that makes the browser download the file.

twig
<a href="{{ muxAsset.getStaticRenditionUrl('highest.mp4', 'my-video.mp4') }}">Download</a>

getSecurePlaybackJWT(keyId, mediaType, options, expiresIn) string|null ​

The original token method, kept for existing templates. Returns a token for the first playback ID when it's signed, otherwise null.

  • keyId: signing key ID. Optional from 2.8.0; defaults to the oldest key.
  • mediaType: v video, t thumbnail, g gif, s storyboard
  • options: modifiers, e.g. {time: 10, width: 640, fit_mode: 'smartcrop'}. Before 2.8.0, these were silently dropped.
  • expiresIn: minimum lifetime in seconds
twig
{% set token = muxAsset.getSecurePlaybackJWT(null, 't', {time: 10, width: 640}) %}

For new templates, getPlaybackToken() is equivalent and can also choose a playback ID by policy.

signedKeys / securePlaybackTokens Deprecated ​

Return the stored signing key records, including private keys. Don't output them in a page. Use hasSigningKey() to check whether signing is possible; the methods above pick the key for you.