Share via


Create an Azure Media Services live stream with OBS

Media Services logo v3


Warning

Azure Media Services will be retired June 30th, 2024. For more information, see the AMS Retirement Guide.

This quickstart will help you create a Media Services Live Event by using the Azure portal and broadcast using Open Broadcasting Studio (OBS). It assumes that you have an Azure subscription and have created a Media Services account.

In this quickstart, we'll cover:

  • Setting up an on-premises encoder with OBS.
  • Setting up a live stream.
  • Setting up live stream outputs.
  • Running a default streaming endpoint.
  • Using Azure Media Player to view the live stream and on-demand output.

Prerequisites

If you don't have an Azure subscription, create a free account before you begin.

Sign in to the Azure portal

Open your web browser, and go to the Microsoft Azure portal. Enter your credentials to sign in to the portal. The default view is your service dashboard.

Set up an on-premises encoder by using OBS

  1. Download and install OBS for your operating system on the Open Broadcaster Software website.
  2. Start the application and keep it open.

Run the default streaming endpoint

  1. Select Streaming endpoints in the Media Services listing.
  2. If the default streaming endpoint status is stopped, select it. This step takes you to the page for that endpoint.
  3. Select Start.

Set up an Azure Media Services live stream

  1. Go to the Azure Media Services account within the portal, and then select Live streaming from the Media Services listing.
  2. Select Add live event to create a new live streaming event.
  3. Enter a name for your new event, such as TestLiveEvent, in the Live event name box.
  4. Enter an optional description of the event in the Description box.
  5. Select the basic Standard pass-through option.
  6. Leave all the rest of the settings as they are for now.
  7. Select the I have all the rights to use the content/file, and agree... checkbox after you have read the Online Services Terms and the Microsoft Privacy Statement.
  8. Select the Review + create button to review the settings.
  9. Select the Create button to create the live event. You're then returned to the live event listing.
  10. Select the link to the live event that you created. Notice that your event is stopped.
  11. Keep this page open in your browser. We'll come back to it later.

Set up a live stream by using OBS Studio

OBS starts with a default scene but with no inputs selected.

Add a video source

  1. From the Sources panel, select the add icon to select a new source device. The Sources menu will open.
  2. Select Video Capture Device from the source device menu. The Create/Select Source menu will open.
  3. Select the Add Existing radio button, then select OK. The Properties for Video Device menu will open.
  4. From the Device dropdown list, select the video input you want to use for your broadcast. Leave the rest of the settings alone for now, and select OK. The input source will be added to the Sources panel, and the video input view will show up in the Preview area.

Add an audio source

  1. From the Sources panel, select the add icon to select a new source device. The Source Device menu will open.
  2. Select Audio Input Capture from the source device menu. The Create/Select Source menu will open.
  3. Select the Add Existing radio button, then select OK. The Properties for Audio Input Capture menu will open.
  4. From the Device dropdown list, select the audio capture device you want to use for your broadcast. Leave the rest of the settings alone for now, and select OK. The audio capture device will be added to the audio mixer panel.

Set up streaming and advanced encoding settings in OBS

In the next procedure, you'll go back to the portal Azure Media Services page in your browser to copy the input URL to enter into the output settings:

  1. If you aren't already on the streaming endpoint page in the portal, navigate to it from the Media Services account you are working with.
  2. Select Start to start the live stream event. (Billing starts now.)
  3. In the Input URL box, copy the URL to your clipboard.
  4. Switch to the OBS application.
  5. Select the Settings button in the Controls panel. The Settings options will open.
  6. Select Stream from the Settings menu.
  7. From the Service dropdown list, select Show all, then select Custom....
  8. In the Server field, paste the RTMPS URL you copied to your clipboard.
  9. Enter something into the Stream key field. It doesn't really matter what it is, but it needs to have a value.
  10. Select Output from the Settings menu.
  11. Select the Output Mode dropdown at the top of the page and choose Advanced to access all of the available encoder settings.
  12. Select the Streaming tab to set up the encoder.
  13. Select the right encoder for your system. If your hardware supports GPU acceleration, choose from NVIDIA NVENC H.264 or Intel QuickSync H.264. If your system doesn't have a supported GPU, select the X264 software encoder option.

X264 Encoder settings

  1. If you have selected the X264 encoding option select the Rescale Output box. Select either 1920x1080 if you are using a Premium Live Event in Media Services or 1280x720 if you're using a Standard (720P) Live Event. If you're using a basic or standard pass-through live event, you can choose any available resolution.

  2. Set the Bitrate to anywhere between 1500 Kbps and 4000 Kbps. We recommend 2500 Kbps if you are using a Standard encoding Live Event at 720P. If you are using a 1080P Premium Live Event, 4000 Kbps is recommended. You may wish to adjust the bitrate based on available CPU capabilities and bandwidth on your network to achieve the desired quality setting.

  3. Enter 2 into the Keyframe interval field. The value sets the key frame interval to 2 seconds, which controls the final size of the fragments delivered over HLS or DASH from Media Services. Never set the key frame interval any higher than 4 seconds. If you are seeing high latency when broadcasting, you should always double check or inform your application users to always set this value to 2 seconds. When attempting to achieve lower latency live delivery you can choose to set this value to as low as 1 second.

  4. OPTIONAL: Set the CPU Usage Preset to veryfast and run some experiments to see if your local CPU can handle the combination of bitrate and preset with enough overhead. Try to avoid settings that would result in an average CPU higher than 80% to avoid any issues during live streaming. To improve quality, you can test with faster and fast preset settings until you reach your CPU limitations.

  5. Leave the rest of the settings unchanged and select OK.

