WPF count the number of frames in a video C# - c#

I would like to count to total number frames in a video after the mediaelement opens. The MediaElement.RenderedFramesPerSecondProperty does not work, when I do this I get an error saying; "System.Windows.Controls.MediaElement does not contain definition for RenderedFramesPerSecondProperty".
I am using MediaElement in WPF to play the video.
Thanks!

As per my knowledge there is no way I suppose.
Try with this link to dig in more.
I checked out more and found this solution -
Microsoft provides a free diagnostic tool that will tell you the frame rate at which WPF is updating the screen? I guess if you're not convinced you're getting the framerate you're asking for, then perhaps you might not trust it, but I've found it to be a reliable tool. It's called Perforator, and it's part of the WPF Performance Suite, which you can get by following the instructions here: http://msdn.microsoft.com/library/aa969767
Hope this helps you.

Related

Taking pictures and recording multimedia files from WPF-application

we are in need of a way to record videos with sound and taking pictures inside a WPF-application. It should be able to save locally to disk. Preferably it should be able to show the content once it is saved as well, but if no such component exists, we will use another component for the playback.
I've looked around and found no real good options to do this. Some options lack the sound recording in videos, and some are just too old to get working properly (WPF has had a long run so far...)
Does anyone here has any experience in this specific area?
Got Taking Pictures and Videos working with this little documentation https://www.codeproject.com/Articles/330177/Yet-another-Web-Camera-control
If you dont tell us what problems exactly you got, or which code you already got, we can't really help.

Reading specific frames from video file with .NET (not necessarily in sequential order)

I have a .NET Winform application and i need to show specific frames of a video file. Frames aren't necessarily in sequential order and are loaded when the user moves a slider, or when the application fires some events. I tried the following things:
Using EmguCV (OpenCV Wrapper): The problem here is that when i use SetCaptureProperty (With CAP_PROP.CV_CAP_PROP_POS_FRAMES, AVI_RATIO or MSEC ) to sets capture's position, the position isn't seted correctly (I checked it using GetCaptureProperty next to the SetCaptureProperty instruction). So, the frame returned by QueryFrame isn't the needed frame.
Using WPF MediaElement with Clock driven behavior: I can set the position of the video at the place that i need. The problem is that i don't know how get only one frame of the video sequence. By default, i have the Clock controller paused. When I set the position, If I call Clock.Controller.Resume(), then the video start playing from here. If I don't call Clock.Controller.Resume(), or if i call Clock.Controller.Resume() and then Clock.Controller.Pause() nothing is happening.
Im looking for another video library that can be used for accomplish this work, but i am not sure about what could be used. Any idea?
Thanks a lot for all comunity members, not only for help with this answer, but for the very big help that you give me with my problems every day. Iam new, but i would try to return these helping others with your problems.
Sorry for my terrible english! (Im spanish speaker and english speaking is not my best quality :S)

DirectShow DVD manipulation and capturing

I am new to DirectShow.
My intention was to develope a small application (C#) that handles video processing.
The main tasks i need are :
1 - Display video content from a DVD.
2 - Navigate to specific points of time in the video.
3 - Capture specific frames into still images and save them to files.
Sounded easy at first, but after reading thousands of blogs, forums and code samples i can't figure out how this can be done .
I am pretty sure these tasks have been implemented plenty of times, so if anyone has anything that can help i would be very happy to hear it.
As i am getting desperate on this issue, buying external DLLs or paying for some advice is an option.
Thanks.
Not sure if this will help, but I have a DvdPlayerElement control in my WPF MediaKit.
You must install an audio codec if you want audio as the built in one with Windows is locked down due to licensing.
perhaps you can wrap the MSVidWebDVD object, combined with some screen capture techniques [?] see also Extract frame from VOB(DVD) file
Thanks Jeremiah, I do know WPF MediaKit and tried working with it.
It is pretty cool, but does not allow all of the functionality available in DirectShow.
There are some events missing and the seeking operation does not seem to work for me.
I guess i can dig in the code and figure it out, but the time pressure won't allow it.
If you have an example of an application that accomplishes what i am looking for (display, seek, capture) i would be very happy to take a look.
Thanks again.

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

Using webcam's button in my own program

My webcam has a button, with which you take a photo of current frame
when using it's original software what came with it when I bought it.
Is there any way to use that button to take photos in my program.
I would be using C#.
I was thinking of using Windows Image Acquisition (WIA) or avicap32
for using webcam in my software.
Any help would be appreciated. Where do I start?
EDIT:
I see that you didn't understand me. I need to know if my phisycal camera button is pressed.
I am using DigiMicro 1.3 camera (Manufacturer is DNT), which isn't really a webcam but a USB microscope, but
it behaves like a webcam.
Does the camera actually require that the software be running when you press the button? I know some webcams implement this feature at the driver level. If that's the case, I don't think there's much you can do without interacting directly with the USB port, which would be incredibly difficult and likely not worth the trouble. I can't find any technical documentation on the vendor's website with that kind of information.
The "MicroCapture" software doesn't come with any DLLs that have exported functions, so P/Invoking doesn't appear to be an option. Unfortunately, I can't get the driver installed, so I can't check if it comes with any P/Invoke-able DLLs.
Sorry, but since there's no standard interface for that kind of functionality and the vendor doesn't provide any specific information on it, I don't think this is possible. I would suggest contacting DNT directly about it. They may have some component that will do what you need.
This Coding4Fun post guides you through pretty much everything you need to do to get started using WIA, including adding the reference to a project, displaying the select a device dialog, and of course actually taking the picture :P.
Coding4Fun - Look at me! Windows Image Acquisition
I suggest that you take a look at the DirectShow.NET library. It has great functionality for capturing images/videos off connected devices. It also comes with several samples to get you started quickly.

Categories