<?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>Fri, 03 Feb 2012 22:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>
		<item>
		<title>DirectShow Spy: Filter Mapper Spy</title>
		<link>http://alax.info/blog/1100</link>
		<comments>http://alax.info/blog/1100#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:07:50 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></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=1100</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1100" title="DirectShow Spy: Filter Mapper Spy"></a>DirectShow Filter Graph Spy was updated to add new functionality: spying over another DirectShow object &#8211; Filter Mapper. Filter Mapper object is used for filter registration purposes and also internally by DirectShow&#8217;s Intelligent Connect. IFilterMapper2 interface traces provide detailed description &#8230;<p class="read-more"><a href="http://alax.info/blog/1100">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1100" title="DirectShow Spy: Filter Mapper Spy"></a><p><a href="http://alax.info/blog/777">DirectShow Filter Graph Spy</a> was updated to add new functionality: spying over another DirectShow object &#8211; <a href="http://msdn.microsoft.com/en-us/library/dd375788%28VS.85%29.aspx">Filter Mapper</a>. Filter Mapper object is used for filter registration purposes and also internally by DirectShow&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ms940065.aspx">Intelligent Connect</a>. <a href="http://msdn.microsoft.com/en-us/library/dd390033%28VS.85%29.aspx">IFilterMapper2</a> interface traces provide detailed description on steps DirectShow takes in order to connect and/or render filter pins. For example when trying to render <em>MEDIATYPE_Audio</em> pin, Filter Mapper suggested &#8220;RDP DShow Redirection Filter&#8221; and, then, &#8220;Default DirectSound Device&#8221;:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">186</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> nFlags 0x0<span style="color: #808030;">,</span> bExactMatch <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nMinimalMerit 0x00200001<span style="color: #808030;">,</span> bInputNeeded <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> nInputTypeCount <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> pInputPinCategory NULL<span style="color: #808030;">,</span> bRender <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> bOutputNeeded <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nOutputTypeCount <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> pOutputPinCategory NULL
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">191</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> nInputTypeIndex <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> MajorType <span style="color: #808030;">{</span><span style="color: #008c00;">73647561</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0010</span><span style="color: #808030;">-</span><span style="color: #008c00;">8000</span><span style="color: #808030;">-</span>00AA00389B71<span style="color: #808030;">}</span><span style="color: #808030;">,</span> Subtype <span style="color: #808030;">{</span><span style="color: #008c00;">00000000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">000000000000</span><span style="color: #808030;">}</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">212</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> pMoniker @device<span style="color: #808030;">:</span>sw<span style="color: #808030;">:</span><span style="color: #808030;">{</span>083863F1<span style="color: #808030;">-</span>70DE<span style="color: #808030;">-</span>11D0<span style="color: #808030;">-</span>BD40<span style="color: #808030;">-</span>00A0C911CE86<span style="color: #808030;">}</span><span style="color: #808030;">\</span><span style="color: #808030;">{</span>AB9D6472<span style="color: #808030;">-</span>752F<span style="color: #808030;">-</span>43F6<span style="color: #808030;">-</span>B29E<span style="color: #808030;">-</span>61207BDA8E06<span style="color: #808030;">}</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">220</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> sFriendlyName <span style="color: #800000;">"</span><span style="color: #0000e6;">RDP DShow Redirection Filter</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDescription <span style="color: #800000;">"</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDevicePath <span style="color: #800000;">"</span><span style="color: #800000;">"</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">212</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> pMoniker @device<span style="color: #808030;">:</span>cm<span style="color: #808030;">:</span><span style="color: #808030;">{</span>E0F158E1<span style="color: #808030;">-</span>CB04<span style="color: #808030;">-</span>11D0<span style="color: #808030;">-</span>BD4E<span style="color: #808030;">-</span>00A0C911CE86<span style="color: #808030;">}</span><span style="color: #808030;">\</span>Default DirectSound Device
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">220</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> sFriendlyName <span style="color: #800000;">"</span><span style="color: #0000e6;">Default DirectSound Device</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDescription <span style="color: #800000;">"</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDevicePath <span style="color: #800000;">"</span><span style="color: #800000;">"</span></pre>
<p>Important is that DirectShow&#8217;s internals are using the mapper through COM instantiation and this provides a safe method to override default behavior process wide in order to, for example, extend <a href="http://msdn.microsoft.com/en-us/library/ms940065.aspx">Intelligent Connect</a> functionality onto custom, unregistered globally, private filters.</p>
<p>Also, the binary is renamed from FilterGraphSpy.dll to DirectShowSpy.dll.</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="./777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1100/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>How to use windowless Video Mixing Renderer Filter to show video fullscreen</title>
		<link>http://alax.info/blog/1082</link>
		<comments>http://alax.info/blog/1082#comments</comments>
		<pubDate>Fri, 09 Oct 2009 17:04:27 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[IVideoWidow]]></category>
		<category><![CDATA[IVMRWindowlessControl]]></category>
		<category><![CDATA[renderer]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[VMR]]></category>
		<category><![CDATA[windowless]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1082</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1082" title="How to use windowless Video Mixing Renderer Filter to show video fullscreen"></a>The question is being asked from time to time. Everyone knows what is full screen video. Video renderers implement full screen capability since long ago through their IVideoWindow::put_FullScreenMode property, and even Filter Graph Manager exposes its own IVideoWindow interface to &#8230;<p class="read-more"><a href="http://alax.info/blog/1082">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1082" title="How to use windowless Video Mixing Renderer Filter to show video fullscreen"></a><p>The question is being asked from time to time. Everyone knows what is full screen video. Video renderers implement full screen capability since long ago through their <a href="http://msdn.microsoft.com/en-us/library/dd377320(VS.85).aspx">IVideoWindow::put_FullScreenMode</a> property, and even <a href="http://msdn.microsoft.com/en-us/library/dd375786(VS.85).aspx">Filter Graph Manager</a> exposes its own <a href="http://msdn.microsoft.com/en-us/library/dd377276%28VS.85%29.aspx">IVideoWindow</a> interface to forward calls to filter&#8217;s implementation of <a href="http://msdn.microsoft.com/en-us/library/dd377276%28VS.85%29.aspx">IVideoWindow</a> interface.</p>
<p>However, for Video Mixing Renderers, version <a href="http://msdn.microsoft.com/en-us/library/dd407343(VS.85).aspx">7</a> and <a href="http://msdn.microsoft.com/en-us/library/dd407344%28VS.85%29.aspx">9</a>, the preferred and recommended mode is windowless, where no IVideoWindow interface is available.</p>
<blockquote><p><strong>Note</strong> The <a id="ctl00_MTCS_main_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/dd390536%28VS.85%29.aspx"><strong>IVMRWindowlessControl</strong></a> or <a id="ctl00_MTCS_main_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/dd390537%28VS.85%29.aspx"><strong>IVMRWindowlessControl9</strong></a> interface is now preferred over <strong>IVideoWindow</strong>. For more information, see <a id="ctl00_MTCS_main_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/dd407299%28VS.85%29.aspx">Using Windowless Mode</a>.</p></blockquote>
<p>So in order to implement full screen mode it takes the application to attach Video Mixing Renderer filter to a private frameless window, to its entire client area and expand the window to entire monitor area.</p>
<p>The sample project <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01">FullScreenWindowlessVmrSample01</a> is illustrating this technique.</p>
<p><img class="alignnone size-full wp-image-1083" title="FullScreenWindowlessVmrSample01 Main Dialog" src="http://alax.info/blog/wp-content/uploads/2009/10/09-Image001.png" alt="FullScreenWindowlessVmrSample01 Main Dialog" width="489" height="141" /></p>
<p><span id="more-1082"></span>Main application dialog owns a special window to host renderer, implemented by CRendererDialog class.</p>
<pre>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;"><span style="color: #800000; font-weight: bold;">class</span> CRendererDialog <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CDialogImpl<span style="color: #800080;">&lt;</span>CRendererDialog<span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span>
<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>

    <span style="color: #800000; font-weight: bold;">enum</span> <span style="color: #800080;">{</span> IDD <span style="color: #808030;">=</span> IDD_RENDERER <span style="color: #800080;">}</span><span style="color: #800080;">;</span>

BEGIN_MSG_MAP_EX<span style="color: #808030;">(</span>CRendererDialog<span style="color: #808030;">)</span>
    MSG_WM_INITDIALOG<span style="color: #808030;">(</span>OnInitDialog<span style="color: #808030;">)</span>
    MSG_WM_DESTROY<span style="color: #808030;">(</span>OnDestroy<span style="color: #808030;">)</span>
    MSG_WM_ERASEBKGND<span style="color: #808030;">(</span><span style="color: #400000;">OnEraseBkgnd</span><span style="color: #808030;">)</span>
    MSG_WM_PAINT<span style="color: #808030;">(</span>OnPaint<span style="color: #808030;">)</span>
    MSG_WM_DISPLAYCHANGE<span style="color: #808030;">(</span>OnDisplayChange<span style="color: #808030;">)</span>
    MSG_WM_KEYDOWN<span style="color: #808030;">(</span>OnKeyDown<span style="color: #808030;">)</span>
    COMMAND_ID_HANDLER_EX<span style="color: #808030;">(</span>IDCANCEL<span style="color: #808030;">,</span> OnCancel<span style="color: #808030;">)</span>
END_MSG_MAP<span style="color: #808030;">(</span><span style="color: #808030;">)</span>

<span style="color: #800000; font-weight: bold;">private</span><span style="color: #e34adc;">:</span>
    CMainDialog<span style="color: #808030;">&amp;</span> m_Owner<span style="color: #800080;">;</span>
<span style="color: #696969;">//...</span></pre>
</pre>
<p>The dialog template does not have a caption, it has no frame and has its window rectangle equal to client area. As a result, spanning the Video Mixing Renderer to the entire client area and proper positioning of the dialog window is showing video on the entire monitor.</p>
<pre>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">ATLVERIFY<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">.</span>Create<span style="color: #808030;">(</span>m_hWnd<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLVERIFY<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">.</span><span style="color: #400000;">MoveWindow</span><span style="color: #808030;">(</span>MonitorData<span style="color: #808030;">.</span>m_Position<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
m_RendererDialog<span style="color: #808030;">.</span><span style="color: #400000;">ShowWindow</span><span style="color: #808030;">(</span>SW_SHOWNORMAL<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// ...</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pVmrWindowlessControl<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>SetVideoClippingWindow<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pVmrWindowlessControl<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>SetVideoPosition<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> m_RendererDialog<span style="color: #808030;">.</span>GetVideoPosition<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
</pre>
<p>Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01/Release/FullScreenWindowlessVmrSample01.exe?format=raw">included</a>. The project is using ATL and <a href="http://wtl.sourceforge.net/">WTL</a> libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1082/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to dynamically change resolution for video preview</title>
		<link>http://alax.info/blog/1061</link>
		<comments>http://alax.info/blog/1061#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:28:08 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bridge]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[preview]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[resolution]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1061</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1061" title="How to dynamically change resolution for video preview"></a>From a conversation: Q: I am using Web camera with DirectShow. Camera has only capture pin, so I am looking for the best way to switch resolution on the pin while graph is running. I would like to keep preview &#8230;<p class="read-more"><a href="http://alax.info/blog/1061">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1061" title="How to dynamically change resolution for video preview"></a><p>From a conversation:</p>
<blockquote><p><span id=":1t8" dir="ltr">Q: I am using Web camera with DirectShow. </span>Camera has only capture pin, so I am looking for the best way to switch resolution on the pin while graph is running. I would like to keep preview with smaller image size and when i would like to capture an image i would like to switch to full resolution. I have to use sample grabber callback since i need access to single image to process them. Is there a way to do that without stopping and starting a graph? This works but very slow between captures.</p></blockquote>
<p><span id=":1sb" dir="ltr">Is it possible to just reconnect the sample grabber only with new media changes and then resume the graph? Currently i just kill the graph and start it again, but it takes few seconds to do so, so I am looking the way to reduce that time.</span></p>
<p><span id=":1rj" dir="ltr">There is no way to switch resolution on the running graph. There is a technique to dynamically start/stop individual filters and re-negotiate resolutions (media types), but it does not work for the majority of filters. </span><span id=":1rl" dir="ltr">Additionally to that <a href="http://msdn.microsoft.com/en-us/library/dd377544%28VS.85%29.aspx">Sample Grabber </a></span><a href="http://msdn.microsoft.com/en-us/library/dd377544%28VS.85%29.aspx"><span id=":1rl" dir="ltr">Filter</span></a><span id=":1rl" dir="ltr"><a href="http://msdn.microsoft.com/en-us/library/dd377544%28VS.85%29.aspx"></a> cannot change resolution too, as it passes data through.</span></p>
<p><span id=":1u4" dir="ltr">If you only have to use switched resolution for preview, you can use <a href="http://www.gdcl.co.uk/gjd.htm">Geraint&#8217;s</a> <a href="http://www.gdcl.co.uk/gmfbridge/index.htm">GMFBridge Toolkit</a> to join two graphs, and a filter that changes resolution. Combining all that you will have a running capture graph that [also] renders video to a bridge sink. </span>In the other graph you have another bridge sink that receives video from first graph and then you resize video to the resolution of interest already in the second graph. You can stop and reconfigure only second graph to update resolution and have first graph running and capturing. This is the best you can do, or just stop your single graph and change resolution this simple way.</p>
<p>So a solution, which is used by many, and I can recommend it too, is to use <span id=":1u4" dir="ltr"><a href="http://www.gdcl.co.uk/gmfbridge/index.htm">GMFBridge</a></span> bridging. Additionally, <span id=":1tv" dir="ltr">you can find questions and answers on it on <a href="http://social.msdn.microsoft.com/forums/en-US/windowsdirectshowdevelopment/threads/?filter=unread">MSDN DirectShow Development Forum</a> (search for &#8220;bridge&#8221; there). W</span><span id=":1tv" dir="ltr">ith a certain effort you can duplicate this with your own code but this is more or less ready to use solution and</span>, again, the key advantage you have that you have two graphs which you can top independently.</p>
<blockquote><p><span id=":1tc" dir="ltr">Would it be possible to use smart tee as a splitter on the capture pin, and then use two sample grabbers on capture and preview, one with smaller resolution and the other one with higher one?</span></p></blockquote>
<p><span id=":1tt" dir="ltr">With a <a href="http://msdn.microsoft.com/en-us/library/dd377612%28VS.85%29.aspx">Smart Tee Filter</a> you will still have 1 graph, so no individual resolution changes without stopping the graph. Additionally to that, Smart Tee Filter will deliver same frame on its output pins, so they will have to have one resolution and no resizing takes place inside.</span></p>
<blockquote><p><span dir="ltr">Also, </span><span id=":1sg" dir="ltr">is it possible to run 2 graphs in the same time? Same device, 2 graphs, 2 sample grabbers.</span></p></blockquote>
<p><span id=":1u8" dir="ltr">Most likely no, for only one reason: you won&#8217;t be able to have two running filters for the same device, as source filter will exclusively lock the device.</span><span dir="ltr"> </span> <span id=":1tf" dir="ltr">So capture filter will be a single filter. You can use <a href="http://msdn.microsoft.com/en-us/library/dd390336%28VS.85%29.aspx">Infinite Tee Pin Filter</a> to split stream between 2+ processing lines. And you can use the same bridge to pass data into another graph for further processing.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1061/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

