<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Larix &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/tag/larix/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Mon, 02 Nov 2020 13:54:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>General: How to stream/broadcast from your phone</title>
		<link>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/</link>
					<comments>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sun, 03 May 2020 13:47:48 +0000</pubDate>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[broadcast]]></category>
		<category><![CDATA[Larix]]></category>
		<category><![CDATA[SRT]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[VLC]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=6678</guid>

					<description><![CDATA[In this short article I&#8217;ll describe briefly how to stream/broadcast from your phone&#8217;s camera&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>In this short article I&#8217;ll describe briefly how to stream/broadcast from your phone&#8217;s camera to the world. In order to do that, you&#8217;ll need the <strong>Larix Broadcaster</strong> app installed on your phone, you will need a server with a public IP and a <strong>Haivision Media Gateway</strong> installed and for the end users, they&#8217;ll need standard <strong>VLC Player</strong> install.<br />
The Larix Broadcaster app and the VLC player are free, but Haivision Media Gateway is not. In addition, if you have your own server and want to install it as a VM, you&#8217;ll have to contact the vendor directly. I&#8217;ll use a much easier option and host it in AWS where it comes as a template from the <a href="https://aws.amazon.com/marketplace/pp/Haivision-Haivision-Media-Gateway-PAYG/B014VA1JZ4" rel="noopener noreferrer" target="_blank">AWS Marketplace</a>.</p>
<h1>Haivision Media Gateway in AWS</h1>
<p>In AWS, launch a new instance from the AWS Marketplace and search for SRT. You&#8217;ll see several options(SRT Gateway vs. Media Gateway and BYOL as PAYG license). I&#8217;ll choose Pay-as-You-Go Media Gateway.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png"><img fetchpriority="high" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png" alt="" width="1357" height="191" class="aligncenter size-full wp-image-6680" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png 1357w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-300x42.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-1024x144.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-768x108.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-1170x165.png 1170w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-585x82.png 585w" sizes="(max-width: 1357px) 100vw, 1357px" /></a><br />
As you can see, the software is not that cheap and you pay as much as you used. So if you are not streaming, just shut down the instance. Another important thing is the size of the instance, how much horse power you need. Is it 2 CPUs, 4 CPUs, 8? Well, nobody knows your needs, but it also depends on what type of stream are you sending, is it going to be a low-res or 1080p, how many users will consume that stream, etc. I strongly suggest that you go over this <a href="https://doc.haivision.com/additional-resources/srt-deployment-guide" rel="noopener noreferrer" target="_blank">document</a>. It describes how to size your environment and it gives you practical guidance on how to configure the Media Gateway. It&#8217; not a necessary read to continue with this post, but it&#8217;s strongly recommended once you have everything up and running.<br />
OK, in my case I&#8217;ll go with a t3.medium instance which is 2 CPUs and 4GB RAM. Create the instance as you normally do, make sure you have a public IP and the ports that are recommended in the security group given are open (22, 80 and 443). Once the instance boots up log with the default username <strong>haiadmin </strong>and the password is your instance id which is <strong>i-0123something</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png" alt="" width="468" height="488" class="aligncenter size-full wp-image-6681" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png 468w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-02-288x300.png 288w" sizes="(max-width: 468px) 100vw, 468px" /></a><br />
I won&#8217;t go into details what each option does and what each keyword means, I&#8217;ll just guide you through creating a route for you to be able to broadcast. So, from the screen that you see, click on the button to add a route.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png" alt="" width="1061" height="137" class="aligncenter size-full wp-image-6682" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png 1061w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-300x39.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-1024x132.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-768x99.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-585x76.png 585w" sizes="(max-width: 1061px) 100vw, 1061px" /></a><br />
These are my parameters. For the <strong>Route Name</strong>, enter a description and make sure the checkmark is checked for Start Route. Further down, enter a description for the <strong>Source Name</strong>, in my case it&#8217;s Larix Cam or whatever you want to put here. The <strong>Protocol </strong>is <strong>TS Over SRT</strong> and the port is <strong>50000</strong>. The <strong>Mode </strong>is <strong>Listener </strong>and the rest are the defaults. As I said earlier, if you want a better throughput, read the SRT deployment guide doc that I&#8217;ve sent earlier. It will tell you how to tweak these parameters. So, this tells the Media Gateway to listen on port UDP 50000 for any incoming broadcast.<br />
Now, click on the <strong>Destination </strong>button.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png" alt="" width="1082" height="131" class="aligncenter size-full wp-image-6683" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png 1082w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-300x36.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-1024x124.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-768x93.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-585x71.png 585w" sizes="(max-width: 1082px) 100vw, 1082px" /></a><br />
The <strong>Destination </strong>is where the broadcast will be distributed. So, you got the point now. A camera on your phone sends the video to our instance in AWS and this instance (Media Gateway) distributes the feed to numerous viewers. You can&#8217;t stream from your phone directly, because your phone&#8217;s bandwidth and horse power are minuscule, so you need a gateway.<br />
Here is how the <strong>Destination </strong>looks like.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png" alt="" width="657" height="753" class="aligncenter size-full wp-image-6684" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png 657w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-06-262x300.png 262w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-06-585x670.png 585w" sizes="(max-width: 657px) 100vw, 657px" /></a><br />
Name the destination however you like, make sure the <strong>Protocol </strong>is <strong>TS over SRT</strong> and the <strong>Port </strong>is 50001. The Media Gateway passes the signal from UDP 50000 (source) to UDP 50001 (destination). Can you use some other ports? Yes, you can as long as they are not the same and greater than 1024 and less than 65535. Change the <strong>Type </strong>to <strong>Listener </strong>and leave the rest of the parameters as-is. Again, read the SRT Deployment Guide. Click <strong>Add </strong>and once you go back, click <strong>Create </strong>to create the route.<br />
<strong>SUPER IMPORTANT</strong>: Make sure you edit the security group for this instance and open the ports for the source and destination. In my case, you have to add UDP ports 50000 and 50001 to the rules of the security group.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png" alt="" width="1094" height="527" class="aligncenter size-full wp-image-6685" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png 1094w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-300x145.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-1024x493.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-768x370.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-585x282.png 585w" sizes="(max-width: 1094px) 100vw, 1094px" /></a></p>
<h1>Larix Broadcaster app</h1>
<p>On your phone download this app from Google Play or App Store. Go to <strong>Settings </strong>(the gear icon), <strong>Connections </strong>and click on the <strong>(+)</strong> sign to add a connection.<br />
Enter a name for your connection, and for the URL enter the public IP of your instance and the port of the listener, so it looks like <strong>srt://public_IP:port</strong>. Make sure you specify <strong>srt://</strong> as prefix. The defaults are 640&#215;480 with audio, but you can change that in the settings for the app. Now, that you have a connection, make sure it&#8217;s active by selecting it and after that just hit the <strong>Record </strong>button. If something is not right, you&#8217;ll see it right away on your camera. It will tell you that the app can&#8217;t connect to the server. And if everything is OK after about 8-10 seconds you&#8217;ll see a green dot next to your source in the Media Gateway.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png" alt="" width="1039" height="134" class="aligncenter size-full wp-image-6687" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png 1039w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-300x39.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-1024x132.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-768x99.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-585x75.png 585w" sizes="(max-width: 1039px) 100vw, 1039px" /></a></p>
<h1>VLC PLayer</h1>
<p>There is really nothing much to say here. Go to <a href="https://www.videolan.org/vlc/index.html" rel="noopener noreferrer" target="_blank">this </a>website, download and install <strong>VLC </strong>and from the menu click on <strong>Media | Open Network Stream</strong>. Enter the IP address of the AWS instance and specify the destination port like <strong>srt://public_IP:port</strong>. Make sure you specify the destination port, not the source port and the protocol should be srt.</p>
<h1>Stream a video file (optional)</h1>
<p>In case you want your source to be a video file instead of a camera stream, reconfigure the source or add another route with new source and destination of which the source is RTMP. Configure the source so it looks like this.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png" alt="" width="1096" height="819" class="aligncenter size-full wp-image-6690" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png 1096w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-300x224.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-1024x765.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-768x574.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-585x437.png 585w" sizes="(max-width: 1096px) 100vw, 1096px" /></a><br />
From another server send the video stream to the Media Gateway using this command (you need ffmpeg installed).</p>
<pre class="brush: bash; title: ; notranslate">
ffmpeg -re -i video-file.mp4 -c copy -f flv rtmp://media_gateway_ip/live/stream
</pre>
<p>In VLC, use the <strong>srt://media_gateway_ip:port</strong> to watch the stream.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
