<?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>IONCANNON &#187; Streaming Video</title>
	<atom:link href="http://www.ioncannon.net/tag/streaming-video/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ioncannon.net</link>
	<description>Thoughts on Software Development and Engineering</description>
	<lastBuildDate>Tue, 03 Jan 2012 13:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://www.ioncannon.net/?pushpress=hub'/>
		<item>
		<title>iPad Streaming Video and More</title>
		<link>http://www.ioncannon.net/programming/1015/ipad-streaming-video-and-more/</link>
		<comments>http://www.ioncannon.net/programming/1015/ipad-streaming-video-and-more/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 11:01:33 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[segmenter]]></category>
		<category><![CDATA[Streaming Video]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=1015</guid>
		<description><![CDATA[I&#039;ve updated the configuration examples in the open source segmenter project to reflect Apple&#039;s recommended stream bitrates for iPad video streaming, added a few fixes and a few new features. If you are interested in streaming video on the iPad, iPhone or iPod Touch and haven&#039;t done so yet you it may help to start [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve updated the configuration examples in the open source segmenter project to reflect <a href="http://developer.apple.com/iphone/library/technotes/tn2010/tn2224.html">Apple&#039;s recommended stream bitrates</a> for iPad video streaming, added a few fixes and a few new features. If you are interested in streaming video on the iPad, iPhone or iPod Touch and haven&#039;t done so yet you it may help to start with my post on <a href="http://www.ioncannon.net/meta/564/iphone-windowed-http-live-streaming-server/">windowed streaming on for the iPhone</a>, then read about <a href="http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/">iPhone HTTP streaming with FFMpeg and the open source segmenter</a> and finally check out the <a href="http://www.ioncannon.net/projects/http-live-video-stream-segmenter-and-distributor/">iPad, iPhone, and iPod Touch live video streaming project page</a>.</p>
<p>Here is a demo of the iPad streaming video created with the segmenter (I tried to show the progressive upgrade happening but it happens very quickly since the iPad is on WIFI, I also show that you can scrub without any issues and if you look in the background you can see the server log displaying entries as the segments are downloaded):</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/ydP51WxRDDk&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ydP51WxRDDk&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>If you want to view the demo yourself I&#039;ve created a demo for the <a href="http://www.ioncannon.net/projects/ivids/ipad/">iPad</a>, <a href="http://www.ioncannon.net/projects/ivids/iphone/">iPhone, and iPod Touch</a>. Note that those are two links, one for the iPad version and one for the iPhone/iPod Touch version. The main difference is the size of the video.</p>
<p>I used the open source video <a href="http://www.bigbuckbunny.org/">Big Buck Bunny</a> (the 1920&#215;1080 ogg version) for the above demos.</p>
<p>If you are interested in more details on what changed read on or skip to the bottom if you want to see what I&#039;ll be working towards in future versions of the segmenter.</p>
<p><span id="more-1015"></span></p>
<p>Over the past few weeks I learned that it is important that each segment starts with an <a href="http://avidemux.org/admWiki/index.php?title=H264#I-Frames">IDR frame</a>. To accomplish this I thought setting the gop so that the segment time % (gop size / frame rate) = 0 would work but I haven&#039;t completely convinced myself of this yet. An example of would be a segment size of 10 seconds % (300 gop size / 30 frame rate) = 0. This should insure that each segment starts with the correct i-frame and while I have looked over the resulting segments with a hex editor and believe it works I still get errors when using certain tools on the individual segments that makes me think it isn&#039;t working like I think it should. Either way I have included updates to the gop size in the example configuration files. The gop size is controlled by the -g option for FFMpeg and in the examples I have set it so that for a 10 second segment with the given frame rate the gop size makes sure each segment starts correctly. If you want to know more you can dig into the resulting segments and use this forum post on <a href="http://forum.digital-digest.com/showthread.php?t=89736">how to extract an i-frame</a>, this <a href="http://www.mpucoder.com/DVD/mpeghdrs.html">list of mpeg headers</a> to verify that each has the correct i-frame at the start.</p>
<p>The <a href="http://developer.apple.com/iphone/library/technotes/tn2010/tn2224.html">Apple streaming tech notes</a> where informative in a few other ways as well. The tech notes contain the supported h264 profiles for each device. For the iPhone/iPod Touch baseline level 3.0 is supported while the iPad supports baseline level 3.1. You can find out more about <a href="http://h264.code-shop.com/trac/wiki/Encoding">h264 encoding levels with FFMpeg</a> and also review <a href="http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/">FFMpeg x264 encoding guide</a>, <a href="http://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping">FFMpeg option mappings</a> and <a href="http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html">information on encoding with the x264 codec</a> for more information.</p>
<p>Another bit of information disclosed in the Apple tech notes is the existence of a media stream validation tool. This tool can be downloaded from the Apple iPhone developer site and has to be run on OS X. Apple recommends that you use this tool to validate any streams that you create.</p>
<p>One other note that I have recently ran across is that Apple seems to be <a href="http://techcrunch.com/2010/03/26/iphone-video-apps-downgrade-streaming-rates/">rejecting <i>native apps</i> that have video streams without a fall back audio stream</a>. The correct way of generating the fallback 64k audio only stream is something that is lacking in the current version of the segmenter but I hope to fix that soon. It won&#039;t matter for those using the HTML5 video tag however.</p>
<p>If you are using HTML5 video tags it is important not to use my older posts as a guide for the iPad since I use a now outdated example. Those examples still work on the iPhone but they do not work on the iPad. Here is an updated example that will work on both the iPhone and iPad:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Video Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body style=&quot;background-color:#FFFFFF; &quot;&gt;
    &lt;center&gt;
      &lt;video controls&gt;
        &lt;source src=&quot;stream_multi.m3u8&quot;/&gt;
      &lt;/video&gt;
    &lt;/center&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Finally I am currently using the latest version of FFMpeg to do tests and it seems to have become more reliable for me. The current version in git seems to be pretty good at producing usable videos from a variety of source videos.</p>
<p>The following is a quick summary of the recent changes I have made:</p>
<ul>
<li>Applied an audio patch for the segmenter from Scott Kidder. This patch skips any video processing if there is no video stream.</li>
<li>Modified sample configs with newer FFMpeg string, gop sizes, frame rates and other parameters to match the Apple recomended values for iPhone/iPod Touch with aspect ratios of 4:3 and 6:9 on cell or wifi and iPad with aspect ratios of 4:3 and 6:9 on cell or wifi</li>
<li>Added configuration sanity checks</li>
<li>Made gems not required if not using those features that need them</li>
<li>Added fix for deprecation warning from newest version of libavformat</li>
<li>Made termination work better when killed with SIGINT/ctrl-c</li>
<li>Fixed some minor issues with index file format</li>
</ul>
<p>The following are enhancements I&#039;m planning on making:</p>
<ul>
<li>
I plan on creating a howto on getting everything set up on EC2.
</li>
<li>
Dig more into verification that each segment starts with the correct I-frame.
</li>
<li>
I&#039;m going to work on refactoring everything so that instead of creating files and then transferring them it streams them all. This makes more sense with doing encryption as just another part of the pipeline.
</li>
<li>
Add ability to do <a href="http://tools.ietf.org/html/draft-pantos-http-live-streaming-02#section-6.1.2">encryption</a>. I have a proof of concept working but I decided I need to get everything set up in one continuous stream before integrating encryption into the mix.
</li>
<li>
<a href="http://www.ioncannon.net/programming/941/using-daemon-kit-and-robustthread-to-build-ruby-daemons/">I had thoughtabout using the ruby daemon utils</a> to wrap the segmenter but I decided it probably isn&#039;t necessary at this point.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/programming/1015/ipad-streaming-video-and-more/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Streaming Video Between QuickTime Broadcaster and VLC</title>
		<link>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/</link>
		<comments>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 00:19:58 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[QuickTime Broadcaster]]></category>
		<category><![CDATA[Streaming Video]]></category>
		<category><![CDATA[VLC]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=478</guid>
		<description><![CDATA[In my attempt to stream live video to my iPhone I ran into an issue with the USB QuickCam I have. Instead of fighting the problem I decided to turn to the iSight camera on a macbook but I quickly found that there isn&#039;t a great way to get the video stream to another machine. [...]]]></description>
			<content:encoded><![CDATA[<p>In my attempt to stream live video to my iPhone I ran into an issue with the USB QuickCam I have. Instead of fighting the problem I decided to turn to the iSight camera on a macbook but I quickly found that there isn&#039;t a great way to get the video stream to another machine. The best way that I have found to stream from the iSight to a second machine is to use a combination of QuickTime Broadcaster and VLC. In this post I detail how I got it set up and working.</p>
<p><span id="more-478"></span></p>
<p><b>Step 1: Install QuickTime Broadcaster</b></p>
<p>The first step is to install <a href="http://www.apple.com/quicktime/broadcaster/">QuickTime Broadcaster</a>. It doesn&#039;t have a lot of requirements so it should work on most macs. The QuickTime Broadcaster will be the source of the video and the destination of the video in my case is a second machine with <a href="http://www.videolan.org/">VLC</a> installed on it although you could run VLC on the source machine if you wanted to.</p>
<p>An important note at this point is to make sure the destination machine doesn&#039;t have a firewall turned on or if it does that it isn&#039;t blocking ports 5432 and 5434.</p>
<p><b>Step 2: Configure QuickTime Broadcaster for Streaming</b></p>
<p>Navigate to the Applications folder and launch QuickTime broadcaster. Click on the network tab and select &#034;Custom&#034; from the &#034;Preset&#034; list. For &#034;Transmission&#034; select the &#034;Manual Unicast&#034; option. The &#034;Address&#034; field contains the IP for your <b>target machine</b>, the one that you are <b>streaming to</b>. When you are finished, your settings should look something like this:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcastNetworkSetup.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcastNetworkSetup-300x221.png" alt="QuickTime Broadcast Network Setup for Streaming Video to VLC" title="QuickTime Broadcast Network Setup for Streaming Video to VLC" width="300" height="221" class="alignnone size-medium wp-image-479" /></a></p>
<p>Now the configuration is ready and it is time to create an export for use in VLC. To export go to File -> Export -> SDP menu option. For this example I&#039;m calling the file stream01.sdp.</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcasterExportSDP.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcasterExportSDP-300x103.png" alt="QuickTime Broadcaster Export SDP" title="QuickTime Broadcaster Export SDP" width="300" height="103" class="alignnone size-medium wp-image-481" /></a></p>
<p>You should transfer this file to the machine you are going to run VLC on at this point. If you are interested you can actually view the contents of the SDP file. Here is the one generated for me from the above:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">v=0<br />
o=- 0 3702455757 IN IP4 127.0.0.0<br />
s=QuickTime<br />
t=0 0<br />
a=range:npt=now-<br />
a=isma-compliance:2,2.0,2<br />
m=audio 5432 RTP/AVP 96<br />
c=IN IP4 192.168.132.100<br />
b=AS:125<br />
a=rtpmap:96 mpeg4-generic/44100/2<br />
a=fmtp:96 profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1210<br />
a=mpeg4-esid:101<br />
m=video 5434 RTP/AVP 97<br />
c=IN IP4 192.168.132.100<br />
b=AS:1372<br />
a=rtpmap:97 H264/90000<br />
a=fmtp:97 packetization-mode=1;profile-level-id=4D401E;sprop-parameter-sets=J01AHqkYFAe2ANQYBBrbCte98BA=,KN4JF6A=<br />
a=mpeg4-esid:201<br />
a=cliprect:0,0,480,640<br />
a=framesize:97 640-480</div>
</div>
<p><br/><br />
<b>Step 3: Play the Video Stream with VLC</b></p>
<p>Once the SDP file is on the destination machine you can start VLC and open it. In VLC go to File -> Open File then select the SDP file that was exported earlier.</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCOpenFile.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCOpenFile-300x100.png" alt="VLC Open File" title="VLC Open File" width="300" height="100" class="alignnone size-medium wp-image-484" /></a></p>
<p>VLC is now ready to stream from QuickTime Broadcaster. In QuickTime Broadcaster click the Broadcast button and then in VLC click the play button. At this point you should start seeing the stream in VLC. The order you start broadcasting between QuickTime Broadcaster and VLC doesn&#039;t seem to matter. There were a few times that I had VLC start for a second then freeze but I was using a wireless network so I&#039;ll blame that for the freezes. In general it worked well once it was all set up.</p>
<p>You can start VLC from the command line and point it directly to the stream file if you want. To do that use this command:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp</div>
</div>
<p>or if you want fancy logging:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc -vvv &#8211;color &#8211;file-logging &#8211;logfile vlc-log.html &#8211;logmode html stream01.sdp</div>
</div>
<p><br/><br />
<b>Step 4: VLC Streaming</b></p>
<p>This is actually what I would call re-streaming since my need is to get the iSight stream to FFMpeg. In the perfect world I would be able to stream directly from QuickTime Broadcaster to FFMpeg but the limitations of QuickTime Broadcaster don&#039;t allow that to happen, at least from what I could find.</p>
<p>To re-stream the iSight stream follow these steps:</p>
<ol>
<li>
  Go to Media -> Streaming</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreaming.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreaming-300x289.png" alt="VLC Streaming Menu Option" title="VLC Streaming Menu Option" width="300" height="289" class="alignnone size-medium wp-image-485" /></a></p>
<p>Enter the SDP file in the file window and hit the Stream button.
  </li>
<li>
   After you click the Stream button a window will pop up where you have the option to select a Destination:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsHTTPAdd.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsHTTPAdd-300x258.png" alt="VLC Stream Output Destinations HTTP Add" title="VLC Stream Output Destinations HTTP Add" width="300" height="258" class="alignnone size-medium wp-image-486" /></a></p>
<p>  Select &#034;Display locally&#034; if you want to see the video as it is re-streamed. </p>
<p>  Select HTTP from the &#034;New destination&#034; drop down list and click the Add button. I have picked HTTP here because it is what works the best for me but there are other options you can use if you want to try different streaming protocols. I was able to leave the defaults as they were for the HTTP stream.
  </li>
<li>
Select a transcoding profile. Here I&#039;ve selected the &#034;Video &#8211; Theora + Vorbis (OGG)&#034; profile for streaming. It seems to work the best for me:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsSetup.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsSetup-300x258.png" alt="VLC Stream Output Destinations Setup" title="VLC Stream Output Destinations Setup" width="300" height="258" class="alignnone size-medium wp-image-489" /></a></p>
<p>Click the Stream button at the bottom to start streaming.
</li>
<li> Test the stream with something like mplayer or ffplay. Because I&#039;m using HTTP to do the stream I can run the following command to test:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">mplayer http://192.168.132.100:8080/</div>
</div>
<p>Just as the playback can be done from the command line the re-streaming can too:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp &#8211;sout &#039;#transcode{vcodec=theo,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ogg,dst=0.0.0.0:8080},dst=display}&#039;</div>
</div>
<p>If you want to drop the local display:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp &#8211;sout &#039;#transcode{vcodec=theo,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ogg,dst=0.0.0.0:8080}}&#039;</div>
</div>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

