Instagram, TikTok, YouTube, Snapchat, and Mux customer VSCO make uploading, editing, and fine-tuning videos a piece of cake, which has shaped consumer expectations: they want nothing less than a smooth and sophisticated video creation experience. From travel to fitness, most community apps have a video experience — or will add one before long. Mux removes all the friction from video uploads and playback to any device — but what about the video editing experience?
Our partner Shotstack is a cloud-based video editing platform that developers and marketers use to enhance, personalize, and automate video production. Simultaneous use of Shotstack and Mux makes it easy to build complete video workflows and combine uploads and edits, fully branded, inside an app or product.
In the guide below, Jeff Shillito from Shotstack will walk you through how to set up a sample community fitness video app, but you could use the same approach for traveler videos, restaurant and small business reviews, local neighbor communities, and creator platform apps — or any other product that enables customer or community-created videos.
Stride fitness app example
This guide will use a fictitious mobile fitness app, Stride, to demonstrate the power and versatility of combining Shotstack and Mux. Stride is a typical fitness app that records a user’s sporting activity.
The app also includes a feature that allows users to record, upload, edit, and share a 20-second video filmed during or after their fitness activity. To illustrate, let’s imagine a user who just completed a short run and made a short video of themselves as they reached the end of it. Mux ingests, encodes, and stores the UGC footage from the video clip they recorded, and Shotstack generates a branded video using that footage, brand-aligned graphics, and the data generated during the run (things like distance, steps, heart rate).
For simplicity, let’s imagine a user has just completed a short run and made a short video of themselves. The video clip will be merged with data collected by the app, including distance, steps, heart rate, and a title. It will be displayed in a newly rendered video, generated by a Shotstack template.
Even better, Shotstack’s templates can be reused. To demonstrate, we will generate another video created by another user with different source videos and data but the same template.
Application workflow overview
The application comprises the following components:
Stride Mobile App - Records footage and sends it to Mux. It also sends fitness activity data and saves it to the Stride Server. The app can be used as a gallery of user-generated videos and has the capability of sharing on social networks.
Stride Server - Orchestrates the requests among the mobile app, Mux, and Shotstack and serves as a central database to store video information and fitness activity data. Users can be notified once the video processing is finished and the video is ready to view and share.
Mux - Processes, transcodes, stores, and streams the video source footage and the final output video. Once the final rendered video is ready to view, Mux can notify the Stride Server using a webhook.
Shotstack - Renders a video by combining motion graphics, source footage from Mux, and data from the Stride Server. The final video is sent back to Mux for hosting and streaming.
Designing a video edit template in Shotstack
Before a user can generate a compiled video in Shotstack, they must design and save a reusable template. The easiest way to create a video template is to use the Shotstack Studio, a browser-based video editor.
The template will include merge fields placeholders that act like variables whose data can be swapped for each video generated. The user's uploaded video URL will populate one of the merge fields, and the title and fitness activity data will populate a set of text-based placeholders.
We created a 20-second video template for this tutorial to streamline the design step. The template was designed using the video editor, but the final template is a JSON file.
A template in Shotstack is a JSON description of the video sequences, layout, and transitions. The JSON below is the template we designed and saved in Shotstack with a template ID so we can use it later. The JSON includes merge fields that will merge assets and data.
If you want to follow along, you can copy the JSON, create a new template in Shotstack Studio, and paste the code into the JSON view, which can be accessed via the JSON View toggle in the bottom left-hand corner:
When you’ve saved the template, a template ID is generated and can be used later in the workflow. You can find the template ID in the templates list page:
In this example, the template ID is 6661a3f8-62ad-4651-8f84-57066f6b287e.
Uploading footage to Mux from the app
The first step in the workflow is to record your footage and send it to Mux via the app UI. To do so, select a video from the user gallery. Once selected, you must submit the data for the video to the Stride Server and save it to a database.
Once the data is saved to the Stride Server, the server will make a request to Mux for a signed URL. The signed URL is part of the Mux direct upload technique and must be returned back to the Stride mobile app.
The direct upload process is documented in detail within the Mux documentation. It requires a request like below (using cURL):
MUX_TOKEN_ID and MUX_TOKEN_SECRET are credentials you can find in your Mux Dashboard.
It is also important to note that the request uses the parameter mp4_support, which is set to standard. This ensures the source footage is saved as a single MP4 file instead of using the default HLS (.m3u8) streaming format.
That is because Shotstack, and video editing software in general, only supports static video files like mp4. Mux calls these files static mp4 renditions.
The request above will return a payload with a URL to upload the video using a signed request.
The app then uses this URL to upload the video to Mux, making a call similar to the following (again using cURL):
Once you’ve uploaded the video and Mux has processed it, a webhook is returned with an event type of video.asset.static_renditions.ready to the Stride Server, triggering the next step in the workflow: generating the video with Shotstack.
Generating the video using Shotstack
Once the Stride Server receives the webhook from Mux, it will include a set of video source files that Shotstack can use in the video template to generate a video.
The video source files are named low.mp4, medium.mp4, and high.mp4. Each one represents a different resolution. For our edit, we will use a high-resolution video. You may need to parse the webhook response and check the width and height, but for simplicity, we will use the final source video URL, which uses the following format:
https://stream.mux.com/{PLAYBACK_ID}.high.mp4
For this guide, we uploaded a video to the following location:
https://stream.mux.com/ck2XKwDHexeVgGD600gXXrOQaTGHTtZ54fBGvfU0002O00M/high.mp4
Along with the data saved in the Stride Server database, we can now use the template ID that Shotstack created earlier (6661a3f8-62ad-4651-8f84-57066f6b287e) and merge fields to generate and render a video. In the Shotstack Studio editor, open the template and click on the code button:
You will see a code snippet window that can output code in several languages (PHP, Node, Ruby, and Python) and can use either plain JSON or a template and merge field body. The easiest way to render a template is to use a template ID.
Here is what the cURL request would look like to create a video using the video we uploaded to Mux, a sport name, title, and activity data:
Ensure that SHOTSTACK_ENV is changed to either v1 or stage, depending on which environment you are using, SHOTSTACK_API_KEY uses the correct key for the environment, and SHOTSTACK_TEMPLATE_ID is set to the template ID we created earlier.
The request above will start the render process which merges the data into the template and returns a render ID. When the final video is ready, Shotstack will send a webhook to the Stride Server with a temporary URL of the output video file.
This video file can be fetched using Mux or Shotstack’s Mux destination.
Hosting the video with Mux and notifying the user
Once the Shotstack webhook has notified the Stride Server that the rendered file is ready, it will receive a payload that looks like this:
The URL in the payload is a temporary video file that can be fetched using the Mux API like any other video file and is hosted as an HLS (.m3u8) stream.
The Mux docs explain how to POST a video, but the request you’ll send looks like this (using cURL):
Remember to use your Mux credentials and replace the input with the URL of the generated file.
Once again, you can use Mux webhooks to notify the Stride Server that the final video is available in Mux and can be displayed in the app and shared online.
Here is the final rendered video hosted on Mux:
Creating unique videos for every user
The power of Shotstack is its template-based approach to video editing. Using the Stride app, each user has their own UGC video file, title, and activity data and can easily create many videos each week. This could add up to thousands of unique videos generated every day by an app with a large user base.
To demonstrate how easy it is to generate multiple unique videos, you can modify the Shotstack request we sent earlier with a new UGC video file, title, and activity data like this:
Check out the final video below! By creating just a few parameters in the merge fields, you can create a unique video in a matter of seconds:
Building a real-world UGC app feature
This article has provided a high-level overview of the core functionality needed to build a UGC video application, feature, or campaign.
Shotstack complements Mux’s encoding and hosting services by providing video editing and motion graphics components that are not currently available in Mux. And, just like Mux, Shotstack takes an API-first approach to video, making it the ideal fit for developers who want to get started quickly without worrying about infrastructure or the complexities of video.