Interop.quartztypelib odd behavior - c#

I'm being annoyed by an odd behavior of Interop.quartztypelib in making media player with c#. With the help this link
http://www.codeproject.com/Articles/2632/DirectShow-MediaPlayer-in-C?msg=4853463#xx4853463xx
I created my own video player with Interop.quartztypelib. There's an important function for me to implement is that my application shall be able to capture the video image, just like you click "ALT" + "Printscreen" to make a screenshot of an active window in windows. But surprisingly I found that in the image captured by my application (I use
Graphics.CopyFromScreen
in my code), there's no video image on the video screen! I got the image of my form (the video player) but not the image of the video being played! And clicking "ALT" + "Printscreen" just gives me the same result!
I'm wondering if this Interop.quartztypelib doesn't support image capture. Anybody knows if there's a way to do settings to enable this? Thanks.

Printscreen doesn't do that
You need to implement some way of switching out of overlay, or some other way of getting a still. There is some trick with hardware acceleration, buts its not really applicable to you as the application dev. You're probably have to get antiquated with rendering api's.
For OpenGL api I think it would be glReadPixels.
For directX here's a SO question. I'm going to guess its directX in your case.

Related

Limit media player fullscreen to the bounds of my application

So a lot, if not most of all Media Players have a "fullscreen" mode. My application has a WebBrowser control and also an embedded Windows Media Player control. Now the problem here is that the fullscreen mode is literal. It actually covers my whole screen.
Is it possible to somehow modify the behavior of my application so that all "fullscreen" modes only stretches to the bounds of my application. Basically only "fullsceens" inside my application?
Any hints or suggestions are welcome!
Only idea that I could come up with it somehow fool windows thinking that my application is a monitor. But maybe that's taking it too far?
No way, sir.
"Full screen" is "full screen" and it is managed by OS to cover all the screen.
If you need to adapt the video size based on parameter you can't work on full screen.

c# Text over video

I've spent days googling and coding tryin to acheive the basic level of effect all media players have when showing fancy subtitles - that being text (optionally with outline/dropshadow/glow) written above a video (video being a videofile but would nice to also have option of being a videofeed eg webcam).
So far the only way I've managed to get anything over a video is either to write to a transparent picturebox above a video component which is aliased so has dodgy outline, or using the directshow.net library and the capture method from the dxtext example I have managed to actually write over a picturebox that is being spat frames of the video. The problem here is that as soona s I add the writing commands in (video plays to picturebox fine without it) then I get slight fps hit coming accross as marginal stuttering on the video.
Does noone have a way to just write/draw over a video without taking this kind of performance hit? Or am I going to have to resort to directx or something or just give up on this luxury? :/ I can paste any code needed for help but I think anyone with assistance will probably be the one wanting to post code!
TIA for any input, it's doing my head in D:

Make entire screen monochrome and other full screen effects

Does anyone know how to apply effects to the entire screen, in c# or any programming language.
I'm mostly interested in making the screen monochrome (specifically green-white instead of black white).
I know a cross-graphic card solution is possible because I found a program that can do it:
http://www.freedomscientific.com/products/lv/magic-bl-product-page.asp
Anyone knows how to accomplish something this or where to look?
Thanks !!
There is no easy Windows API to modify the entire screen contents. But this could be done at the device driver level.
Otherwise you have to resort to some Windows API tricks: place a "fake" window over the entire desktop, in a loop: grab the entire screen contents without grabbing fake window contents, do your processing to get the monochrome effect, then display that on the fake window. Yes, it's hacky and slow, but possible. Even more hacky, when you get mouse clicks to "go through" the fake window (lots of SetWindowsRgn calls).
So cross-platform here means using GDI, though some older DirectDraw APIs might work, in that case, you have a much easier time with hardware overlays (and better performance). Though I'm not sure how many cards actually support hardware overlays, and if newer versions of windows support the older DirectDraw APIs.
One more possibility is if the video card has a C# or C++ or C API, then you can do whatever you want with the card without writing device driver code.
Then there's CUDA, but I haven't yet tried that out. I know it's for stream processing on nVidia boards, but I wonder if it could get you an easy backdoor into the video display stuff.
To help people in the future who are interested in this:
This is possible with the Magnification API's color effect method. This allows one to use a matrix that can be applied to the whole screen.
NegativeScreen is an open source project that implements the feature you are describing in C#.
Unfortunately, this only works with affine transformations, as the API takes only an augmented matrices rather than a delegate or something.

DirectShow EVR resizing window problem

