Pricing update: Free users

Mux input

By Per-Kristian Nordnes & Victoria Bergquist

Upload videos to Mux directly from the studio.

Mux Video Input Sanity Plugin

This is a plugin which let you use Mux video assets in your Sanity studio.

The Mux plugin for Sanity gives you a way to upload and preview videos easily.

Read our blog post about this plugin.

Not familiar with Sanity? Visit www.sanity.io

Quick start

  • Make a schema type that uses the plugin's type mux.video, for example:

    {
      title: "Video blog post",
      name: "videoBlogPost",
      type: "document",
      fields: [
        { title: "Title", name: "title", type: "string" },
        {
          title: "Video file",
          name: "video",
          type: "mux.video"
        }
      ]
    }

    Read more about schemas in Sanity here.

  • Get an API Access Token and enter it into the setup screen First time you use the plugin you will be asked to enter your Mux credentials.

    The Mux Video API uses an Access Token and Secret Key for authentication.

    If you haven't already, generate a new Access Token in the Access Token settings of your Mux account dashboard, and make sure it got permission to both read and write video and read data.

    The token is stored in the dataset as a document of the type mux.apiKey with the id secrets.mux. Having the ID be non-root ensures that only editors are able to see it.

    The Mux plugin will find it’s access tokens by fetching this document.

Playing videos in the frontend

We have made an own player which supports poster images for the videos as set with this plugin, see sanity-mux-player

You could use any player which supports HLS, just point the video source to:

https://stream.mux.com/${assetDocument.playbackId}.m3u8

Enabling Signed Urls

To enable signed urls with content uploaded to Mux, you will need to check the "Enable Signed Urls" option in the Mux Plugin configuration. Assuming that the API Access Token and Secret Key are set (as per the Quick start section).

More information for this feature of the plugin can be found on Mux's documentation

Enabling MP4 support

To enable static MP4 renditions, create or open the config file found in config/mux-input.json in your studio folder. This file is automatically created the first time the studio starts after adding the plugin.

{
  "mp4_support": "standard"
}

Currently mp4_support is the only supported MUX option and this supports a value of either standard or none (the default).

Contributing

Issues are actively monitored and PRs are welcome. When developing this plugin the easiest setup is:

  1. Fork this repo.
  2. Install the sanity cli and create a sanity project: npm install -g @sanity/cli && sanity init. Follow the prompts, starting out with the blog template is a good way to go.
  3. cd into your project directory, run npm install && npm start - your sanity studio should be running on http://localhost:3333.
  4. cd into the plugins director of your project.
  5. Fork this repo and clone your fork into the plugins directory inside your project git clone git@github.com:your-fork/sanity-plugin-mux-input.git.
  6. Open sanity.json, go to the plugins array and add mux-input.
  7. Re-start the sanity studio server with npm start.
  8. Edit schemas/post.js and add follow the plugin documentation to add a mux.video type field.
  9. Your studio should reload, and now when you edit the plugin code it should reload the studio, when you're done create a branch, put in a PR and a maintainer will review it. Thank you!

Install command

sanity install mux-input

Contributors

Categorized in

Other plugins by authors

Content Graph View
- has 6 likes

Official(made by Sanity team)

A tool for Sanity Studio to graph your content and see changes in real-time.

Go to Content Graph View

Content Calendar
- has 12 likes

Official(made by Sanity team)

Schedule and view your editorial calendar, right where you store your content. Prioritize and get organized on the fly with a visual calendar in your Studio.

Go to Content Calendar

Asset source for Unsplash
- has 11 likes

Search photos on Unsplash and insert them directly inside of your Sanity Studio.

Go to Asset source for Unsplash