We’ve seen how to setup OBS for live streaming, and how to send it to YouTube. This article is about how can set up your own live streaming using Microsoft Azure Media Services.
You will need:
- A Microsoft Azure account. A free trial is available.
- OBS installed and running. You can use a single machine that is running OBS to work through this example, or you can use a web browser from any other machine to setup streaming in Azure.
What we will do
We’ll create what is in the diagram. Everything in Azure lives inside your Azure account, and this is tied to an Azure subscription. Within your Azure account, you can have many different infrastructure and platform services. Resource Groups are a way to group these together. We’ll create a resource group that groups all of the things we create for our live stream. When you use Azure Media Services to live stream, you can also create a DVR or VOD asset. This needs to be stored somewhere, so we will create an Azure Storage account for this. The streaming itself happens within Azure Media Services, so we will create an Azure Media Service instance. The Azure Media Service Instance automatically creates an endpoint. This is the streaming input URL and you tell OBS to stream to this location. We will then create a channel, which is the entity that contains live events. Then we can create the live event itself and create a locator for it, which is the output. We then need to get that output out of Azure and we use a streaming endpoint to do so. The streaming endpoint can use a content delivery network (CDN) to deliver your stream more efficiently.
1. Login to the Azure Portal
Open a web browser and go to http://portal.azure.com and login with your Azure account. If you don’t have one, this is your opportunity to create one. You will see a screen like this.
2. Create Azure Media Service
The portal is pretty user-friendly and will prompt you to create whatever it needs as you go through it. We could go through and create the resource group and storage account on our own, but instead we’ll do so via the Azure Media Service creation workflow. In the search box, type “media” and you will see “Media services” highlighted under Services.
Now click the blue “Create media service” button.
This starts the media service creation workflow. Required fields are prefixed with a red asterisk. You will typically see a green checkmark to the right of the field if you have entered valid data. If you see a red cross, then either the data you’ve chosen is not unique or it contains a character that is not supported.
You need to specify an Account Name for the media service (this is not the same as the Azure account; it is not case-sensitive and cannot include special characters).
The Subscription field should already be filled out. If you have multiple subscriptions associated with your Azure account, choose the appropriate one.
Under Resource Group, select the “Create New” radio button, and enter a name for your resource group.
The Location will default to a value, in my case “West US”.
Finally, you will see the “Storage Account” field. Click the right arrow, which will allow you to choose a storage account. Since you probably don’t have one, you will choose “Create new”, and type the name of your storage account in the Name field.
When you press OK, you will be taken back to the Media service creation screen, and you can now press Create.
You will then see a popup message informing you that deployment is in progress.
If you click the bell icon on the near the top of the browser window, you can open up the notifications to check on the progress of deployments. In this case, you will see that the deployment succeeded.
Press the “Go to resource” button to continue to the Media Services console. This provides information about what is going on with the media service that you just created, and lets you perform a variety of operations.
3. Create the Channel
Under Media Services in the right column, click “Live streaming”. This enables you to create a channel.
Click “Custom create” because we want to do live encoding and packaging and not just passthrough. This launches the channel creation workflow.
Click on the right arrow of “Settings” to configure the basic settings. You need to change the “Encoding type” to “Live Encoding” and specify a Name for your channel. Then press OK.
Now you will be shown the channel ingest settings. There’s nothing to change here because you have an RTMP output from OBS, so you can just press OK to continue.
There is nothing to change on the Preview page, so just press OK to continue.
The Encoding page is the final one and you should leave the Encoding preset to the “Default 720p” value. Press OK to continue.
You will see green check marks next to all four steps, and you can now press the Create button to create your channel.
Once again, you’ll see a notification message about the channel being created. You’ll then see your channel and a field containing the ingest URL. Things will continue to happen behind the scenes as the channel is provisioned and started, and you’ll see the status change from Stopped to Started.
4. Create the Live Event
We’ve created the media service and the channel. Now we need to create the live event. Click the channel that you just created listed under “Channel Name” to bring up the channel page.
Since we just want to start live streaming immediately, click the “Go Live” button towards the top of the screen — it has a little globe icon next to it. This kicks off the live event creation workflow and we’ll see corresponding notifications. You will also see the live event (called “default”) listed at the bottom of the screen, and eventually its status will change to “Running”.
5. Create Streaming Endpoint
Now you have a live event running in the channel that you created within the Azure Media Service. You can get video in, but you can’t get video out until you create one or more locators. Click on the live event under “Live events” that you just created to show more information about it.
Sometimes, this page does not open and you need to refresh the browser window and navigate back to the live event screen. When the live event information loads, it should look like this.
You will notice that while the live event is running, there is a red exclamation point next to the “Locator Type” called Streaming. Click it to configure the streaming endpoint.
The message in the shaded box says that a streaming endpoint must be running. This is how video is going to leave Azure and get to your viewers. Click on this shaded box.
A streaming endpoint is created for you with some default settings. One of these is to use a CDN for delivery. You can disable this if you want by clicking the “Disable CDN” button near the top, but we’ll leave it enabled for now.
Start the streaming endpoint by click the Start button near the top. Because CDN usage is selected by default, you will get a notification about CDN provisioning and propagation. Click Yes to continue.
6. Start Input Stream
While the streaming endpoint is being started, now is a good time to go into OBS and setup the input stream.
Scroll to the far left in your browser window and you will get all the way back to the Media Service page (you can also get to this by looking at the media service page and clicking on live streaming.) Grab the Ingest URL by clicking the clipboard icon to the far right of the field.
7. Configure OBS
Now go into the Settings menu of OBS and navigate to Stream. Paste the URL that you just copied into the URL field and type “default” in the “Stream key” field, then press OK.
Back on the OBS main screen, press “Start Streaming” — make sure you have something setup in OBS to stream or you will just be outputting a black screen.
8. Test the Live Stream
Now go back into your browser, and scroll to the right until you get to the Locator details page.
You will see four streaming endpoints, each for different streaming protocols. You can click the “Watch” button on the Live Event page to bring up an embedded player (press the play button to start playback!) On the screen below, you can see the OBS window, the Azure console window, the native IINA player app playing the HLSv4 stream and a dash.js reference player. Note that the OBS stream will be ahead of all of the others. The DASH and HLS outputs should only have a few seconds difference.
You can use these URLs for playback in the appropriate player on different devices.
9. Shutting it Down
Don’t forget to shut things off or delete them when you are done. Keeping channels running incurs costs. You can either delete the resource group, which will destroy all of the resources, or if you’re going to do more streaming, you can simply stop anything that is running. You can use the Dashboard view to see what resources are present in your account.