So I've been looking into the world of media playback for windows and I've started making a C# Media Player using DirectShow. I started off using the VRM-7 windowed video renderer and it was brilliant except it had a couple of small problems (multi monitors, fullscreen). But after some research I found that it's deprecated and I should be using VRM9.
So I changed it to use VRM9 windowless then found out that was an old post rofl >_< so finally I'm using Vista/Win7 (or XP .net 3) Enhanced Video Renderer (EVR) which is apparently the most up to date Microsoft video renderer and has all the flashy performance/quality things added to it. (tbh I haven't noticed any difference but maybe I need a blue-ray or HQ video to notice it).
With using EVR everything is working fine except resizing the video. Its really laggy/choppy/teary and probably something to do with its frame queueing mechanism.
To demonstrate my problem
open up windows media player classic.
View -> Options -> Playback -> output
Chose the "EVR" DirectShow Video renderer
Now restart wmp class and play a video, while it's playing click and drag a corner to resize it. You'll notice its horribly laggy. This is the exact same problem i am having.
But if you chose "EVR Custom Pres. **" or EVR Sync **" resizing works beautifully! So i tried googling around for anything about EVR resizing issues and how to fix it but i couldn't believe how little i could find. I'm guessing "Custom Pres." stands for "Custom Presenter" which sounds like they made their own.
Also you'll notice on the right hand size when you swap between EVR and the other EVR's the Resizer drop down on the right greys out.
So basically I wan't to know how I can fix this retarded resizing problem and is there any decent documentation out there? There is a fair bit for VMR7/9 but not much for EVR. I downloaded the DirectX SDK which apparently has samples but it was a waste of 500mb of bandwidth as it had nothing relevant.
Perhaps there is some way to force it not queueing up frames if that is the problem?
If you want code say the word and I'll paste some in. But it's really quite simple and nothing much happens, i'm convinced it's a problem with the EVR renderer.
EDIT: Oh and one other thing, what does VLC use? If you go into vlc options and change the renderer to anything but default, they all suck. So is it using VMR7? Or its own?
I need to write my own Custom Presenter, which from the looks of http://msdn.microsoft.com/en-us/library/bb530107(VS.85).aspx is a relatively big task.
Guess i'll look at the sample and try to go from there

C#: Creating a graphical screensaver

I am thinking about creating a screen saver. I have the whole thing, its graphics and the back-end kind of ready in my head. But I am not quite sure how to get the graphics out in code.
What I would like is a slide show of images with a bit of movement (kind of like the slide show in media center) and some floating text and shapes on top. The shapes somehow translucent.
I currently have a very simple static slideshow made in WinForms. Just a simple application that goes fullscreen and displays some images and pretends to fade them in and out in a hackish kind of way. But it is not very well made, and the performance is not very good. For example to prevent lag, I fade in a black square on top of the image, instead of fading in the actual image. Silly perhaps, but it kind of worked :p
Anyways, I would like to do a better job. But not sure where to start. Is WPF a good solution for this? Or should I look into DirectX or OpenGL? Is this something that could be handled well with XNA, or is that too game spesific?
WPF is not a bad idea. It takes advantage of DirectX and hardware acceleration for its animations and effects.
You will get better performance if you write this kind of stuff natively (against directx or opengl), but the cost of writing it will be much higher. It's quite possible you will not need that edge anyway.
Have a look at hanselman's baby smash (which is a full screen wpf app with animations) to get a grasp of what you can do with wpf.
Note: I did write a slide show kind of thingy in WPF way back, the key to getting this to work smoothly is loading up the images in a background thread and freezing it.
I guess XNA works well. There's a sample screensaver in C# Express, by the way.
Actually XNA works pretty well. For example: this is an (advanced) example of what can be made with XNA. The community is quite helpful and XNA has great potential.
A few weeks ago I wrote a two-part article describing how to create a Windows screen saver with GDI+. I am not displaying a slide show in my screen saver, but instead I am randomly drawing shapes. I did however explain the fundamentals of creating a screen saver for Windows which should be of some help if you have never created a screen saver before.
Create a Screen Saver Using C# – Part 1
Create a Screen Saver Using C# – Part 2
If you want to go with just GDI and GDI+, I wrote some info here about how to speed them up when rendering images and drawing them to screen. There is also fully functional screen saver source code at the above link (which I wrote myself after digging for some of the more obscure screen saver details), in case that helps.
Recently I finished with my first WPF (I wanted to see, how it can be done with WPF) screen-saver. You can check-it out on YouTube. Try to see HD-version.
Though I never tried XNA, I'm really pleased with WPF so far. Easy and flexible. But I guess you probably wouldn't get an XNA-performance (or am I wrong here?).
You can google for GDI+ or WPF ScreenSaver-templates to start with.

Categories