Alpha Channel Videos in WPF<p align=left><font face=Arial size=2></font> </p> <p>Is it possible to use the media element to play alpha channel videos in WPF ? Also how can I play .mov files or .swf in WPF. Is there an easy way to do this in WPF ?</p> <p align=left> </p> <p align=left>Adwait</p>© 2009 Microsoft Corporation. All rights reserved.Fri, 29 Aug 2008 18:01:50 Z0689e2b8-829e-4860-857b-b4755e0bc0e0http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#0689e2b8-829e-4860-857b-b4755e0bc0e0http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#0689e2b8-829e-4860-857b-b4755e0bc0e0Adwait Joshihttp://social.msdn.microsoft.com/Profile/en-US/?user=Adwait%20JoshiAlpha Channel Videos in WPF<p align=left><font face=Arial size=2></font> </p> <p>Is it possible to use the media element to play alpha channel videos in WPF ? Also how can I play .mov files or .swf in WPF. Is there an easy way to do this in WPF ?</p> <p align=left> </p> <p align=left>Adwait</p>Fri, 08 Feb 2008 13:30:45 Z2008-02-08T13:30:45Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#3d85b9a8-cbe6-424d-bab0-5b2c2f585d25http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#3d85b9a8-cbe6-424d-bab0-5b2c2f585d25Jeremiah Morrillhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeremiah%20MorrillAlpha Channel Videos in WPF<p>It's not possible for the media element to do alpha channels of video.  You could export your video to a png sequence (and write some code to play it) to honor the transparency, but that might not be feasible in all situations.</p> <p align=left> </p> <p align=left><font face=Arial size=2>To play .mov files, you just need the directshow filters to play them and MediaElement should then be compatible.  Maybe <a title="http://www.free-codecs.com/download/QuickTime_Alternative.htm" href="http://www.free-codecs.com/download/QuickTime_Alternative.htm">this will work.</a>  For flv files, you might want to try installing the <a title="http://ffdshow-tryout.sourceforge.net/" href="http://ffdshow-tryout.sourceforge.net/">ffdshow codec.</a></font></p> <p align=left> </p> <p align=left>As for swf files, you will have to embed the flash applet in your wpf app using something like HwndHost or WindowsFormsHost.  Or if yer feeling frisky, you can try using this <a title="http://www.codeplex.com/WPFWin32Renderer" href="http://www.codeplex.com/WPFWin32Renderer">http://www.codeplex.com/WPFWin32Renderer</a></p> <p align=left> </p> <p align=left>-Jer</p> <p align=left> </p> <p align=left>BTW - Those are 32bit codecs, so make sure your .NET app is compiled for x86, or else your app will not be able to load them on a 64bit os.</p>Fri, 08 Feb 2008 13:52:32 Z2008-02-08T13:52:32Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#6db9a917-acaf-4197-b2c2-a4186a322175http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#6db9a917-acaf-4197-b2c2-a4186a322175Adwait Joshihttp://social.msdn.microsoft.com/Profile/en-US/?user=Adwait%20JoshiAlpha Channel Videos in WPFSo is it fair to say that if I have these codes, I would just put a mov file in the media element and it should start playing ? I tried that but it did not play. Actually nothing played at all. <p align=left><font face=Arial size=2></font> </p>Fri, 08 Feb 2008 14:58:13 Z2008-02-08T14:58:13Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#481f45aa-9547-472d-b7b4-72329d70f9dehttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#481f45aa-9547-472d-b7b4-72329d70f9deJeremiah Morrillhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeremiah%20MorrillAlpha Channel Videos in WPFDo the mov files play fine in Windows Media Player?  Also, are you able to get any media file (like a WMV) to play via the MediaElement? <p align=left><font face=Arial size=2></font> </p>Fri, 08 Feb 2008 15:04:26 Z2008-02-08T15:04:26Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#4dfe4f5e-3d72-43f0-b10e-a20702c36a3dhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#4dfe4f5e-3d72-43f0-b10e-a20702c36a3dAdwait Joshihttp://social.msdn.microsoft.com/Profile/en-US/?user=Adwait%20JoshiAlpha Channel Videos in WPFYEs I am able to play .mov files in WPM and I am able to play wmv, mpg, avi files in the media element just not the mov. <p align=left><font face=Arial size=2></font> </p>Fri, 08 Feb 2008 15:08:34 Z2008-02-08T15:08:34Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#02ab7607-8d7b-4071-8408-da03e7701796http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#02ab7607-8d7b-4071-8408-da03e7701796Adwait Joshihttp://social.msdn.microsoft.com/Profile/en-US/?user=Adwait%20JoshiAlpha Channel Videos in WPFAny ideas how can I accomplish this ?<br>Sun, 10 Feb 2008 16:32:59 Z2008-02-10T16:32:59Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#07201f18-52ea-4f92-884e-bd611d678138http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#07201f18-52ea-4f92-884e-bd611d678138JakeSeehttp://social.msdn.microsoft.com/Profile/en-US/?user=JakeSeeAlpha Channel Videos in WPF I also want to alpha key my videos on MediaElement and I saw in the SP1 beta WPF demo something similar to that where the video (a volcano) was able to go transparent.<br><br>Can anyone confirm this please?<hr size="1" align="left" width="25%">Jake SeeThu, 05 Jun 2008 12:58:25 Z2008-06-05T12:58:25Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#e1e330ad-f6ce-4af0-910e-476200da01cbhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#e1e330ad-f6ce-4af0-910e-476200da01cbHunsoulhttp://social.msdn.microsoft.com/Profile/en-US/?user=HunsoulAlpha Channel Videos in WPF I'm interested in playing .mov and .mp4 with WPF.<br>Does anybody know how can I accomplish it?<br>It can play wmv but when I try to play a .mp4 it doesn't show anything. It's strange because the Blend designer shows the first frame of the .mp4 video in the mediaelement.<br><br>Waiting for an aswer...Tue, 05 Aug 2008 15:43:12 Z2008-08-05T15:43:12Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#317963f4-4742-4535-9561-88446f3cd1b0http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#317963f4-4742-4535-9561-88446f3cd1b0Brendan Clark - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Brendan%20Clark%20-%20MSFTAlpha Channel Videos in WPF<div class=quote><font class=quoteHeader>JakeSee said:</font> <p> I also want to alpha key my videos on MediaElement and I saw in the SP1 beta WPF demo something similar to that where the video (a volcano) was able to go transparent.<br><br>Can anyone confirm this please? <hr align=left width="25%" size=1> Jake See <p></p></div><br><br>The demo you are describing is using a new feature in 3.5 SP1 - custom ShaderEffects.  You can try this feature out with the 3.5 SP1 beta.  Greg Schecter's blog has a good introduction for how to author these Effects: <a href="http://blogs.msdn.com/greg_schechter/archive/2008/05/09/a-series-on-gpu-based-effects-for-wpf.aspx">http://blogs.msdn.com/greg_schechter/archive/2008/05/09/a-series-on-gpu-based-effects-for-wpf.aspx</a><br><br>Color-keying a video is fairly simple.  You need to write a pixel shader that takes one input (the color to remove), and then set the rgba values for pixels that color to zero.  Then, create a ShaderEffect class with that pixel shader.  To use it all you need to do is set yourMediaElement.Effect to an instance of your new class.Tue, 05 Aug 2008 20:15:43 Z2008-08-29T18:01:49Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#927e41d5-7c02-481b-989f-cf35e03bec81http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#927e41d5-7c02-481b-989f-cf35e03bec81snesnehttp://social.msdn.microsoft.com/Profile/en-US/?user=snesneAlpha Channel Videos in WPFI have written a shader that sets the alphavalue of a targetcolor to zero, as descriped in the above posting. The shader itself works, but the result is blended within the background color of the component that carries the mediaplayer. I thought about something like a 'bltmode' or so that is set to 'add' for default!? When setting the target pixel's color to black (rgb(0,0,0)) and the alpha value to 0, it works fairly nice.<br>Is there something like a 'bltmode' anywhere? I cannot find useful information about this issue.. I just want to use the media as an 'overlay', not as a blending component.<br><br>Here is my shader code:<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">sampler2D input : register(s0); </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">float4 transparentColor : register(c0); </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">bool</font><font style="font-size:11px"> equals(</font><font style="color:blue">float</font><font style="font-size:11px"> f1, </font><font style="color:blue">float</font><font style="font-size:11px"> f2) </font></td></tr><tr><td>{ </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">float</font><font style="font-size:11px"> f = abs(f1 - f2); </font></td></tr><tr><td>    <font style="color:blue">return</font><font style="font-size:11px"> f &lt; 0.0001f; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">} </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">float4 main(float2 uv : TEXCOORD) : COLOR </td></tr><tr><td>{    </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    float4 result = tex2D(input, uv);     </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">if</font><font style="font-size:11px">( (equals(result.r, transparentColor.r)) &amp;&amp; </font></td></tr><tr><td>        (equals(result.g, transparentColor.g)) &amp;&amp; </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        (equals(result.b, transparentColor.b)) ) </td></tr><tr><td>    { </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        result.r = 0; </td></tr><tr><td>        result.g = 0; </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        result.b = 0; </td></tr><tr><td>        result.a = 0; </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    } </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">return</font><font style="font-size:11px"> result; </font></td></tr><tr><td>} </td></tr></tbody></table></div><br>Fri, 29 Aug 2008 10:47:46 Z2008-08-29T10:47:46Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#8c7f7ca2-3537-410a-b4f3-71bf7dfc473ahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0689e2b8-829e-4860-857b-b4755e0bc0e0#8c7f7ca2-3537-410a-b4f3-71bf7dfc473aBrendan Clark - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Brendan%20Clark%20-%20MSFTAlpha Channel Videos in WPF<p>Yes, there was a mistake in my post, that's the shader I meant to describe :)  As far as your other question goes, everything in WPF alpha blends into the content behind it by design.  Supporting different blend modes is definitely something we're looking into for future versions.</p>Fri, 29 Aug 2008 18:01:10 Z2008-08-29T18:01:10Z