Closed LazyCuteLion closed 7 years ago
yes,and the mov play in MediaUriEment,the alpha is not work, black instead of it.
Try:
D3DFMT_X8R8G8B8
to the D3DFMT_A8R8G8B8
in the Vmr9Allocator
. I'm facing the same problem, Cant view .mov video encoded using DVX3.
Tried both,
changed from "D3DFMT_X8R8G8B8" to "D3DFMT_A8R8G8B8" or Set VideoRenderer="EnhancedVideoRenderer"
The pixel is filled with RGB color (no alpha included) See Image.
It suppose to have only smoke from given image.
We should figure out if the problem is in the codecs or WPF MediaKit.
Hmmm, maybe it's because the codecs based on DirectShow. I exported the .mov file from Adobe Effect using quicktime.
But when I tried using HAP alpha from link exported as .avi file Same problem still happened. Not sure why It's doesn't recognize as rgba video.
General Complete name : ***\sample-1080p30-HapA.avi Format : AVI Format/Info : Audio Video Interleave File size : 105 MiB Duration : 10 s 0 ms Overall bit rate : 88.3 Mb/s Recorded date : 2014-03-26T09:47:17.00632 Writing application : Adobe After Effects CC (Windows) Video ID : 0 Format : Hap5 Codec ID : Hap5 Duration : 10 s 0 ms Bit rate : 88.3 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate : 30.000 FPS Bits/(Pixel*Frame) : 1.419 Time code of first frame : 00:00:00:00 / 00:00:00:00 Time code source : Adobe tc_A / Adobe tc_O Stream size : 105 MiB (100%)
Or maybe could you suggest file type that work with alpha? so I could give it a try. (If I can't figure it out then I have to write mask and then overlay into graph maybe) Thanks :)
Have you tried it with HAP codecs installed - and try to force the HAP codecs for the MediaUriElement in the MPC-HC - set it by VideoDecoder
?
As a workaround, you may export mov to animated PNG (APNG) and try normal WPF Image
for that.
If you decide to go with the color keying - I may change the MediaUriElement to have a property Effect for writing custom effect. (Or you may try the Effect
with the normal WPF MediaPlayer
).
I couldn't figure out how to force using specify decoder, There's no VideoDecoder attributes for MediaUriElement only found VideoRenderer.
Anyway, It'd be awesome to have alpha mask features so there will be video source and alpha mask source then composite, do overlay, or something later.
Try in the code: player.MediaUriPlayer.VideoDecoder = "..."
About the Effect
: you have to create own effect, probably BitmapEffect
or ShaderEffect
(see DeeperColor
in the WPF MediaKit source). Anyway, why do you cannot use WPF MediaPlayer
? IMO it should be possible to apply the effect for the MediaPlayer
, too.
I've do some research and it's said that LAVFilter could decode media with alpha but the alpha is ignored. Not sure if there's any alternative way.
Ps. My project cannot use color keying due to some part is half transparent.
On which part is the alpha ignored - in the LAVFilter or later by WPF-MediaKit somewhere?
If you have just certain transparency levels, like lets say 100%, 75%, 50%, then you may do color keying with three colors. If you have variable transparency, then it's not easily possible.
Note: some people use animated PNGs, e.g. see https://stackoverflow.com/a/8470614/254109
In the LAVFilter LINK
Some part is fading out while some part fading in. Quite hard using color keying.
My video is about 2-5 mins long. so it's take lots of memory to cache those image to playing in sequence while have to work with audio play/pause to sync with the image.
It's pitty LAVFilter cannot do alpha. Then I see just options:
Interesting, let me know, if setting MediaUriElement.Effect
is enough for you or if you need to access internal VideoImage.Effect
.
Okay just MediaUriElement.Effect works fine. Just to share the work around. Here's my fx file.
sampler2D input : register(s0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 color;
float2 pColor;
pColor.x = uv.x / 2; // Set position devided by 2 for RGB
pColor.y = uv.y;
color = tex2D(input , pColor.xy);
float4 mapColor;
float2 pMapColor;
pMapColor.x = 0.5 + (uv.x / 2); // Set position devided by 2 and shift to right side for Alpha (0.5 is for half of image position)
pMapColor.y = uv.y;
mapColor = tex2D(input, pMapColor.xy);
color.a = mapColor.r;
return color;
}
This one I'm using double size video from above which left is for rgb while right is for alpha.
Thanks for sharing the code. Closing the issue.
Do you have such mov? Have you tried it with WPF-MediaKit?