Make MediaElement support more video codecs - c#

Is there a way to make MediaElement support more video codecs like mkv, flv, mov etc.? If not, is there any other control that supports more video codecs?

Have you seen the Player Framework?
It's an open source component supporting Windows 8, part of the Microsoft Media Platform, and developed by Microsoft.
It's an alternative to the standard MediaElement control, and provides a plug-in mechanism.
I'm not sure whether you can support extra codecs through this mechanism though.
Other than that, you can also extend the media platform (the extension has to be written in C++ though) as shown in these samples provided by Microsoft:
Media Extension Sample
MediaStreamSource media extension sample
The second example is very interesting as it's a sample media extension adding the MediaStreamSource mechanism as in Silverlight.
Thanks to this extension you could implement your own MediaStreamSource in C#/VB.NET providing content to the MediaElement.

It seems impossible as WinRT has completely different set of API and all existing win32 based codecs won't run unless codec owners rewrite them. One long way will be to port win32 code into winrt which will require in depth knowledge of both and seems way too long to do it. Even if somehow you will find way to make existing codec work, it will not work on arm based windows 8 tablets.
This means, there are no codecs for winrt other then Microsoft has provided.
Your options are to convert them into h.264 video, which has become a standard as h.264 plays on all devices. Apple did great job by standardizing video. Win 7 onwards, microsoft has provided inbuilt support for h.264.

MediaElement plays whatever the windows media player can play.
So if you have the right set of codecs installed on your PC it can be a pretty versatile media player.
Personally I have installed K-Lite codecs
As well as Media_player_codec_pack codecs
And now my Windows Media Player doesn't lag anymore when playing mp4 files. Just follow the suggestion of the installer and restart your PC BEFORE starting the installation process. Also... it attempts to trick you with dialogs to install secondary software so BEWARE!!
Once Installed, just remember to experiment with the "preferred acceleration" parameter in the application's video settings, to see what goes better according to your hardware. I have set it to - CUVID.
I also installed this set of codecs to support avi format
Hope this helps :)

Related

c# mixing two audio files in windows phone 8.1 silverlight project

