|
Sep
4
Written by:
Jeremiah Morrill
9/4/2008 6:11 AM
I'm notorious for showing off things before they are done. So keeping with my notoriety, I have decided to give a sneak preview of the WPF MediaKit. Keep in mind most things are largely untested. I don't restore a lost D3D Device just yet and don't expect the sample application to be pretty. I did spend a lot of time commenting everything, so it shouldn't be too bad to navigate. Right now I have two "example" controls, the MediaUriElement and the VideoCaptureElement. I just threw the VideoCaptureElement together very quickly, so hopefully it works off the bat. Ignore or turn off (in VS Debug options) the MDA LoaderLock "exceptions". These are not really exceptions! http://jmorrill.hjtcentral.com/portals/21/blog/files/wpfdshow.zip
Tags:
15 comment(s) so far...
Re: WPF MediaKit Preview
Your work is so cool -- as best I can, I've been following the evolution of VRE, D3DImage, and friends as I'm in the position of (1) needing a WPF-based video playback system for a proprietary codec and (2) not knowing anything about D3D or DirectShow.
I've got code that produces the frames as buffers of raw pixels. I'd be grateful if someone could point me to a simple example of how I can push those frames into the DirectShow system -- normally I can spend a few hours with the docs and scrape together something, but in this case I'm in over my head...
-mpg
By mpg on
9/4/2008 7:14 AM
|
Re: WPF MediaKit Preview
Hi mpg,
If you have code that already produces raw pixel buffers, the VRE doesn't require any DShow knowledge. I wrote it to be a high performance WriteableBitmap. You can simply initialize the VRE with your width/height/pixel format and pass the pixel buffer right to the VRE. It's synced with the WPF render thread, so you don't have to worry about Dispatchers.
DirectShow is actually pretty easy to use, but writing DirectShow filters is a lot more complicated and requires C++, COM, DShow and media knowledge. If you were to make your own "CODEC" for DShow, you'd probably want to make a "Source Filter". You can find a few examples on the internet or in the Windows SDK.
By Jeremiah Morrill on
9/4/2008 7:25 AM
|
Re: WPF MediaKit Preview
There are even tutorias on writing C# DirectShow filters out there -
http://www.codeproject.com/KB/directx/prototypingdsfilters.aspx http://www.informikon.com/directshow-tutorials/experimental-directshow-source-filter-in-c.html
They are not fast by any stretch of the imagination. But they let you poke at the innards of Filters untill you get comfortable writing them in C++.
By Adam Hill on
9/4/2008 8:38 AM
|
Re: WPF MediaKit Preview
Sometimes my video start playing, sometimes not, and when the file load it takes time (to long)... The videofiles works fine in WMP and in your last app (D3DImage VideoPlayer)!?
And what is it with "LoaderLock", whill this be permanent or can you solv that?
/Ken
By Ken on
9/4/2008 1:36 PM
|
Re: WPF MediaKit Preview
Mmm, okay I've got the VRE example all hacked up and going fine, pushing into it in-memory-buffers. Next question, possibly a dumb one: does VRE offer any support for frame rate control and such, or do I modify the "while (!m_endTest)" loop myself (e.g. I see a suspicious Sleep(33) call in there...).
By mpg on
9/4/2008 2:20 PM
|
Re: WPF MediaKit Preview
Ken,
That is odd. Do you have a link to a media file I can test with that you are seeing these issues on? The basic DShow code really hasn't been modified all that much, so hearing that is very puzzling. Also the LoaderLock thing is not caused by me, but by managed directx. I'll see if they have a newer version of MDX that doesn't have this. It's not a real problem, though some people perceive it to be.
By Jeremiah Morrill on
9/4/2008 4:41 PM
|
Re: WPF MediaKit Preview
mpg,
The VRE does not provide any method of timing as its just a WriteableBitmap conceptually. The Sleep()s are just in the sample code to simulate framerate control. You will have to roll your own. This is usually pretty simple if you have the sample times of each sample (frame).
-Jer
By Jeremiah Morrill on
9/4/2008 4:44 PM
|
Re: WPF MediaKit Preview
Ken,
Also try playing with the PreferedPositionFormat property of the MediaUriElement, maybe set with MediaTime. I have it set to Frame right now, maybe my frame seeking is screwing with your media type.
By Jeremiah Morrill on
9/4/2008 4:46 PM
|
Re: WPF MediaKit Preview
Jer-
I've got VRE hooked up now to my real frame decoder (w00t!), giving me a whopping 10fps for 1888x1062 frames. And I'm cool with controlling my own frame rate -- I get it now, thanks.
[There's still one lurking bug somewhere, though. Even with the original VRE example app, sometimes I get just a black screen when I hit one of the three buttons -- from the debugger, it looks like it's not making it into the GDIGraphicsLoop() function, for example. No errors appearing, though, apart from a first-chance InvalidDeploymentException arising from m_mediaElement->Play(), but I suspect that one is a red herring. Bug is not reproducible yet, but I suspect something to do with the build/config environment. I'll post if I figure it out.]
-mpg
By mpg on
9/5/2008 12:38 AM
|
Re: WPF MediaKit Preview
Your work is really amazing! The way you use Action delegates is great by the way, I always wanted to have an easier way to invoke short delegates...
I am developing a media center like application in WPF and currently I use WinForms interop to host the ActiveMovie window. This is quite a code mess, also routing mouse events correctly and DPI aware from WinForms to WPF has been much work. I cannot utilize the whole MediaKit because I do lots of advanced manual graph building stuff (using codec preferences, preloading files, selecting audio tracks, gathering codec information, etc). But I will try to add your WPF renderer to my project, so I can kick out all this annoying WinForms interop stuff which makes the application slow when resizing and prevents me from using overlayed WPF controls.
One question: Have you considered to make an EVR/WPF renderer usind D3DImage? The EVR renderer does deliver much smoother video compared to VMR solutions due to prebuffering of frames and more precise timing. Also, it uses DXVA2 hardware acceleration which allows to offload more decoding tasks to the GPU. It would be great to have these benefits in WPF also!
Lukas
By Lukas on
9/5/2008 5:39 AM
|
Re: WPF MediaKit Preview
Hi Lukas!
Yeah it was hard thinking up a decent object model for all these as there's so much you can do with directshow, that it's difficult covering all use cases. I tried to pick the most common stuff and abstract from there. You may want to just use a few classes or snippets from this library I'm making. Or you could probably just inherit from MediaElementBase/MediaPlayerBase and just add the functionality from there.
I have thought about using the EVR :) I left room for it in with the VideoRendererType enum. The main reason I started with VMR9 was that I already had some left over allocator code that was rotting from a while back. But it will be nice to be able to use both in WPF. And DXVA2 support will be sweet. I'd love to try out a blueray when I get that in there :)
By Jeremiah Morrill on
9/5/2008 6:09 AM
|
Re: WPF MediaKit Preview
I love this article , Very good collection of information,thanks.
By replica fendi scarf on on
1/5/2010 11:47 PM
|
|
ed hardy
ED Hardy Hoodies ED Hardy Hoodies Ed Hardy Swimwear Ed Hardy Swimwear ed hardy tops ed hardy tops ed hardy shoes ed hardy shoes ed hardy t shirt ed hardy t shirt ed hardy shirts ed hardy shirts christian audigier christian audigier ed hardy kids ed hardy kids Ed Hardy Sunglasses Ed Hardy Sunglasses ED Hardy belts ED Hardy belts ed hardy Bags ed hardy Bags ed hardy purse ed hardy purse ed hardy mens ed hardy mens ed hardy womens d hardy womens ed hardy mens shirts ed hardy mens shirts ed hardy mens tops ed hardy mens tops ed hardy mens hoodies d hardy mens hoodies ed hardy mens swim trunks ed hardy mens swim trunks ed hardy mens shoes ed hardy mens shoes ed hardy womens swimwear ed hardy womens swimwear ed hardy womens t shirt ed hardy womens t shirt ed hardy womens tops ed hardy womens tops ed hardy womens pants ed hardy womens pants ed hardy womens hoodies ed hardy womens hoodies ed hardy womens shoes ed hardy womens shoes ed hardy womens clothing ed hardy womens clothing
By ed hardy on
3/15/2010 9:23 PM
|
cheap nike shox
There are wide variety of Nike Shox for both men and women's selection.The Nike Shox Sale are best selling nowadays.Get your own Cheap Nike Shox now.It's definitely time for you to buy womens nike shox and wens nike shox, Wearing them will keep you in a perfect condition.
By nike shox on
3/16/2010 10:11 PM
|
|
|
|