質問する質問する
 

回答の候補Alpha Channel Videos in WPF

すべての返信

  • 2008年2月8日 13:52Jeremiah Morrill ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    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.

     

    To play .mov files, you just need the directshow filters to play them and MediaElement should then be compatible.  Maybe this will work.  For flv files, you might want to try installing the ffdshow codec.

     

    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 http://www.codeplex.com/WPFWin32Renderer

     

    -Jer

     

    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.

  • 2008年2月8日 14:58Adwait Joshi ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    So 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.

     

  • 2008年2月8日 15:04Jeremiah Morrill ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Do 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?

     

  • 2008年2月8日 15:08Adwait Joshi ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    YEs 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.

     

  • 2008年2月10日 16:32Adwait Joshi ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Any ideas how can I accomplish this ?
  • 2008年6月5日 12:58JakeSee ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
     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.

    Can anyone confirm this please?
    Jake See
  • 2008年8月5日 15:43Hunsoul ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    I'm interested in playing .mov and .mp4 with WPF.
    Does anybody know how can I accomplish it?
    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.

    Waiting for an aswer...
  • 2008年8月5日 20:15Brendan Clark - MSFT ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答の候補
    JakeSee said:

     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.

    Can anyone confirm this please?


    Jake See



    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: http://blogs.msdn.com/greg_schechter/archive/2008/05/09/a-series-on-gpu-based-effects-for-wpf.aspx

    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.
  • 2008年8月29日 10:47snesne ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     コードあり
    I 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.
    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.

    Here is my shader code:

    sampler2D input : register(s0); 
    float4 transparentColor : register(c0); 
     
    bool equals(float f1, float f2) 
        float f = abs(f1 - f2); 
        return f < 0.0001f; 
     
    float4 main(float2 uv : TEXCOORD) : COLOR 
    {    
        float4 result = tex2D(input, uv);     
     
        if( (equals(result.r, transparentColor.r)) && 
            (equals(result.g, transparentColor.g)) && 
            (equals(result.b, transparentColor.b)) ) 
        { 
            result.r = 0; 
            result.g = 0; 
            result.b = 0; 
            result.a = 0; 
        } 
         
        return result; 

  • 2008年8月29日 18:01Brendan Clark - MSFT ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    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.