K-lite Codec crashing issue - c#

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.

Related

DirectShow IVideoWindow can't be wider than 4096px

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.

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.

Playing video in a .NET application

Lately, I've been trying to setup a media center PC. I've played around with all the common media center applications like XBMC, Plex, Boxee, and WMC. But all of them have one issue or another. So I was thinking about writing my own application from scratch.
My problem is I have no experience with developing software that plays media such as videos or music. I'm also not interested in spending a huge amount of time trying to figure this out, considering all the different file formats and codecs out there. I'm really more interested in developing the database and library interface for my application and reusing someone else's control or code for actually playing the media.
One option I was thinking was to just control an existing media player externally. So for example you may browse for a video to play in my application, and then when you hit play it would fire up VideoLAN or some other popular video player.
However, I was wondering if there was an easy way to play video inside a .NET application. I'm looking for something that is capable of playing a wide variety of formats such as MKV files, and DVD ISOs. I'm more experience with WinForms, but was also thinking about using this project as an opportunity to learn WPF.
i've spent many years looking at playing video under wpf.
The short answer
There is no easy way to guarantee to be able to play a variety of formats under wpf ( mkv,dvd etc etc ) or under windows for that matter.
the long answer
If you are looking just to run this at home and not release it, install all the codecs you need and most of the formats will run via mediaelement in wpf.
Getting all the codecs to cooperate can sometimes be frustrating.
Now moving into slightly harder territory.
if you want to play DVD then you need to replace mediaelement with wpfmediakit
http://wpfmediakit.codeplex.com/
wpfmediakit gives a base library to get access to the low level directshow functionality.
There is already a code base for playing DVDs based on wpfmediakit.
Now moving onto the very hard territory.
if you want to distribute your application and have users be able to "just watch" most/all media formats means you need to be able to completely control their codecs, which generally means distributing the codecs with your package and building the directshow filter graph in code rather than let windows build it.
The easiest way is to use the existing .Net hooks to Microsoft's standard MediaPlayer:
http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd562851%28v=vs.85%29.aspx
was trying myself a while ago for something to play media in winforms, and found out there is vlc wrappers for .Net, dunno how good they are as i gave up, but you can try
here is one them:
http://vlcdotnet.codeplex.com/
Thanks for all the great answers. But just found out that VLC can actually be controlled through HTTP. So I think I'm just going to use that to point an instance of VLC running with the HTTP interface at whatever file I want to play.

Making a video player training software

I am currently making a software that can be used to playback training packages. The features I want to add are:
Ability to read the time of videos
Ability to play and pause videos of various codecs (as bundled in Klite Codec Pack)
Ability to create a custom playlist file and continue from the last stop/pause of the playlist when opened
Generate a report of how the playlist was completed
I know very well how I am going to handle the last two parts but I need help on the first two. The current one simply has to launch the files using an external player on the system, and monitor the launched process for exit... but this is not quite what I want.
If WPF is an option you can use the <MediaElement/> for hosting the video in an application. Specifically you can use the Position property for getting and setting the current time.
As the <MediaElement/> is a wrapper for Windows Media Player, all videos playable in WMP should be playable in the <MediaElement/> (after you installed necessary codecs).
You can use VLC with the .Net Interface to VLC. It supports lots of codecs out of the box and seems to be really easy to use.

Playing videos in C# application via Windows Media Player. Is there a stable, decently performing solution?

I've written a WPF application (in Visual C# 2010 Express) that has 2 windows. The 1st has a various buttons, the other displays video using the MediaElement control. When a button is pressed, a video associated with it is played or stopped if it's already playing.
On my development machine (Windows 7, good graphics card, lots of memory etc), this runs fine. The only problem I've encountered is that when attached to the debugger it is very unstable but when run normally these issues go away.
Unfortunately when run on a much less powerful XP machine the videos run at 1-2fps. This is despite the fact that the videos run fine in Windows Media Player.
There seem to quite a lot of reports of poor performance for the MediaElement control (not to mention inconsistencies in what it can play) so I decided to look at some alternatives.
I tried a free library call WPF MediaKit (http://wpfmediakit.codeplex.com) that I thought might have some effect, however while I've got it to work on an XP machine, it resolutely refuses to display videos on my development machine despite using exactly the same code. I'm still hoping I can this to work but I'm not confident it will help given it's still using the MediaElement control behind the scenes.
I then tried using wmp.dll COM control (Windows forms rather than WPF) and even with the simplest app (new Windows Form project, WMP control added to form, and 1 line of code to set the URL on load) I get odd behaviour. With the debugger attached, it works across multiple monitors, but sometimes when it starts playing, it just repeatedly stutters over the 1st few frames and the only way to break it out of this seems to be to move it to the other monitor. If I'm not using the debugger, I don't seem to get the stutter issue but the video is only displayed on the main monitor, as soon as I move the window to the secondary monitor, it goes black.
So my question is has anyone experienced anything like the above and/or have a decent solution to it? It would be especially nice to find something that works consistently with and without the debugger attached!
Have you tried this library?
http://directshownet.sourceforge.net/about.html
There's also this .NET interface to VideoLAN media player, but that introduces a dependency to VLC:
http://wiki.videolan.org/.Net_Interface_to_VLC
WPF MediaKit does not use MediaElement behind the scenes, but instead uses the D3DImage interop class to provide high performance video to WPF.
WPF in XP has always been a hit-or-miss in terms of performance. You might want to take a look at the rendering tier to ensure WPF is fully hardware accelerating. Also make sure you have the newest video drivers available and that the GPU is capable.
-Jer

Categories