August 10, 2022 (10 months ago)
We think data is important. So important, in fact, that our company began with Mux Data — a way for developers to leverage better data and observability tools for video. One reason we did this is because data on the 'nets is often overwhelming, convoluted, and in formats that are just too difficult to digest and act upon.
Mux Data was built to help solve this challenge. And when you pair Mux with other powerful tools, like Google Analytics, it's even easier to synthesize and visualize data related to our products, whether it be a blog, podcast, or video. In turn, you can use this data to make better decisions by responding quickly to real-time events, iterating on marketing efforts and product features, focusing on certain funnels, and cutting costs (whether time or dollars) where return on investment (ROI) is not as promising.
However, occasionally you may crave a level of customization and granularity that even the above tools can’t provide out of the box. This level of customization requires a robust and scalable system to ingest and distribute data. One such system is Google Pub/Sub.
Pub/Sub is one of Google’s Cloud products. It allows you to manage large amounts of data — such as real-time video analytics — coming in and out of your system asynchronously between several services without them ever having to know about each other.
Let’s say you are building a live event platform that integrates Mux Video, Mux Data, a ticketing service, a messaging service, and a shipping service (swag for attendees!). Pub/Sub will act as your data handler. In this type of multipart system, each part only needs to send data to Pub/Sub and never directly to each other — even on failures.
To begin the process, navigate to the Streaming Exports from the left-hand menu. This will take you to the settings of your Mux dashboard. Click on "New streaming export".
You'll be prompted with the setting necessary to configure and enable your streaming exports integration with Pub/Sub:
This is Mux's relevant service account. Service accounts are email addresses that refer to a non-human user, such as an application or a virtual machine.
Service accounts can be thought of as both an identity and a resource.
(Note: Don't close this window yet. You'll be back to complete the last field.)
Now that we have the information we need from Mux, let’s create your Pub/Sub project in your Google Cloud dashboard.
There are several ways you can create a project.
From the console, navigate to the top menu. There is a drop-down selector to switch quickly between projects. Click it, and a modal will open. Inside the modal, click the top right “new project” button and enter details for the new project, including project name and organization.
From any page inside Google Cloud, navigate to the top search bar. Search for “resources.” You will then see a list of all resources in your Google Cloud account. Click “create project.”
From any page in your Google Cloud account, navigate to the top search bar and search for “projects.” It will send you directly to the page where you input new project details.
A project represents one real-time messaging system in Pub/Sub.
Entities that send data to your project are called publishers, and entities that receive data from Pub/Sub are called subscribers. In the future, your project can grow to support different communication models, such as one-to-many, many-to-one, and many-to-many.
At this point, you have a Pub/Sub project waiting for publishers, like Mux, to send data to it and subscribers, like your application, to receive data from it. However, in order to make that transfer of data possible, you must grant the relevant parties permission to do what you need them to do.
For this post, we’ll focus on setting up Mux as a publisher for your project.
IAM, or Identity and Access Management System, is a framework you’ll use to grant and restrict access to resources. In this case, the resource is your Pub/Sub project.
With Pub/Sub, there are several Google-specific IAM terms worth knowing before we go further:
To capture real-time view data from Mux, we must configure an IAM policy by adding Mux’s service account as a principal and granting it the role of Pub/Sub publisher.
In your Google Cloud console, search for “IAM” in the search bar. Then click the “add” button.
In the field for “new principals,” input Mux’s service account.
Publisher is one of the many different roles you can assign to principals in Pub/Sub. Publishers can only do one thing in Pub/Sub: publish topics. Depending on your specific system needs down the line, you may need to grant different roles and permissions. You can find Pub/Sub’s full list of roles and permissions here. For now, we only need to grant Mux publisher permissions.
Topics are the entry point for publishers into your Pub/Sub project.
To create a topic, search for “topics” in the search bar, then click “create topic.”
In order to complete the connection between your Pub/Sub project and Mux Data, you have to provide Mux with the topic name so that Mux knows which topic it needs to push data to.
You can find the topic name in the topics panel under the column named “Topic name.”
Back in the Mux dashboard, on the Streaming Exports page you left open, enter your Pub/Sub topic name. Click on the "Enable export" button to finish up the process.
Mux sends messages about real-time view data formatted using Protobuf (proto2) encoding.
We have a guide to help you understand this formatting in our docs.
Voila! ✨You can now capture real-time view data from Mux Data in your Google Pub/Sub project. From here, you can use the data you capture to make important decisions faster. However, if you ever need any help, Mux has partnered with Google Pub/Sub to make this integration smoother for you. Contact us if you ever need a hand. ✋🏻
Or tweet at me on Twitter @clearythuydoan if you want to chat Pub/Sub setup. 🙋🏻♀️
No credit card to start. $20 in free credits when you're ready.
Mux is proud to partner with Contentful, the API-first content platform, to help you create, manage, transcode, publish, and stream video content on any digital channel. If you are new to the Mux Cont ...
By John and Blair
Why your brand needs videos outside of social platforms With the introduction of App Tracking Transparency in iOS 14.5, online brands now have a dramatically different relationship with social platfor ...
By John and Harris
As innovators in the streaming video industry, we’d like to see a robust video strategy that gives the new administration control not only of stories, but also of the distribution.
By Eric Elia