My goal is to mix 2 audio files that is one voice and one background music. For mixing I am using NAudio.
The problem is I am getting following exception while reading mp3 file using NAudio's Mp3FileReader.
DllImport cannot be used on user-defined methods
I am using NAudio in Windows Phone 8.1 Silverlight app project. I am not sure if NAudio is useable on WP Silverlight app if its useable then please help by providing a code example or suggest any other library or custom implementation to mix 2 audio files.
No, I'm afraid NAudio is not usable on Silverlight, as it makes lots of calls into Windows APIs which you can't do in Silverlight. You can take a look at the NAudio NLayer project which offers fully managed MP3 decoding. You could use that in conjunction with some of the more generic helper classes in NAudio like the MixingSampleProvider to perform the mixing you require. Of course the next issue would be what you want to do with that mixed audio. Silverlight does have a way of streaming user generated audio using the MediaElement but NAudio does not provide support for this directly.
[DllImport] requires a substantial chunk of code in the CLR, nothing very subtle about the pinvoke marshaller. That's a problem on a phone, it runs a special version of the CLR named .NETCore. Probably better known today as the codebase that spun-off the CoreCLR open source project. Keeping it small required unsubtle choices, pinvoke fell on the floor.
So no, you'll have no use at all for NAudio. You'll have to dip into the built-in support for audio. The relevant oversight MSDN page is this one. This blog post is relevant.
As you can tell, XAudio2 is your ticket with direct support for mixing. There is a learning curve of course, the language is probably the first obstacle given the question tags. Get started with this sample to get the basics.
Maybe you should consider taking the step to upgrade from WP8.1 Silverlight (WPS) project to WP8.1 (WinRT) one so that you have better access to audio APIs...
...or directly to a UWP/Win10 app (if you don't plan to release immediately to phones). If you choose that path, you could try maybe a free preview tool that converts WPS to UWP, just released from Microsoft and Mobilize.NET - https://blogs.windows.com/buildingapps/2015/09/17/initial-preview-of-silverlight-bridge-to-uwp/

How can I show an MP4 video inside a Winforms application without the need for installing missing codecs?

We're currenty building a little company presentation application for USB sticks that is used to display PDF files regardless of any PDF reader installed on the system. That works quite well, so we now also want to show videos directly inside the application. As we cannot ensure that the customers system is able to play the video file, I'd like to include everything that is neccessary to play the video regardless of the system configuration.
Before I reinvent the wheel - is there a preferred way to do so? Would another video format offer more possibilities? The target OS is supposed to be Windows XP up to Windows 8 and .NET 2.0. Is there any framework/assembly that I could use to become independent of any prerequisites on the target system? Thanks for your recommendations and thoughts on this!
Playing videos requires software to transform the video data into moving images. Unless you want to take on the mammoth task of writing your own MP4 decoder, you'll have to rely on what the user has installed.
Wikipedia lists Windows Media Player versions here. Version 12 is the only one to support MP4 out-of-the-box. That means your Windows XP and Vista users are going to need a third-party codec.

Axis Camera video streaming with C# 64bit

I'm looking for a way to stream video from an AXIS M10 IP camera, and display the feed using windows forms (or better, wpf). However, it need to be running on 64-bit platform.
This means that I can't use the AXIS Media Control ActiveX component.
Also, I found that these methods work but only in 32bit environment:
1.Using MediaElement Class for WPF
2.Using embedded media player
3.VlcLib (for dotnet)
So far it looks like my only option is to directly implement RTSP protocol and decode the given RTP/AVP stream using Media Foundation (for .net) and display it somehow. (I was able to get the camera to stream to a UDP port using RTSP calls).
I'm fairly new to RTSP/streaming, so I'm concerned that I might be missing the big picture - Will I be able to use media foundation to render/display videos on winform/wpf, or do I have to look at that functionality elsewhere?(from my research it looked like it could decode H.264 streams, but I did not see any video-playing capabilities). I also came across DirectShow - should I use DirectShow over Media Foundation?
Or better yet, is there a library that is able to handle RTSP streaming that runs in 64bit?
VisioForge Video Capture SDK .Net for example (but commercial), WPF controls included.
Decoding using FFMPEG, with DirectShow engine. Really, I don't see any Media Foundation advantages here.
Also any other way using FFMPEG.
Or, you can write RTSP source filter (based on DirectShow Push Source sample) with H264 output pin for video and G726/G711/AAC for audio. Also you can made virtual video capture source filter and use it in MF or DirectShow. You can use live555 library for RTSP implementation.
So, no simple ways here, if you are starting from zero.
If you just need the Video, I would prefer to just display the MJPEG stream of the camera. This is really easy done without the complexity of DirectShow or MediaFoundation. I display 12 cameras at the same time in my application with this little library in WPF: MJPEG Decoder. You can also use it in WinForms. It decodes the MJPEG Stream and gives you the images to display.
The 64 bits Axis Media Control SDK is available now, but requires an account on Axis web site to be downloaded.
After Sign in, you need to join Axis Developper program (free) and download the AMC SDK.
You will install a executable file (.exe), this install all the libs and samples in your Drive
C:\Program Files\Axis Communication\SDK
I found a way to use VLC in 64bits without ActiveX DLL :
The VLCSharp Library is composed of multiple NuGets to use VLC Player on severals platforms (WPF, Winforms, Xamarion, TvOS).
It is working fine on Onvif Cameras

Creating a universal video player (XP, vista, 7)

Im trying to create a media player (in C# .net 4.0) that will work on windows XP (SP3), vista and 7. Normally I would just go the easy way and use WPF's own MediaElement, but since that relies on Windows Media Player 10 or newer, that wont work as Windows XP SP3 may only have WPM9.
First I tried downloading Jerimiah Morill's WPF MediaKit sample application, but this used the EVR which wont show on my test machine (a Windows xp SP3 only with default codecs and default programs, plus the various .Net framework installations). I also downloaded the binaries and tore these apart, creating a new project only with reference to the DirectShow-dll and the bare minimums from the WPF mediakit, this time with no reference whatsoever to EVR. Still no luck. This i'm having a hard time understanding - should'nt even Windows XP be able to play movies using VMR stright out of the box?
I found some samples of media players where one of these works. This one is called DxPlay and uses directshow's graphbuilder, but is built in winforms, has some rather raw-looking code, and will not scale, seek, handle audio, and in general seems rather sketchy.
So, Is there any easy way to create a media player that will play on all the mentioned platforms without pushing WMP10+? I had high hopes for WPF MediaKit, but something is preventing it from playing on Windows XP SP3 (any solution to this would be very interesting).
Thank you very much in advance!
-ruNury
I would try to wrap VLC media player in your .Net project.
Here are some .Net projects that might help you:
http://vlcdotnet.codeplex.com/
http://sourceforge.net/projects/libvlcnet/
http://www.codeproject.com/Articles/109639/nVLC
MSDN suggest EVR (Enhanced Video Renderer) for video output in systems where it is supported: Windows Vista and later. With its introduction, its predecessors - Video Mixing Renderer filter (versions 7 and 9) were cut on smooth scaling of video. Video Mixing Renderer 7 is also less capable in terms of customization, however it consumes far less resources (does not use Direct 3D) and you can output way more videos at once.
Your standard solution here is to support both VMR and EVR output and use the latter starting Windows Vista, fall back to the former otherwise.
EVR is "unofficially" installed in Windows XP with .NET runtime and can be used with an instantiation trick: you the respective DLL is not COM registered and you cannot create an instance using CoCreateInstance API, however you succeed if you do CoLoadLibrary, DllGetClassObject and friends.
For C# development you typically consume DirectShow through DirectShow.NET Library.

How do you playback MP4 video in a Windows Forms App

I'm wondering what the best way is to play back an MP4 video in a Windows Forms application (.NET 2.0) on Vista and XP.
You could Embed Windows Media Player on a Form.
UPDATE: WMP doesn't support MP4 out-of-the-box, but there are codecs packs that add such support. It's possible to bundle a codec installation with your setup, but I think WMP is able to fetch and install MP4 codec on its own.
Either embedding media player or look at managed DirectX (although MDX is a bit old now)
take a look at iSpy - it's open source and wraps VLC player for mp4 playback.
http://www.ispyconnect.com

Categories

Resources