Nvidia NVENC Encoder settings

  1. If you have selected the NVENC GPU encoding option, check the Rescale Output box and select either 1920x1080 if you are using a Premium Live Event in Media Services, or 1280x720 if you are using a Standard (720P) Live Event. If you are using a basic or standard pass-through live event, you can choose any available resolution.
  2. Set the Rate Control to CBR for Constant Bitrate rate control.
  3. Set the Bitrate anywhere between 1500 Kbps and 4000 Kbps. We recommend 2500 Kbps if you are using a Standard encoding Live Event at 720P. If you are using a 1080P Premium Live Event, 4000 Kbps is recommended. You may choose to adjust this based on available CPU capabilities and bandwidth on your network to achieve the desired quality setting.
  4. Set the Keyframe Interval to 2 seconds as noted above under the X264 options. Do not exceed 4 seconds, as this can significantly impact the latency of your live broadcast.
  5. Set the Preset to Low-Latency, Low-Latency Performance, or Low-Latency Quality depending on the CPU speed on your local machine. Experiment with these settings to achieve the best balance between quality and CPU utilization on your own hardware.
  6. Set the Profile to "main" or "high" if you are using a more powerful hardware configuration.
  7. Leave the Look-ahead unchecked. If you have a very powerful machine you can check this.
  8. Leave the Psycho Visual Tuning unchecked. If you have a very powerful machine you can check this.
  9. Set the GPU to 0 to automatically decide which GPUs to allocate. If desired, you can restrict GPU usage.
  10. Set the Max B-frames to 2

Intel QuickSync Encoder settings

  1. If you have selected the Intel QuickSync GPU encoding option, check the Rescale Output box and select either 1920x1080 if you are using a Premium Live Event in Media Services, or 1280x720 if you are using a Standard (720P) Live Event. If you are using a basic or standard pass-through live event, you can choose any available resolution.
  2. Set the Target Usage to "balanced" or adjust as needed based on your CPU and GPU combined load. Adjust as necessary and experiment to achieve an 80% max CPU utilization on average with the quality that your hardware is capable of producing. If you are on more constrained hardware, test with "fast" or drop to "very fast" if you are having performance issues.
  3. Set the Profile to "main" or "high" if you are using a more powerful hardware configuration.
  4. Set the Keyframe Interval to 2 seconds as noted above under the X264 options. Do not exceed 4 seconds, as this can significantly impact the latency of your live broadcast.
  5. Set the Rate Control to CBR for Constant Bitrate rate control.
  6. Set the Bitrate anywhere between 1500 and 4000 Kbps. We recommend 2500 Kbps if you are using a Standard encoding Live Event at 720P. If you are using a 1080P Premium Live Event, 4000 Kbps is recommended. You may choose to adjust this based on available CPU capabilities and bandwidth on your network to achieve the desired quality setting.
  7. Set the Latency to "low".
  8. Set the B frames to 2.
  9. Leave the Subjective Video Enhancements unchecked.

Set Audio settings

In the next procedure, you will adjust the audio encoding settings.

  1. Select the Output->Audio tab in Settings.
  2. Set the Track 1 Audio Bitrate to 128 Kbps.
  3. Select the Audio tab in Settings.
  4. Set the Sample Rate to 44.1 kHz.

Start streaming

  1. In the Controls panel, click Start Streaming.
  2. Switch to the Azure Media Services Live event screen in your browser and click the Reload Player link. You should now see your stream in the Preview player.

Set up outputs

This part will set up your outputs and enable you to save a recording of your live stream.

Note

For you to stream this output, the streaming endpoint must be running. See the later Run the default streaming endpoint section.

  1. Select the Create outputs link below the Outputs video viewer.
  2. If you like, edit the name of the output in the Name box to something more user-friendly so it's easy to find later.
  3. Leave all the rest of the boxes alone for now.
  4. Select Next to add a streaming locator.
  5. Change the name of the locator to something more user-friendly, if you want.
  6. Leave everything else on this screen alone for now.
  7. Select Create.

Play the output broadcast by using Azure Media Player

  1. Copy the streaming URL under the Output video player.
  2. In a web browser, open the Azure Media Player demo.
  3. Paste the streaming URL into the URL box of Azure Media Player.
  4. Select the Update Player button.
  5. Select the Play icon on the video to see your live stream.

Stop the broadcast

When you think you've streamed enough content, stop the broadcast.

  1. In the portal, select Stop.

  2. In OBS, select the Stop Streaming button in the Controls panel. This step stops the broadcast from OBS.

Play the on-demand output by using Azure Media Player

The output that you created is now available for on-demand streaming as long as your streaming endpoint is running.

  1. Go to the Media Services listing and select Assets.
  2. Find the event output that you created earlier and select the link to the asset. The asset output page opens.
  3. Copy the streaming URL under the video player for the asset.
  4. Return to Azure Media Player in the browser and paste the streaming URL into the URL box.
  5. Select Update Player.
  6. Select the Play icon on the video to view the on-demand asset.

Clean up resources

Important

Stop the services! After you've completed the steps in this quickstart, be sure to stop the live event and the streaming endpoint, or you'll be billed for the time they remain running. To stop the live event, see the Stop the broadcast procedure, steps 2 and 3.

To stop the streaming endpoint:

  1. From the Media Services listing, select Streaming endpoints.
  2. Select the default streaming endpoint that you started earlier. This step opens the endpoint's page.
  3. Select Stop.

Tip

If you don't want to keep the assets from this event, be sure to delete them so you're not billed for storage.

Get help and support

You can contact Media Services with questions or follow our updates by one of the following methods: