<?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>Fooling Around &#187; Video</title>
	<atom:link href="http://alax.info/blog/category/video/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Wed, 02 May 2012 15:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>American Kestrel Partnership &#8212; The Peregrine Fund</title>
		<link>http://alax.info/blog/1354</link>
		<comments>http://alax.info/blog/1354#comments</comments>
		<pubDate>Tue, 24 Apr 2012 21:11:57 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[ip video source]]></category>
		<category><![CDATA[kestrel]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[nestbox]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[ustream]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1354</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1354" title="American Kestrel Partnership -- The Peregrine Fund"></a>As a part of American Kestrel Partnership project, Peregrine Fund put live cameras online to broadcast interior and exterior views of American Kestrel nest boxes in their campus in Boise, Idaho. One of the nestboxes is not only populated, four &#8230;<p class="read-more"><a href="http://alax.info/blog/1354">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1354" title="American Kestrel Partnership -- The Peregrine Fund"></a><p>As a part of American Kestrel Partnership project, Peregrine Fund put live cameras online to broadcast interior and exterior views of American Kestrel nest boxes in their campus in Boise, Idaho. </p>
<p>One of the nestboxes is not only populated, four eggs have been laid recently and hatching is expected soon. The live picture is made possible by putting IP cameras and connecting them with to <a href="http://www.ustream.tv/">Ustream.tv</a> broadcasting service through <a href="http://www.adobe.com/products/flash-media-encoder.html">Adobe FMLE</a> software through my <a href="http://alax.info/blog/1223">IP Video Source</a> DirectShow driver for IP cameras (the IP camera video feed is streamed 24/7 through a virtual video device picked up by FMLE and re-encoded into uploadable stream forwarded to Ustream online service for further distribution).</p>
<p><iframe width="600" height="450" src="http://www.youtube.com/embed/vpUsHkjXAqU" frameborder="0" allowfullscreen></iframe></p>
<p>For more information, see:</p>
<ul>
<li><a href="http://kestrel.peregrinefund.org">American Kestrel Website</a></li>
<li><a href="http://www.peregrinefund.org/news-release/233">News Release: The Peregrine Fund launches new project, website to conserve American Kestrels</a></li>
<li><a href="http://boisestatepublicradio.org/post/citizen-scientists-get-chance-help-declining-kestrels">NPR news story about the project</a></li>
<li><a href="http://www.peregrinefund.org/american-kestrel">American Kestrel Partnership Project</a></li>
<li><a href="http://en.wikipedia.org/wiki/American_Kestrel">American Kestrel on Wikipedia</a></li>
<li><a href="http://www.ustream.tv/user/ThePeregrineFund">The Peregrine Fund on Ustream.tv</a></li>
</ul>
<p>Watch the pet on live cameras below:</p>
<h3>North Nestbox &#8211; Outside</h3>
<p><a href=http://ustre.am/Evbs>http://ustre.am/Evbs</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="296" id="utv639704"><param name="flashvars" value="autoplay=false&amp;brand=embed&amp;cid=9652994&amp;v3=1"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&amp;brand=embed&amp;cid=9652994&amp;v3=1" width="480" height="296" allowfullscreen="true" allowscriptaccess="always" id="utv639704" name="utv_n_139754" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object><br /><a href="http://www.ustream.tv/" style="padding: 2px 0px 4px; width: 400px; background: #ffffff; display: block; color: #000000; font-weight: normal; font-size: 10px; text-decoration: underline; text-align: center;" target="_blank">Live stream videos at Ustream</a></p>
<h3>North Nestbox &#8211; Inside</h3>
<p><a href=http://ustre.am/J6jD>http://ustre.am/J6jD</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="296" id="utv706221"><param name="flashvars" value="autoplay=false&amp;brand=embed&amp;cid=10749041&amp;v3=1"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&amp;brand=embed&amp;cid=10749041&amp;v3=1" width="480" height="296" allowfullscreen="true" allowscriptaccess="always" id="utv706221" name="utv_n_591901" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object><br /><a href="http://www.ustream.tv/" style="padding: 2px 0px 4px; width: 400px; background: #ffffff; display: block; color: #000000; font-weight: normal; font-size: 10px; text-decoration: underline; text-align: center;" target="_blank">Live broadcasting by Ustream</a></p>
<p><span id="more-1354"></span></p>
<h3>South Nestbox &#8211; Outside</h3>
<p><a href=http://ustre.am/JjP2>http://ustre.am/JjP2</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="296" id="utv267903"><param name="flashvars" value="autoplay=false&amp;brand=embed&amp;cid=10800960&amp;v3=1"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&amp;brand=embed&amp;cid=10800960&amp;v3=1" width="480" height="296" allowfullscreen="true" allowscriptaccess="always" id="utv267903" name="utv_n_54229" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object><br /><a href="http://www.ustream.tv/" style="padding: 2px 0px 4px; width: 400px; background: #ffffff; display: block; color: #000000; font-weight: normal; font-size: 10px; text-decoration: underline; text-align: center;" target="_blank">Streaming Live by Ustream</a></p>
</td>
<td>
<h3>South Nestbox &#8211; Inside</h3>
<p><a href=http://ustre.am/JjP7>http://ustre.am/JjP7</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="296" id="utv858790"><param name="flashvars" value="autoplay=false&amp;brand=embed&amp;cid=10800965&amp;v3=1"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&amp;brand=embed&amp;cid=10800965&amp;v3=1" width="480" height="296" allowfullscreen="true" allowscriptaccess="always" id="utv858790" name="utv_n_708958" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object><br /><a href="http://www.ustream.tv/" style="padding: 2px 0px 4px; width: 400px; background: #ffffff; display: block; color: #000000; font-weight: normal; font-size: 10px; text-decoration: underline; text-align: center;" target="_blank">Streaming Live by Ustream</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1354/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So, how many EVRs you can do?</title>
		<link>http://alax.info/blog/1342</link>
		<comments>http://alax.info/blog/1342#comments</comments>
		<pubDate>Sat, 03 Mar 2012 21:52:12 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[direct3d]]></category>
		<category><![CDATA[evr]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1342</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1342" title="So, how many EVRs you can do?"></a>Direct3D based DirectShow video renderers – Video Mixing Renderer 9 and Enhanced Video Renderer – have been notoriously known for consuming resources in a way that you can run at most X simultaneously. There has been no comment published on &#8230;<p class="read-more"><a href="http://alax.info/blog/1342">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1342" title="So, how many EVRs you can do?"></a><p>Direct3D based DirectShow video renderers – <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd407344%28v=vs.85%29.aspx">Video Mixing Renderer 9</a> and <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms694916%28v=vs.85%29.aspx">Enhanced Video Renderer</a> – have been notoriously known for consuming resources in a way that you can run at most X simultaneously. There has been no comment published on the topic and questions (e.g. like this: <a href="http://social.msdn.microsoft.com/Forums/en/windowsdirectshowdevelopment/thread/1debfc45-caa3-4dcb-ab1d-c7162adaa1f7">How many VMR 9 can a PC support concurrently</a>) remain unanswered for a long time. Video Mixing Renderer 7 was a good alternative for some time in past until it was cut down to be unable to support hardware scaling (thanks Microsoft!).</p>
<p>The trendy way to render video nowadays is using Enhanced Video Renderer, a Media Foundation subsystem with an interface into DirectShow to take over state of the art video rendering capabilities. So, how many EVRs one can run simultaneously? Chances are that it is less than one could suppose.</p>
<p>The interesting part is that there is no obvious evidence on type of resource running out, which causing next EVR instance to fail to run. And not even run, the failure seem to be coming up at an earlier stage of just connecting pins in stopped state. The failure might be accompanied with errors like E_INVALIDARG, ERROR_FILE_NOT_FOUND, E_UNEXPECTED. The actual limit appear to be loosely correlating to parameters of video output, such as resolution and bitness.</p>
<p><img class="alignnone size-full wp-image-1344" title="Stress EVR" src="http://alax.info/blog/wp-content/uploads/2012/03/Image001.png" alt="" width="742" height="374" /></p>
<p>Desperately waiting for clarification, I am sharing the tool to estimate the limit:</p>
<ul>
<li>multiple EVR instances at once, hosted by multiple windows, which can be distributed across multiple monitors</li>
<li>choices of resolutions and formats</li>
<li>a double click on an individual renderer pops up property page set displaying effective frame rate</li>
<li>32- and 64-bit versions</li>
</ul>
<p><a href="http://alax.info/blog/wp-content/uploads/2012/03/Image002.png"><img class="alignnone size-large wp-image-1345" title="Stress EVR Live" src="http://alax.info/blog/wp-content/uploads/2012/03/Image002-800x391.png" alt="" width="620" height="303" /></a></p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/StressEvr/_Bin/Win32/Release%20Trace/StressEvr.exe">Win32</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/StressEvr/_Bin/x64/Release%20Trace/StressEvr.exe">x64</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/StressEvr">partial source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1342/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oops, AMAP_3D_TARGET</title>
		<link>http://alax.info/blog/1335</link>
		<comments>http://alax.info/blog/1335#comments</comments>
		<pubDate>Mon, 13 Feb 2012 18:43:44 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[DirectDraw]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[mixing]]></category>
		<category><![CDATA[renderer]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1335</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1335" title="Oops, AMAP_3D_TARGET"></a>Unfortunately, AMAP_3D_TARGET appears to be useless. Internally, surface allocation comes up with the following capabilities for the surface: DDSCAPS_VIDEOMEMORY &#124; DDSCAPS_LOCALVIDMEM &#124; DDSCAPS_OFFSCREENPLAIN &#124; DDSCAPS_3DDEVICE. Sadly, DirectDraw responds (might respond?) with E_NOTIMPL. While one can advance one step further by &#8230;<p class="read-more"><a href="http://alax.info/blog/1335">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1335" title="Oops, AMAP_3D_TARGET"></a><p>Unfortunately, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd407394%28v=vs.85%29.aspx">AMAP_3D_TARGET</a> appears to be useless. Internally, surface allocation comes up with the following capabilities for the surface: <strong>DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE</strong>. Sadly, DirectDraw responds (might respond?) with <strong>E_NOTIMPL</strong>.</p>
<p>While one can advance one step further by removing <strong>DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM</strong>, another problem is hit that you are no longer able to create a surface with is both FourCC enabled and in the same time has 3D rendering capabilities. Remove your YUV four character code (such as NV12, YV12, YUY2 you would normally have as codec&#8217;s output) or fail miserably with <strong>DDERR_INVALIDPIXELFORMAT</strong>.</p>
<p>Back to the original problem, the <strong>AMAP_3D_TARGET</strong> flag failing to work makes it impossible to allocate 3D-enabled DirectDraw surface with DirectShow <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd407343%28v=vs.85%29.aspx">Video Mixing Renderer</a>. While it might sound as deprecated technology, it is yet a supported Windows SDK component, the most efficient video rendering component, the least hardware sensitive video rendering component, and &#8211; the most immediately important &#8211; the only way an SDK I am working with can deliver its video overlay.</p>
<p>So, there is no easy way to request a 3D enabled surface through a custom allocator-presenter, with a hook in the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390521%28v=vs.85%29.aspx">IVMRSurfaceAllocator::AllocateSurface</a> updating the allocation flags. It does not make much sense to replace the whole allocator-presenter either: while an earlier DirectShow/Windows SDK provides a decent base for custom allocator-presenter, it is going to eventually hit the same problems mentioned above. And you cannot blit from 3D surface into a plain offscreen surface either without getting <strong>E_FAIL</strong>.</p>
<p>What appears to still be possible is allocating an addition 3D enabled surface, such as within <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390446%28v=vs.85%29.aspx">IVMRImagePresenter::StartPresenting</a> and using it as a replacement surface within <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390445%28v=vs.85%29.aspx">IVMRImagePresenter::PresentImage</a>. Having a custom allocator-presenter receive video frame, you can blit the picture into 3D-enabled surface, do your thing and pass the updated <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd407392%28v=vs.85%29.aspx">VMRPRESENTATIONINFO</a> to default allocator-presenter so that it presents the additional update surface, not the original one.</p>
<p><span id="more-1335"></span></p>
<p><img class="alignnone size-full wp-image-1336" title="3D-enabled DirectDraw Surface with a Video Mixing Renderer through Custom Allocator-Presenter" src="http://alax.info/blog/wp-content/uploads/2012/02/Image001.png" alt="" width="576" height="423" /></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1335/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow SDK at Crime Scene Investigation Service</title>
		<link>http://alax.info/blog/1322</link>
		<comments>http://alax.info/blog/1322#comments</comments>
		<pubDate>Sun, 27 Nov 2011 11:03:46 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[amusing]]></category>
		<category><![CDATA[DirectShow]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1322</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1322" title="DirectShow SDK at Crime Scene Investigation Service"></a>According to CSI: Crime Scene Investigation, Season 06 Episode 13 (17:04), investigators are using snake scope camera with DirectShow AMCAP tool to present the captured image:]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1322" title="DirectShow SDK at Crime Scene Investigation Service"></a><p>According to <em>CSI: Crime Scene Investigation</em>, Season 06 Episode 13 (17:04), investigators are using snake scope camera with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd373424%28v=vs.85%29.aspx">DirectShow AMCAP</a> tool to present the captured image:</p>
<p><img class="alignnone size-full wp-image-1323" title="AmCap and CSI" src="http://alax.info/blog/wp-content/uploads/2011/11/csi.s06e13.rus_.eng_.dvdrip.novafilm.tv_.avi_snapshot_17.04_2011.11.27_12.57.05-2.jpg" alt="" width="624" height="352" /></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1322/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft DTV-DVD Video Decoder at High Resolutions</title>
		<link>http://alax.info/blog/1283</link>
		<comments>http://alax.info/blog/1283#comments</comments>
		<pubDate>Wed, 21 Sep 2011 20:51:23 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[H.264]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1283</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate. The component responsible for video decoding is Microsoft DTV-DVD Video &#8230;<p class="read-more"><a href="http://alax.info/blog/1283">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a><p>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate.</p>
<p>The component responsible for video decoding is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390679%28v=vs.85%29.aspx">Microsoft DTV-DVD Video Decoder</a> (also known as Microsoft MPEG-2 Video Decoder), available with DirectShow interface. It offers video decoding capabilities for video resolutions up to 1920&#215;1088 (Full HD), including DXVA version 2 mode. The decoder is a &#8220;preferred decoder&#8221; and is given a first chance to be taken when it comes for <a href="http://msdn.microsoft.com/en-us/library/dd390342%28v=VS.85%29.aspx">Intelligent Connect</a> to render a video stream.</p>
<p>Technology went ahead though, stepped behind 1920&#215;1088 in particular. Microsoft DTV-DVD Video Decoder DirectShow filter still remains the first take in H.264 video decoding, and what however is taking place &#8211; the decoder accepts the format (media type) which is clearly cannot decode, neither according to specification, nor in real life. As soon as pin connection succeeds, DirectShow is not trying to look for another decoder, which can truly decode the feed. Result: failure to decode video.</p>
<p><img class="alignnone size-full wp-image-1284" title="Incorrect Media Type on Microsoft DTV-DVD Decoder Output" src="http://alax.info/blog/wp-content/uploads/2011/09/Image001.png" alt="" width="1034" height="624" /></p>
<p>The problem takes place in a quite surprising way. Given 5 megapixel video (2560&#215;1592, H.264, Baseline profile, from <a href="http://en.wikipedia.org/wiki/RTSP">RTSP</a>-enabled IP camera), the decoder advertises 720&#215;480 NV12 output media type. While consuming input data, the decoder outputs nothing and keeps video window black.</p>
<p>It does not issue any filter graph events, no. The filter is persistent and works hard in assumption that a new piece of knowledge will come from Mars and provide new capabilities to start decoding video, or filter&#8217;s input will give up and provide a new <a href="http://en.wikipedia.org/wiki/Network_Abstraction_Layer#Parameter_Sets">SPS</a> to lower resolution down to something less complex.</p>
<p>Well then, so is this advanced technology yet to be discovered by science? It appears that no. CoreAVC Video Decoder, applied to the same H.264 video decodes it well and nice:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/09/Image002.png"><img class="alignnone size-large wp-image-1287" title="CoreAVC H.264 Video Decoder with 5 MP Video from StarDot SDH500BN IP Camera" src="http://alax.info/blog/wp-content/uploads/2011/09/Image002-505x600.png" alt="" width="505" height="600" /></a></p>
<p><span style="text-decoration: underline;">Update 2011-09-26</span>: According to Microsoft classification, this is <a href="http://connect.microsoft.com/VisualStudio/feedback/details/689926/dtv-dvd-video-decoder-directshow-filter-negotiates-decoding-at-high-resolutions-but-fails-to-actually-decode">a bug on a released product</a>. That is, if anyone is experiencing severe issues as a result of this behavior, one might need to contact Microsoft Support directly in search of a solution.</p>
<p>Actually, as resolutions over Full HD (1920&#215;1080) are not so much common at the moment, the issue side effects are not yet likely. Still moving on with time, I think the issues are likely to come up, without being severe though.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1283/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A tricky EVR bug was caught up: input pin may falsely report disconnected state</title>
		<link>http://alax.info/blog/1262</link>
		<comments>http://alax.info/blog/1262#comments</comments>
		<pubDate>Tue, 26 Jul 2011 17:13:38 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[evr]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1262</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1262" title="A tricky EVR bug was caught up: input pin may falsely report disconnected state"></a>Crime An application which builds a DirectShow graph unexpectedly started failing with VFW_E_NOT_CONNECTED (0&#215;80040209) error code. Scene The problem takes place during DirectShow graph building, yet in stopped state. Specific call which appeared to be giving out the error in &#8230;<p class="read-more"><a href="http://alax.info/blog/1262">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1262" title="A tricky EVR bug was caught up: input pin may falsely report disconnected state"></a><h4>Crime</h4>
<p>An application which builds a DirectShow graph unexpectedly started failing with VFW_E_NOT_CONNECTED (0&#215;80040209) error code.</p>
<h4>Scene</h4>
<p>The problem takes place during DirectShow graph building, yet in stopped state. Specific call which appeared to be giving out the error in first place appears to be EVR input pin&#8217;s <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin">IPin::ConnectionMediaType</a>, and the problem is also specific to <a href="http://msdn.microsoft.com/en-us/library/ms694916%28VS.85%29.aspx">Enhanced video Renderer</a> (Windows 7, but not necessarily only this version).</p>
<h4>Investigation</h4>
<p>The problem does not appear to be persistent. On the contrary, it is taking place for just a few milliseconds after pin connection. After the problem is gone, it does not seem to ever come up again unless the filter graph is built again from the beginning.</p>
<p>EVR pin connection is always reporting success, so the following error code stating <a href="http://msdn.microsoft.com/en-us/library/ms919477.aspx">VFW_E_NOT_CONNECTED</a> &#8220;The operation cannot be performed because the pins are not connected.&#8221; goes against documented behavior, and is thus a bug.</p>
<p>Depending on time between pin connection and media type polling, the call can reach EVR:</p>
<ul>
<li>before it starts showing the problem &#8211; stage A</li>
<li>at the time the call fails &#8211; stage B</li>
<li>after the failure time interval, when the call is successful from then on &#8211; stage C</li>
</ul>
<p>Thus, the problem is limited to specific use cases:</p>
<ul>
<li>the application should care about media type on EVR input</li>
<li>unexpected failure takes place when the call reaches in stage B</li>
<li>also found: the clipping window for the EVR has to belong to a non-primary monitor</li>
</ul>
<p>If an application keep polling for media type in a loop, the result may be about the following:</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #603000;">UINT</span> nStageA <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nStageB <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nStageC <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// [...]</span>
<span style="color: #800000; font-weight: bold;">for</span><span style="color: #808030;">(</span><span style="color: #800080;">;</span> <span style="color: #800080;">;</span> <span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    AM_MEDIA_TYPE MediaType<span style="color: #800080;">;</span>
    <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>MediaType<span style="color: #808030;">,</span> <span style="color: #800000; font-weight: bold;">sizeof</span> MediaType<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">const</span> HRESULT nConnectionMediaTypeResult <span style="color: #808030;">=</span> pInputPin<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>ConnectionMediaType<span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>MediaType<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>nConnectionMediaTypeResult<span style="color: #808030;">)</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>nStageB<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            nStageC<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
            <span style="color: #800000; font-weight: bold;">break</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span> <span style="color: #800000; font-weight: bold;">else</span>
            nStageA<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span> <span style="color: #800000; font-weight: bold;">else</span>
    <span style="color: #800080;">{</span>
        ATLASSERT<span style="color: #808030;">(</span>nConnectionMediaTypeResult <span style="color: #808030;">=</span><span style="color: #808030;">=</span> VFW_E_NOT_CONNECTED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        nStageB<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoTaskMemFree<span style="color: #808030;">(</span>MediaType<span style="color: #808030;">.</span>pbFormat<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>
<span style="color: #696969;">// [...]</span>
<span style="color: #603000;">CString</span> sMessage<span style="color: #800080;">;</span>
sMessage<span style="color: #808030;">.</span>Format<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Bingo!</span><span style="color: #0f69ff;">\r</span><span style="color: #0f69ff;">\n</span><span style="color: #0f69ff;">\r</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nStageA </span><span style="color: #0f69ff;">%d</span><span style="color: #0000e6;">, nStageB </span><span style="color: #0f69ff;">%d</span><span style="color: #0000e6;"> - 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0000e6;">, nStageC </span><span style="color: #0f69ff;">%d</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nStageA<span style="color: #808030;">,</span> nStageB<span style="color: #808030;">,</span> nResult<span style="color: #808030;">,</span> nStageC<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
AtlMessageBox<span style="color: #808030;">(</span>m_hWnd<span style="color: #808030;">,</span> <span style="color: #808030;">(</span><span style="color: #603000;">LPCTSTR</span><span style="color: #808030;">)</span> sMessage<span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Result</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> MB_ICONERROR<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p><img class="alignnone size-full wp-image-1263" title="EVR Input Pin IPin::ConnectedMediaType Stages" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0034.png" alt="" width="384" height="184" /></p>
<h5>Workaround</h5>
<p>An obvious straightforward workaround is to follow EVR connection with a wait for Stage B to pass, or timeout &#8211; whichever takes place first.</p>
<p>Also, <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin">vote for the bug on Microsoft Connect</a>.</p>
<h5>More Details</h5>
<p>Video renderer filter are notorious for re-agreeing media type and being fretful as for memory allocators and media types (for a good reason though!). So it makes sense to suggest that the problem takes place when the filter is doing something related, such as it starts background activity immediately after connection in order to discover upstream peer capabilities.</p>
<p>In order to possibly get details on this, it is possible to raise an exception as soon as Stage B is detected and take a look at thread states using a debugger. Indeed, on of the background threads is engaged in EVR reconnection activity:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0023.png"><img class="alignnone size-large wp-image-1264" title="EVR Background Thread State" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0023-800x429.png" alt="" width="620" height="332" /></a></p>
<p>Yes it does the reconnection, but nevertheless it is expected to do the things undercover and transparently, it still allows a failure on the outer API.</p>
<pre>     evr.dll!GetSourceRectFromMediaType() + 0x37 bytes    
     evr.dll!CEVRInputPin::CheckMediaType() + 0x81 bytes    
     evr.dll!CBasePin::ReceiveConnection() + 0x61 bytes    
     evr.dll!CEVRInputPin::ReceiveConnection() + 0x1fc2d bytes    
     quartz.dll!CBasePin::AttemptConnection() - 0x21 bytes    
     quartz.dll!CBasePin::TryMediaTypes() + 0x60 bytes    
     quartz.dll!CBasePin::AgreeMediaType() + 0x54 bytes    
     quartz.dll!CBasePin::Connect() + 0x46 bytes    
     quartz.dll!CFilterGraph::ConnectDirectInternal() + 0x83 bytes    
     quartz.dll!CFilterGraph::ConnectRecursively() + 0x2c bytes    
     quartz.dll!CFilterGraph::ConnectInternal() + 0xde bytes    
     quartz.dll!CFilterGraph::Connect() + 0x17 bytes    
     quartz.dll!CFGControl::WorkerDisplayChanged() + 0xf1 bytes    
     quartz.dll!CFGControl::CGraphWindow::OnReceiveMessage() + 0x2e2a bytes    
&gt;    quartz.dll!WndProc() + 0x3e bytes    
     user32.dll!_InternalCallWinProc@20() + 0x23 bytes    
     user32.dll!_UserCallWinProcCheckWow@32() + 0xb7 bytes    
     user32.dll!_DispatchMessageWorker@8() + 0xed bytes    
     user32.dll!_DispatchMessageW@4() + 0xf bytes    
     quartz.dll!ObjectThread() + 0x65 bytes</pre>
<p>A test Visual C++ .NET 2010 application <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/EvrInputPinConnectionBug">is available from SVN</a>. The code requires a media file, and refers to <em>352&#215;288 I420.avi</em>, which is included into ZIP file attached to <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin#details">MS Connect Feedback</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1262/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another VFW/DirectShow Pain in the Ass: picapmk4.dll</title>
		<link>http://alax.info/blog/1250</link>
		<comments>http://alax.info/blog/1250#comments</comments>
		<pubDate>Thu, 21 Jul 2011 13:05:33 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[codec]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[crapware]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[picapmk4]]></category>
		<category><![CDATA[vfw]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1250</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1250" title="Another VFW/DirectShow Pain in the Ass: picapmk4.dll"></a>A customer complained on video playback problems which had symptoms of software compatibility issue. At certain operation modes software froze leaving the only option to kill process and restart. I appeared that the system has a third party DLL installed, &#8230;<p class="read-more"><a href="http://alax.info/blog/1250">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1250" title="Another VFW/DirectShow Pain in the Ass: picapmk4.dll"></a><p>A customer complained on video playback problems which had symptoms of software compatibility issue. At certain operation modes software froze leaving the only option to kill process and restart.</p>
<p>I appeared that the system has a third party DLL installed, a new hero name&#8217;s &#8211; <strong>picapmk4.dll</strong>. The DLL registers itself as Video for Windows codec and is clearly indicating capabilities it does not really support.</p>
<p>The DLL itself has no indication of its source, no valid version info. Instead it has GPL v2 embedded, XviD logo and about box resource template showing up as &#8220;PMK4 Video Codec&#8221;.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0011.png"><img class="alignnone size-full wp-image-1251" title="XviD logo" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0011.png" alt="" width="468" height="211" /></a></p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0021.png"><img class="alignnone size-full wp-image-1252" title="PMK4 Video Codec" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0021.png" alt="" width="467" height="371" /></a></p>
<p>Looks like crapware, which is hostile to DirectShow environment, with possibly GPL compliance issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1250/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow App Mess: Google Video Chat vs. Skype</title>
		<link>http://alax.info/blog/1233</link>
		<comments>http://alax.info/blog/1233#comments</comments>
		<pubDate>Fri, 08 Jul 2011 15:26:06 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[crapware]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[skype]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1233</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1233" title="DirectShow App Mess: Google Video Chat vs. Skype"></a>Two widely popular applications, which use DirectShow API appeared to be locked in a combat: Google video chat is installing a plugin which registers artificial video capture sources &#8220;Google Camera Adapter 0&#8243; and &#8220;Google Camera Adapter 1&#8243;. As the application &#8230;<p class="read-more"><a href="http://alax.info/blog/1233">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1233" title="DirectShow App Mess: Google Video Chat vs. Skype"></a><p>Two widely popular applications, which use DirectShow API appeared to be locked in a combat: Google video chat is installing a plugin which registers artificial video capture sources &#8220;Google Camera Adapter 0&#8243; and &#8220;Google Camera Adapter 1&#8243;.</p>
<p>As the application does not announce any integration capabilities and is only using video for internal purposes for in-browser video, the approach with system-wide device registration is, well, questionable.</p>
<p><img class="alignnone size-full wp-image-1234" title="Google Chat DirectShow Video Sources" src="http://alax.info/blog/wp-content/uploads/2011/07/Image004.png" alt="" width="593" height="399" /></p>
<p><img class="alignnone size-full wp-image-1236" title="Video Capture Devices on AMCAP" src="http://alax.info/blog/wp-content/uploads/2011/07/Image001.png" alt="" width="655" height="557" /></p>
<p>No need to mention, that devices are not operational: they are giving ERROR_DLL_INIT_FAILED (Error 0x8007045A) as soon as you try to instantiate a filter in a DirectShow video capture enabled application.</p>
<p>In-browser Google Video Chat itself does work and shows video from &#8220;real&#8221; DirectShow devices, including such artificial as created by <a href="http://alax.info/blog/1216">IP Video Source</a> tool. Google developers prefer still to take data off the device and as soon as possible leave DirectShow domain, as their graph looks like:</p>
<p style="padding-left: 30px;">Video Capture Source -&gt; <a href="http://msdn.microsoft.com/en-us/library/dd377612%28VS.85%29.aspx">Smart Tee Filter</a> -&gt; <a href="http://msdn.microsoft.com/en-us/library/dd377544%28VS.85%29.aspx">Sample Grabber Filter</a> -&gt; <a href="http://msdn.microsoft.com/en-us/library/dd390934%28VS.85%29.aspx">Null Renderer Filter</a></p>
<p>While Google plugin developers might need some interprocess synchronization, as the plugin runs in a child &#8220;plugin container&#8221; process (plugin-container.exe), introduction of virtual video capture devices is not necessary, but is a plain garbage for the operating system and DirectShow environment.</p>
<p>For some reason, Google developers decided to introduce a special thing: they mirror captured video left-to right when it comes to showing picture capture locally. Well, quite possibly it starts a new era in video conferencing: one will not see a direct copy of video sent remotely, but instead he will be given a mirrored thing.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image005.png"><img class="alignnone size-large wp-image-1235" title="Mirrored Video on Google Video Chat" src="http://alax.info/blog/wp-content/uploads/2011/07/Image005-800x253.png" alt="" width="620" height="196" /></a></p>
<p>The curious part is, however, the effect the broken devices introduce to another popular software &#8211; Skype.</p>
<p><span id="more-1233"></span>As Skype is capable of video capturing from a DirectShow device, for video-enabled conferencing, it enumerates the available devices and definitely gets in touch with the aliens from Google planet, which are already known to be broken junk.</p>
<p>The outcome appears to be subject to chances, there are two possible outcomes and only one is such that is more or less good for a user:</p>
<ul>
<li>either, Skype shows other available devices and ignores Google adapters (while basically any reasonable DirectShow video capture device would still list those devices &#8211; after all they are registered as existing!)</li>
<li>or, Skype stumbles upon a broken thing, stops enumeration and show no video capture devices available at all! Since Skype does enumeration only once on startup, if it fails to discover devices a user needs to close Skype completely and start it again for another try with video hardware.</li>
</ul>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image002.png"><img class="alignnone size-medium wp-image-1237" title="Skype with No Cameras" src="http://alax.info/blog/wp-content/uploads/2011/07/Image002-320x273.png" alt="" width="320" height="273" /></a> <a href="http://alax.info/blog/wp-content/uploads/2011/07/Image003.png"><img class="alignnone size-medium wp-image-1238" title="Skype with non-Google Cameras" src="http://alax.info/blog/wp-content/uploads/2011/07/Image003-320x273.png" alt="" width="320" height="273" /></a></p>
<p>It appears that both applications have severe issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1233/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use your own video transformation DirectShow filter as an effect while playing back a file</title>
		<link>http://alax.info/blog/1175</link>
		<comments>http://alax.info/blog/1175#comments</comments>
		<pubDate>Fri, 11 Mar 2011 23:34:31 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Source]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1175</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1175" title="How to use your own video transformation DirectShow filter as an effect while playing back a file"></a>One of the popular questions asked in relation to DirectShow filters, and also a popular task is to modify video stream while in playback. There are various reasons one might need to do it, including keying video to replace color/range, &#8230;<p class="read-more"><a href="http://alax.info/blog/1175">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1175" title="How to use your own video transformation DirectShow filter as an effect while playing back a file"></a><p>One of the popular questions asked in relation to DirectShow filters, and also a popular task is to modify video stream while in playback. There are various reasons one might need to do it, including keying video to replace color/range, or apply text or time code on top of video, including while re-compressing footage, adjust brightness or contrast.</p>
<p>DirectShow BaseClasses/SDK include samples (in most cases <a href="http://msdn.microsoft.com/en-us/library/dd375634%28VS.85%29.aspx">EzRGB24</a> sample is the best to start for a video effect, also demonstrates use of private interface on a filter) to quick-start with the task without getting too much into detail and once this part is done, next step is to integrate filter into playback, connect it with other filters.</p>
<p>As a result of DircetShowflexibility, there are ways to do things not so good, while still being under impression of keeping right track.</p>
<p>File playback is one of the basic tasks with DirectShow. To play a file, one creates a filter graph using powerful helpers provided by <a href="http://msdn.microsoft.com/en-us/library/dd375786%28VS.85%29.aspx">Filter Graph Manager</a> object. It might be a actually a single call <a href="http://msdn.microsoft.com/en-us/library/dd390090%28VS.85%29.aspx">IGraphBuilder::RenderFile</a> which takes all the complexity of finding matching filters, connecting them together, dealing with splitters and renderers, video and audio. A single call resolves the problems in a convenient way &#8211; easy.</p>
<p>Still a simple thing of inserting your own video transformation filters breaks the simplicity. One needs to build the graph partilly, insert the effect and complete building, or build the thing and break in with a new filter. How to find insertion point? Will the other filters like intrusion? Different file types and formats.</p>
<p>There is an easy and elegant solution to pre-add your own effect filter into graph and start rendering a file from there. Sounds reasonable and sometimes works. The problem is however that it does not work always, and you never know when it lets you down. The graph might be build and the effect filter is never taken and is left orphaned aside of playback pipeline.</p>
<p>Reliable graph building assumes you are in control over building steps and allow only the level of flexibility required to connect and build parts &#8211; and this is where <a href="http://msdn.microsoft.com/en-us/library/dd390342%28VS.85%29.aspx">Intelligent Connect</a> is still a powerful helper. With an effect, the parts are &#8220;before the effect&#8221; and &#8220;after the effect&#8221;. RenderFile is no longer an option, and one has to dive deeper into graph building API.</p>
<p>First of all, the building starts with the file itself: unlike RenderFile, <a href="http://msdn.microsoft.com/en-us/library/dd390087%28VS.85%29.aspx">IGraphBuilder::AddSourceFilter</a> method adds just the first filter for a given file/format. It stops there and lets caller continue building as required. At this point, it is the right time to manually add effect filter with <a href="http://msdn.microsoft.com/en-us/library/dd390016%28VS.85%29.aspx">IFilterGraph::AddFilter</a> (IGraphBuilder is inherited from IFilterGraph and exposes the same method).</p>
<p>Having both ends in the graph for the &#8220;before the effect&#8221; part, intelligent connect can be used to connect and add filters required to make the connection. For an arbitrary file format, the task may be not trivial: depending on format and installed software components, the chain may look rather different. First, some filters combine stream splitting capability with immediate access to file (or another type of resource), others rely on joint operation of <a href="http://msdn.microsoft.com/en-us/library/dd375641%28VS.85%29.aspx">Async File Source</a> filter with a format-dependent splitter filter. Some expose elementary stream pins immediately, some provide transport stream pin.</p>
<p>There may be a few approaches as for addressing pin connection task (see also <a href="http://msdn.microsoft.com/en-us/library/dd375815%28VS.85%29.aspx">General Graph-Building Techniques</a> on MSDN). Straightforwardly, one might want to call <a href="http://msdn.microsoft.com/en-us/library/dd390088%28VS.85%29.aspx">IGraphBuilder::Connect</a> and take advantage of intelligent connect. Before this can be done, however it takes caller to select a pin of the obtained source filter to start from. There might be a few pins, including those exposing video formats, non-video formats and pre-split formats where video is behind depacketizing (demultiplexing). Considering variety of formats and support, it might make sense to make a first attempt finding a video pin (by enumerating pins and their media types, looking and <a href="http://msdn.microsoft.com/en-us/library/dd373477%28VS.85%29.aspx">AM_MEDIA_TYPE</a>::majortype and comparing to MEDIATYPE_Video) and, if not found, taking a first output pin of any type, or going through ping trying to connect first one which succeeds in connection.</p>
<p>An alternate approach is to take advantage of a helper object: <a href="http://msdn.microsoft.com/en-us/library/ms779896%28VS.85%29.aspx">Capture Graph Builder</a>. While originally it is intended to help capture graph building, it contains useful methods for general building and connecting pins. It does not own a graph itself: it is designed to operate on top of existing graph, provided by its owner. So one need to provide its existing graph and call helper methods for easy graph building. One of the methods is <a href="http://msdn.microsoft.com/en-us/library/ms784859%28VS.85%29.aspx">ICaptureGraphBuilder2::RenderStream</a>, which connects pins of given filters. Unlike API discussed earlier, it takes filter interfaces on input and will be responsible for finding proper pins itself, which might be a good idea if you don&#8217;t want to bother yourself doing it. To specify the requested task, it takes media type argument, which in this case might be video or, if fails, any type provided that video media type will still be anyway checked on input of effect filter.</p>
<p>Once the part &#8220;before the effect&#8221; is done, the other part may be completed as simple as calling <a href="http://msdn.microsoft.com/en-us/library/dd390089%28VS.85%29.aspx">IGraphBuilder::Render</a> on the output pin of the effect. This will correspond to final step of original RenderFile execution.</p>
<p>A tiny Visual Studio 2010 C++ project illustrates discussed techniques and it available at SVN repository: <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/RenderStreamTest01">RenderStreamTest01</a>:</p>
<ul>
<li>for a given media file in <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/RenderStreamTest01/RenderStreamTest01.cpp#ln109">line 109</a> the project will start graph building</li>
<li>a suitable replacement for a video effect filter will be a <a href="http://msdn.microsoft.com/en-us/library/dd377544%28VS.85%29.aspx">Sample Grabber</a> filter initialized with a video type (24-bit RGB, but the <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/RenderStreamTest01/RenderStreamTest01.cpp#ln137">line 137</a> can be commented out)</li>
<li>switch in <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/RenderStreamTest01/RenderStreamTest01.cpp#ln109">line 147</a> switches between base Connect approach and Capture Graph Builder helper</li>
<li>while message box is on the screen and also showing building status, the graph can be looked at using <a href="http://msdn.microsoft.com/en-us/library/dd390950%28VS.85%29.aspx">Graph Edit</a> or similar tool, provided that <a href="http://alax.info/blog/777">DirectShow Spy</a> is installed; alternatively you might want to put the graph onto <a href="http://msdn.microsoft.com/en-us/library/ms694349%28VS.85%29.aspx">ROT</a> manually</li>
</ul>
<p>The project also illustrates a solution for recent problems referencing Sample Grabber with new SDK. Sample Grabber was obsoleted and removed from Window SDK definition file (qedit.h). In order to resolved the problem without using an older version of SDK, the definitions might be imported from type the corresponding library and (apart from used as such) copied into the source code directly, as in lines <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/RenderStreamTest01/RenderStreamTest01.cpp#ln13">13-60</a>.</p>
<p>See also on graph building:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/dd318197%28VS.85%29.aspx">Basic DirectShow Tasks</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd390342%28VS.85%29.aspx">Intelligent Connect</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd375815%28VS.85%29.aspx">General Graph-Building Techniques</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd387915%28VS.85%29.aspx">Connect Filters</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd318240%28VS.85%29.aspx">Using Capture Graph Builder</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1175/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow Spy: IAMFilterData interface</title>
		<link>http://alax.info/blog/1111</link>
		<comments>http://alax.info/blog/1111#comments</comments>
		<pubDate>Mon, 08 Feb 2010 18:47:28 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[mapper]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1111</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1111" title="DirectShow Spy: IAMFilterData interface"></a>This quick update for DirectShow Filter Graph Spy adds tracing for (deprecated) IAMFilterData interface, and also fixes problem with Media Player Classic &#8211; Home Cinema, when the player crashes in External Filters windows. Partial Visual C++ .NET 2008 source code &#8230;<p class="read-more"><a href="http://alax.info/blog/1111">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1111" title="DirectShow Spy: IAMFilterData interface"></a><p>This quick update for <a href="http://alax.info/blog/777">DirectShow Filter Graph Spy</a> adds tracing for (deprecated) <a href="http://msdn.microsoft.com/en-us/library/dd389369%28VS.85%29.aspx" rel="nofollow">IAMFilterData</a> interface, and also fixes problem with <a href="http://www.xvidvideo.ru/media-player-classic-home-cinema-x86-x64/">Media Player Classic &#8211; Home Cinema</a>, when the player <a href="http://alax.info/blog/1100/comment-page-1#comment-5738">crashes in External Filters windows</a>.</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="http://alax.info/blog/777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1111/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

