{"id":16125,"date":"2017-12-02T20:08:00","date_gmt":"2017-12-02T20:08:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/?p=16125"},"modified":"2019-03-01T14:12:46","modified_gmt":"2019-03-01T21:12:46","slug":"how-to-setup-live-streaming-server-using-azure-media-service-in-less-than-30-mins","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/how-to-setup-live-streaming-server-using-azure-media-service-in-less-than-30-mins\/","title":{"rendered":"How to setup live streaming server using Azure Media Service in less than 30 mins"},"content":{"rendered":"<p>In this post, Senior App Dev Manager <a href=\"https:\/\/www.linkedin.com\/in\/parkrandy\/\">Randy Park<\/a> walks us through Azure Media Services to setup a live streaming PoC.<\/p>\n<hr \/>\n<p><b>Background<\/b>: A customer recently launched a global intranet portal with an audience distributed across the globe.\u00a0 They expected an increase of the audience on a daily basis and leadership team requested one more interesting feature&#8211; <em>live video streaming<\/em>. Microsoft Premier was asked to help with the live video streaming PoC to assess feasibility and performance. An additional requirement was that first, the live content should stream in real time and the be available after the event for later viewing. Second, the encoding of the media should be controlled internally so that they can manage the media and video codecs required. Third, secure content only accessible to the intended audience. Though everyone had somewhat of an idea that Azure Media Service (AMS) should easily make this possible, none were sure how fast this could be done. This blog will highlight step-by-step of setting up live streaming service less than 30 mins by incorporating a few steps outlined in below articles.<\/p>\n<p>If you are new to Azure Media Service, here are a few resources that provide additional background:<\/p>\n<ul>\n<li><a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/learning-paths\/media-services-streaming-live\/\">Azure Media Services \u2013 Live Streaming Overview<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/media-services\/media-services-manage-channels-overview\">Overview of Live Streaming using Azure Media Services<\/a><\/li>\n<li><a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-media-services-rtmp-support-and-live-encoders\/\">Azure Media Services RTMP Support and Live Encoders<\/a><\/li>\n<\/ul>\n<h3>Creating AMS Live Stream channel<\/h3>\n<p>For the very first PoC, we didn\u2019t have the development environment equipped with a camera thus we chose the <a href=\"http:\/\/ffmpeg.org\/\">FFmpeg<\/a> encoder for the quick PoC of the live video encoder.<\/p>\n<p>1. Create Azure Media Service, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/media-services\/media-services-portal-create-account\">steps specified here<\/a>.<\/p>\n<p>2. Select the AMS account and in the <b>Settings<\/b> window, click <b>Live streaming<\/b>.<\/p>\n<p>3. For channel creation, click <b>Custom Create<\/b>.<\/p>\n<blockquote><p>a.\u00a0 On Settings, select <b>Encoding type<\/b> to <b>Live Encoding<\/b> and supply the channel <b>Name<\/b>. Leave <b>Automatically start the channel after creation<\/b> checked.\nb.\u00a0 On Ingest, select <b>Streaming protocol<\/b> to <b>RTMP<\/b>.\nc.\u00a0 On Preview, leave <b>IP restriction on the preview<\/b> to <b>None<\/b>.\nd.\u00a0 On Encoding, only option for <b>Encoding preset<\/b> is <b>Default 720p<\/b>.\ne.\u00a0 Click <b>Create. <\/b>This process will take at least a few mins then will also start the channel. Starting channel will also take at least 5 mins to the <b>Running<\/b> status.<\/p><\/blockquote>\n<p>4. On Live streaming list, click on the channel just created. The screen containing below information will appear. Copy <b>Ingest URL (Primary)<\/b> and save it somewhere, we will use this in the <b>step 8<\/b> and <b>step 12<\/b>.<\/p>\n<p align=\"center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media1.png\"><img decoding=\"async\" title=\"media1\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media1_thumb.png\" alt=\"media1\" width=\"743\" height=\"772\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 1. Sample channel<\/span><\/p>\n<p>5. Click <b>Go Live<\/b>. You should be able see the Live events section like below, since we didn\u2019t create a specific live event, the <b>default<\/b> live event gets created. The status will change from <b>Starting<\/b> to <b>Running<\/b> in a few minutes.<\/p>\n<p align=\"center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media2.png\"><img decoding=\"async\" title=\"media2\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media2_thumb.png\" alt=\"media2\" width=\"644\" height=\"158\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 2. Creating <b>default<\/b> live event<\/span><\/p>\n<p>6. Click on the <b>default<\/b> live event then click on <b>Streaming<\/b> locator to open multiple streaming URLs.<\/p>\n<p align=\"center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media3.png\"><img decoding=\"async\" title=\"Media3\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media3_thumb.png\" alt=\"Media3\" width=\"1028\" height=\"223\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 3. Streaming locator<\/span><\/p>\n<p>7. Azure Media Live steaming provides multiple streaming URLs, <b>Smooth Streaming<\/b>, <b>MPEG-DASH<\/b>, <b>HLS(v3)<\/b> and <b>HLS(v4)<\/b>. Copy <b>Smooth Streaming<\/b> endpoint URL and save it somewhere, we will use this endpoint for the testing in the <b>step 9<\/b>.<\/p>\n<p>&nbsp;<\/p>\n<h3>Testing with local mp4 file streaming<\/h3>\n<p>8. Download <a href=\"http:\/\/ffmpeg.org\/\">FFmpeg<\/a> encoder and install it. Have your sample mp4 file ready (let\u2019s suppose the file name is <b>my-sample-video.mp4<\/b>) and execute the ffmpeg.exe like below. You would need to have the Ingest URL captured in step 4.<\/p>\n<pre class=\"lang:default decode:true\">C:\\tools\\ffmpeg\\bin\\ffmpeg.exe -v verbose -i my-sample-video.mp4 -strict -2 -c:a aac -b:a 128k -ar 44100 -r 30 -g 60 -keyint_min 60 -b:v 400000 -c:v libx264 -preset medium -bufsize 400k -maxrate 400k -f flv {paste_your_Ingest_url_from_step_4_here}\/mystream<\/pre>\n<p align=\"center\">Below is sample screenshot of the lab machine, note of different filename and the media and codec information, \u2026 etc.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media4.png\"><img decoding=\"async\" title=\"Media4\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media4_thumb.png\" alt=\"Media4\" width=\"895\" height=\"772\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 4. Result output of FFmpeg streaming<\/span><b> <\/b><\/p>\n<p>9. Immediately open Internet Explorer (before step 8\u2019s streaming gets ended), go to <a href=\"http:\/\/ampdemo.azureedge.net\/\">Azure Media Player demo site<\/a>. Select the <b>Samples <\/b>as <b>Live (Smooth Ingest) \u2013 24&#215;7<\/b>, and paste the URL from <b>step 7<\/b>. The URL should contain *.ism\/manifest at the end. Click Update Player. Voila! you will see the step 8\u2019s streaming content playing in the Azure Media player!<\/p>\n<h3>Testing live event streaming<\/h3>\n<p>10. Locate the PC with a camera. We chose Wirecast as it is a well-known RTMP encoder. Wirecast enables capture, live production, and encoding of live streams for broadcast. You can get more information and download a trial version from the <a href=\"https:\/\/www.telestream.net\/wirecast\/overview.htm\">Telestream web site<\/a>. Install the trial version and this step is for Wirecast 8.0.<\/p>\n<p>11. Open Wirecast and click on the very first layer\u2019s (+) button, select the Capture Device.<\/p>\n<p align=\"center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media5.png\"><img decoding=\"async\" title=\"Media5\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media5_thumb.png\" alt=\"Media5\" width=\"1028\" height=\"605\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 5. Capture device \/ Select the camera<\/span><\/p>\n<p>12. Setup <b>Output Settings <\/b>and configure the Wirecast use the RTMP Server and enter the RTMP address copied from the AMS Live Stream\u2019s Ingest URL from <b>step 4<\/b>.<\/p>\n<p>13. Kick off the Live by pressing <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media_button_thumb.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-16165\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/media_button_thumb.png\" alt=\"\" width=\"60\" height=\"37\" \/><\/a> button.<\/p>\n<p>14. Start broadcast by <b>Output &gt; Start \/ Stop Broadcasting &gt; Start RTMP Server: RTMP Server<\/b>. You should be seeing something like below screen.<\/p>\n<p align=\"center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media6.png\"><img decoding=\"async\" title=\"Media6\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/Media6_thumb.png\" alt=\"Media6\" width=\"1028\" height=\"438\" border=\"0\" \/><\/a>\n<span style=\"font-size: xx-small\">Figure 6. <b>Start<\/b> the live broadcasting<\/span><b> <\/b><\/p>\n<p>15. For live event validation, go to Step 9 and Voila, you should be able to see the live broadcasting. If you\u2019re using Wirecast demo version, you will see the Wirecast watermark as well as Wirecast announcement audio to the live streaming.<\/p>\n<p>16. For the archival video access, from the AMS blade, select <b>Assets<\/b>, you should be able to see the Live Archive stored for you to share to those who may want to see the streaming at later time. This channel access has very similar experience mentioned in step 6 and step 7, and one can easily see this archive streaming endpoints are identical than that of live streaming.<\/p>\n<p>And, that\u2019s it. Cool live steaming setup in less than 30 minutes and can share this to the global audience.<\/p>\n<p><b>Conclusion<\/b>: Of course, this isn\u2019t all there is to the PoC. The team continued to build additional components and customized services on this platform. Placing the corporate security context was another big concern to address and currently in the works, but the team was excited to see how easy it is to utilize Azure Media Services for their live streaming experience. Stay tuned on this Premier Blog for subsequent implementations on using the .NET code, wrapping with security context plus integration of multiple Azure Cognitive services to this platform.<\/p>\n<hr \/>\n<p><a href=\"https:\/\/blogs.msdn.com\/b\/premier_developer\/archive\/2014\/09\/15\/welcome.aspx\"><strong>Premier Support for Developers<\/strong><\/a> provides strategic technology guidance, critical support coverage, and a range of essential services to help teams optimize development lifecycles and improve software quality.\u00a0 Contact your Application Development Manager (ADM) or <a href=\"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/contact-us\/\"><b>email us<\/b><\/a> to learn more about what we can do for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, Senior App Dev Manager Randy Park walks us through Azure Media Services to setup a live streaming PoC. Background: A customer recently launched a global intranet portal with an audience distributed across the globe.\u00a0 They expected an increase of the audience on a daily basis and leadership team requested one more interesting [&hellip;]<\/p>\n","protected":false},"author":582,"featured_media":37840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25],"tags":[24,354,3],"class_list":["post-16125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","tag-azure","tag-streaming","tag-team"],"acf":[],"blog_post_summary":"<p>In this post, Senior App Dev Manager Randy Park walks us through Azure Media Services to setup a live streaming PoC. Background: A customer recently launched a global intranet portal with an audience distributed across the globe.\u00a0 They expected an increase of the audience on a daily basis and leadership team requested one more interesting [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/16125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=16125"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/16125\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37840"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=16125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=16125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=16125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}