DirectShow IVideoWindow can't be wider than 4096px - c#

I have a C# application which uses DirectShow to show play video clips. We recently tried to play a video that is 9600x1080 px and it would not show. DirectShow emits events that everything.
We use K-Lite codec pack (1295) and utilise ffdshow libx264 as codec and video renderer. Media Player Classic using the same renderer can play the clip just fine. The latest version of our application use DirectShow.NET while the older versions call DirectShow interfaces directly. Both old and new versions of our application have the same issues.
After some experimentation we have found out the following:
If the video window width is 4096px or narrower it will render video. If it is 4097 or wider it will not render any video. We tried playing a HD-clip and a 720-clip with the same results. They will play when the video window is 4096x1080 but not when the window is 4097x1080 or wider.
When changing resolution or graphic settings there are some flashes (a few frames) of the video when the settings is applied, so that would suggest that it is in fact playing the video but it displays only black.
Tested on Windows 10, 64 bit.
Any ideas of what the we can do to fix this?

The essential part is the video renderer you are using. Even though you did not mention, it is likely that you just use the defaults and this is a VMR-7 in windowed mode. This gets you an aged legacy component with limitations you are hitting.
You are interested in updating your application to use EVR.
Choosing the Right Video Renderer
[…]
In Windows Vista and later, applications should use the EVR if the hardware supports it.
[…] methods use the VMR-7 by default. […] The EVR and VMR-9 are never the default renderers.

Related

How to take high quality photo from integrated camera in WPF

I'm implementing WPF app where I need to take high quality photos from integrated camera. So far I've been successful with capturing video and taking frames from it (described for example here: Wpf and C # capture webcam and network cameras).
But this is not what I want - because video frame quality is not so great. I have MS Surface 4 Pro which has 8Mpx camera with full HD video support and with the above method I'm able to just get full HD frame from it. But I would like to have full 8Mpx picture, like it is possible to take in the native Windows Camera app.
In UWP I would probably have been successful with CameraCaptureUI class, but I didn't find any clues for WPF.
Does anyone has an idea how this could be implemented?
I've found out that XAML Islands do work with .NET Framework 4.8. So I've been able to implement a WPF solution using UWP components MediaCapture and CaptureElement. With that I can take photos with full resolution which was my goal.
Simple sample project can be found here: https://github.com/ondrasvoboda/WPFCamera, consider it just as a proof of concept.
If your app will run on Windows 10 or above, you can now use most of the APIs from Windows 10 in a WPF application.
https://blogs.windows.com/windowsdeveloper/2019/04/30/calling-windows-10-apis-from-a-desktop-application-just-got-easier/

DirectShow Virtual Camera does not appear in the list on some configurations

I'm using DirectShow filter as virtual camera (CLSID_VideoInputDeviceCategory). It's working good but some apps/configurations do not display this feed as source. For example on win 8.1 I can see this source in Chrome/Firefox via webrtc. But in win 10 - chrome does not show this source in the list (but FF does). Also adobe flash does not show it in the list everywhere. What is important for me now is to make it available on win 10 /chrome. What may affect on this and how to fix it?
Update
Looks like there are two different sets of filters for x86 and x64. So the poblem with chrome was caused by different architecture. But flash still not detect camera.
DirectShow virtual cameras are only visible to same bitness applications, which consume video capture using DirectShow (or, in some cases, Video for Windows). If you have a bitness problem, you can fix it by building/registering virtual camera for respective bitness. If the application consumes video using Media Foundation, the virtual DirectShow camera won't bee seen/accessible. Applicability of Virtual DirectShow Sources blog post explains this a bit further and with a picture.
Firefox is supposedly using DirectShow, so it might be a bitness problem.
Another problem might be related to Windows 10 Anniversary Update, which changed behavior of DirectShow sources. You might want to apply a registry fix mentioned here to see if it restores the earlier behavior (to find out whether the experienced issue is related to Anniversary Update changes).

K-lite Codec crashing issue

I have a C# windows form application in which I am playing videos one by one using WMP activex object and WPF MediaElement (I have included it using element host into windows forms). When application starts user selects either WMP or Media Element to play the videos. Then application starts the playing videos one by one from predefined local directory.
The video formats are almost all the leading formats like wmv, avi, mpg, mpeg, mp4, mkv, flv, mov, vob, 3gp. I am using K-lite codecs full pack so that all these formats can play in the player.
Now, the problem is that after installing the k-lite and my application everything works perfectly (All videos plays perfectly). But after sometime some videos stops playing in both the components. At that time I checked whether it plays in actual (native) windows media player or not but it does not play in it also. Then if I uninstalls the K-lite and installs it again, video starts playing both in my application as well as native WM Player. This behavior happens again after some time.
The time after it happens can be anything between hours to days and every time it happens with different video formats. Also I checked it with different hardware and the behavior is same. What could be this problem? Is it a components (WMP activex and Media element) problem? Is it really that codecs crashing issue? or is this issue of codecs conflict with graphics driver?
Also, I have disabled the hardware acceleration in registry.
Also, one thing I forgot to tell is that this screen
Apart from the K-lite codecs this is also a case. I don't understand why my WMP settings are getting lost and it asking me to do it again and again although I have kept windows updates off.
Thanks.

Dynamically increasing/decreasing speed of a video in a windows forms application

I'm building a Windows Forms application in VS 2010 that smoothly increases or decreases the speed of a video playing back based on the speed of the user input.
I've tried several avenues..
1.) Using the AudioVideoPlayback DirectX class - I set the speed of the video, by setting the current position of the video, based on a timer.. and increased or decreased that value based on user input. While this worked on my PC, it lags a lot on our lower end target PC's. Can anyone think of a more efficient way to increase/decrease the speed of playback using this class?
2.) I've tried the Windows Media Player ActiveX control, and tried setting the rate/position dynamically, but this is extremely jumpy and laggy even on my development PC
3.) I've tried the Apple QuickTime Control 2.0 COM Component that comes with VS 2010, and it's also very laggy.
4.) I'm trying to figure out how to set the speed on the Shockwave Flash Object control, but haven't found that out yet
Can anyone suggest other avenues to explore? I just need to be able to increase/decrease the speed of video playback smoothly based on user input without lag. I don't care what format the video needs to be in, all videos can be converted to the required format.
Any help/ideas will be appreciated.
Thanks
The ultimate way is to decode the Bitmaps from videos, and handle the frames yourself.
Try the CaptureNET example from DirectShow.NET. It allows you to capture bitmaps from each frame. After that, write your own playback control to handle the refresh rate.
After trying many different formats/libraries and components I found the VLC Media Player ActiveX control to be the most efficient method to slow down/speed up video without any noticeable lag.

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

Categories