Page 1 of 2
VLC Element for WPF
Posted: 05 May 2007 14:31
by BenZC
Hi,
I've created an VLC Element for the Windows Presentation Foundation.
This Element can be easlily integrated in an existing XAML-File and works like the Media Element from WPF.
My Code based on an existing source code written in C# and C++ also posed in this forum. It is reported in the ticket service under the name "WPF interface for VLC windows"
You can find it under
https://trac.videolan.org/vlc/ticket/573
Also I've used a VLC-Wrapper for the libvlc.dll which was also posed in this forum by Odysee.
You can find it under
viewtopic.php?t=28553
The whole project can be built with Visual Sutdio 2005. Make sure you have Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF) installed.
The extension is available under
http://www.microsoft.com/downloads/deta ... laylang=en
Follow the readme.txt to copy the right compiled dll-files in the right directories.
I've also included a VLC Client to test the VLC Element. This Client is really primitive and was created only for showing a possible usage of the VLC Element in a WPF application.
The VLC Element works fine, but the video rendering process is still inefficient.
At the moment a WPF image is used to render the video, however that's not the WPF image was designed for.
Because of that the video is not playing really smoothly and drawing errors are the result.
It is indispensable to implement a better rendering process to make it more competitive.
I hope some of you are able to assist me with that...
I'm thankful for any suggestions.
Best Regards
BenZC
Screenshot of the VLC Client :
http://www.tfh-berlin.de/~s19999/VLC%20 ... Client.png
Project-Files :
http://www.tfh-berlin.de/~s19999/VLC%20 ... %20WPF.zip
Posted: 05 May 2007 21:20
by Jean-Baptiste Kempf
Hello,
Nice work. POst it to vlc-devel too, please.
Then, can you use the Direct3D output from VLC to render ?
Re: VLC Element for WPF
Posted: 25 Jul 2007 23:46
by juliant
He BenZC
Great work
but i can get it to work completely, my video isnt played in the vlcelement, but instead "pops out" in a hardware yuv overlay (direct x) separate window. Do you know how to fix this? Im using june ctp of Orcas.
Cheers,
juliant
Re: VLC Element for WPF
Posted: 30 Jul 2007 12:23
by BenZC
Hi juliant,
this problems occurs either if the files are not in the right directories:
VLC.WPF.VlcPlugin.dll -> VideoLan-InstallDirectory\VLC\plugins\
VLC.WPF.VideoOutputController.dll -> VideoLan-InstallDirectory\VLC\
VLC.WPF.VideoOutputController.dll -> Directory of the WPF application
libvlc.dll -> Directory of the WPF application
or the version of your installed VLC is not 0.8.6.
Unfortunately at the moment the VlcElement only works with that version.
Greetings
BenZC
Re: VLC Element for WPF
Posted: 31 Jul 2007 10:00
by juliant
Hmm I still can't get it to work... I've double-checked that the files are in the right directories, and my VLC version is 0.8.6.
Btw I stumbled upon
jmorrills blog, he has some posts (with code samples) that might be interesting for getting the rendering performance of the VlcElement improved (allthough i have'nt seen it, you know, 'cause i cant get it to work
)
Native Pointer to Bitmapsource's Buffer and
WPF - Hackery! Part I
best regards,
juliant
Re: VLC Element for WPF
Posted: 01 Aug 2007 09:42
by burninglode
hi juliant,
here is the complete work-around for the vlc-wpf element under VISTA
what you need:
-vlc 0.8.6 (installed or simply the bins)
-"vlc.wpf.videooutputcontroller.dll"
-"VLC.WPF.VlcPlugin.dll"
-"msvcr80.dll", "msvcm80.dll", "msvcp80.dll", "Microsoft.VC80.CRT.manifest"
-the path in your system settings to the msv*.dlls
1. copy the "vlc.wpf.videooutputcontroller.dll" to your VLC directory (example: C:\Program Files\VideoLAN\VLC)
2. download the MSVCRT- DLL´s from here :
http://www.fh-jena.de/contrib/fb/et/stu ... 80.CRT.zip
3. extract the zip-file and copy the whole folder "Microsoft.VC80.CRT" to your VLC directory (example: C:\Program Files\VideoLAN\VLC)
4. add the path for these DLLs to your system settings (start --> settings --> control panel --> system --> Advanced --> Environment Variables: select "Path" and click "edit" --> add the path to your VC80-Dlls ( example: "C:\Programe Files\VideoLAN\VLC\Microsoft.VC80.CRT")
5. copy the "VLC.WPF.VlcPlugin.dll" to vlc plugins folder (C:\Program Files\VideoLAN\VLC\plugins)
6. start vlc and look for setting --> video --> output modules (in advanced mode) , if you have configured all correctly you should see a new modle "wpf..."
for your info: IF VLC.WPF.VlcPlugin.dll already exist in \VLC\plugins:
after adding the classpath you should rename or delete the VLC.WPF.VlcPlugin.dll in your plugins folder and restart vlc because vlc did not reload known dll's. after restarting shutdown vlc and copy the VLC.WPF.VlcPlugin.dll again to the plugins folder.
i´ve also added a complete working copy of vlc with the wpf element on my ftp - check al needed installs here
http://www.fh-jena.de/contrib/fb/et/stu ... %20wpf.zip
i hope it will work now
regards robby
Re: VLC Element for WPF
Posted: 01 Aug 2007 14:06
by jmorrill
Thanks for the link back juliant!
BenZC, I took a peep at your source-code and indeed the performance loss is with recreating a new BitmapSource for each frame. Unfortunatly, this is the "correct" way to use WPF for WPF is a retained rendering system.
I have made a dirty little hack to get the pointer to a BitmapSource's pixel buffer. I have been able to do a 4CIF @ 30 FPS on a 3.4 GHZ at around 7% CPU usage.
To implement in your code, first initialize your BitmapSource with your video's width and height. On each frame your receive from vlc, use my hack to get the pixel pointer (do it each time to unlock the pixels in WIC) and just copy the memory to the bitmap source's pointer (use some unmanaged interop like this for the copy memory
http://pinvoke.net/search.aspx?search=R ... space=[All]). Then run "Invalidate()" on the BitmapSource.
http://jmorrill.hjtcentral.com/Home/tab ... fault.aspx
Hit me up if you have any questions or problems
jeremiah.morrill [at] gmail.com
Re: VLC Element for WPF
Posted: 01 Aug 2007 22:08
by BenZC
Thx juliant for the great link.
With that little WPF hack I could considerably increase the performance.
Unfortunatly I had to change the Videooutput from a RGB24 to a BGR32 Image, to make it run.
jmorrill did you managed it with a RGB24 Image?
Although I could increase the performance, the video is still not playing really smoothly, especially on weak PCs.
So it would be better to use the VLC DirectX Ouput.
If somebody has experience with using the VLC DirectX Ouput, it would be nice if he posts it here.
Best regards
BenZC
Re: VLC Element for WPF
Posted: 02 Aug 2007 22:14
by juliant
Hi everyone
Burninglode, I didnt really think about OS, Im using XP so I guess it only works in Vista then
jmorrill, when I found your post about MediaElement's DirectShow Graph (wich is awesome by the way) i was thinking like you say BenZC, that if it is possible to write a interface to vlc's dummy directshow filter, i think its
dshow/filter.h then it would be possible to write a usercontrol that used MediaElement to display video "through" vlc.
So like you say hope anybody out there could post some info.
Anyway guys thanks for great work, keep it up
PS: sorry for my fast typing/little bad english
Re: VLC Element for WPF
Posted: 03 Aug 2007 11:22
by jmorrill
jmorrill, when I found your post about MediaElement's DirectShow Graph (wich is awesome by the way) i was thinking like you say BenZC, that if it is possible to write a interface to vlc's dummy directshow filter, i think its
dshow/filter.h then it would be possible to write a usercontrol that used MediaElement to display video "through" vlc.
So like you say hope anybody out there could post some info.
I wrote the WPF Media Bridge (
http://jmorrill.hjtcentral.com/Home/tab ... fault.aspx ) to get reference to a MediaElement's underlying DirectShow graph, so in threory, if it works in DirectShow, you should be able to get it working with the WPF Media Bridge with the same performance as a stock MediaElement.
I'm curious how much initialization is required for the VLC Dummy Filter. There might have to be some COM interop written, but that's usually pretty simple. If you have any questions or need help, feel free to email me. This sounds like an interesting project.
-Jer
Re: VLC Element for WPF
Posted: 31 Mar 2008 03:47
by jmorrill
I have just released an WPF control called VideoRendererElement (
http://www.codeplex.com/VideoRendererElement). It does fast raster updates suitable for video. I tweaked the VLC wpf player to use this control and CPU usage was great and no tearing. I blogged about it here
http://jmorrill.hjtcentral.com/Home/tab ... fault.aspx
Re: VLC Element for WPF
Posted: 19 May 2008 21:57
by BenZC
Hi jmorrill,
your VideoRendererElement is a nice work. I have upgrated the VLC Element with that VideoRendererElement and its just working perfect. The video is playing really smoothly without any clipping errors. In the current Version I have implemented both Rendering procedures (the older one which use your BitmapSource's pixel buffer (BitmapBuffer) and the new one which use your VideoRendererElement (DirectShow)). It is possible to switch between those procedures "on-the-fly". So I could exactly see the raise of performance.
I will test the VideoRendererElement a little bit more and will post the source code of the new VLC Element with contains both Rendering procedures soon.
Best Regards
BenZC
Screenshot of the VLC Client using VideoRendererElement (DShow):
http://public.tfh-berlin.de/~s19999/VLC ... _dshow.png
Re: VLC Element for WPF
Posted: 20 May 2008 16:04
by Jean-Baptiste Kempf
Interesting work.
Re: VLC Element for WPF
Posted: 26 May 2008 10:28
by joe525521
very nice!
keep up the good work!
Re: VLC Element for WPF
Posted: 28 Jul 2008 11:37
by publicENEMY
Where can i download the latest VLC Element integrated with VideoRenderer Element?
Re: VLC Element for WPF
Posted: 04 Aug 2008 10:16
by drainey
I too am looking for a dowload of VideoRendererElement and vlc merged
Re: VLC Element for WPF
Posted: 07 Aug 2008 18:44
by BenZC
Hi to all,
I will release the new version of the VLC Element in the next 2 weeks. The reason why I'm didnt release it yet was a bug, which is still present in the current version.
Sometime the DShow Graph Callback is missing. In 90% cases it works, but in 10% (randomly) you just get sound but no picture of the video, cause the DShow Graph doenst invoke the callback method.
I will check it in the next weeks again and will provide a download of the current version.
Kind regards,
BenZC
Re: VLC Element for WPF
Posted: 18 Aug 2008 15:51
by drainey
Thanks Ben... looking forward to having a look at it and giving it a run.
Re: VLC Element for WPF
Posted: 23 Aug 2008 16:09
by BenZC
Hi,
it seems that I have solved the problem with the missing callback. After some debugging action, I recognized that not only the callback was not invoked, but the whole graph was not built.
The InitializeDirectShow(); Method in the VideoRenderElement invokes the m_mediaElement.Play(); Method which creates the graph.
The TearDown(); Method in the VideoRenderElement invokes the m_mediaElement.Close(); Method which destroys the graph.
After each new video source the TearDown(); Method followed by the InitializeDirectShow(); Method was invoked.
So far so good, but sometimes (mostlly after fast video source switching) the m_mediaElement.Close(); Method destroys the graph, but
the m_mediaElement.Play() doesnt recreate the graph and so the callback Method was not invoked and no video picture was available.
So my approach was not to destroy the graph and keep it alive und just reinitialize the graph with the new video format.
After some testings it seems that it works now.
Unfortunately I didnt have time this week to prepare and upload the code.
I will do it in the next week.
Kind regards,
BenZC
Re: VLC Element for WPF
Posted: 27 Aug 2008 23:49
by BenZC
Hi all,
I have published the VLC Renderer Project under
http://www.codeplex.com/VLCRenderer.
This version is a little bit older then the current one, which means it contains the little bug which I have described before.
But except for this it works just fine.
Enjoy it and have fun.
Best regards,
BenZC
Re: VLC Element for WPF
Posted: 28 Aug 2008 09:41
by publicENEMY
Hi all,
I have published the Project under
http://www.codeplex.com/VLCRenderer.
This version is a little bit older then the current one, which means it contains the little bug which I have described before.
But except for this it works just fine.
Enjoy it and have fun.
Best regards,
BenZC
hi BenZC
Thank you for releasing VLC element for wpf. i have a few questions
actually, what kind of bug did you mention? does this integrate with videorenderer element?
thanks you again.
Re: VLC Element for WPF
Posted: 28 Aug 2008 09:42
by publicENEMY
damn.
from
http://www.codeplex.com/VLCRenderer it stated that the vlc element for wpf is already integrated with videorenderer element.
sorry.
thank you.
Re: VLC Element for WPF
Posted: 28 Aug 2008 10:44
by BenZC
actually, what kind of bug did you mention? does this integrate with videorenderer element?
Sometime the DShow Graph Callback is missing. In 90% cases it works, but in 10% (randomly) you just get sound but no picture of the video, cause the DShow Graph doenst invoke the callback method.
The VlcElment ist not really merged with the VideoRenderer, the VlcElement just uses the VideoRenderer to render the videos.
Re: VLC Element for WPF
Posted: 28 Aug 2008 11:38
by publicENEMY
i noticed the prepackaged vlc in vlc element for wpf is from old vlc (2006). so i decided to replace it with the latest stable release (0.8.6i). and when i tried to play video, the video is rendered in an external window with the title 'VLC hardware YUV overlay DirectX output'. im using windows xp sp3.
thanks. looking sweet.
Re: VLC Element for WPF
Posted: 28 Aug 2008 11:43
by dragonslayer
Thanks a lot, the program you gave us is working fine.
Unfortunately the Element itself behaves odd.
I added a reference to the VLC.WPF.VLCElement.dll, included the namespace in my XAML File and when I try to add the Element itself my Visual Studio 2008 SP1 crashes.
Loading the project included in the package does not crash, but there are so many errors, missing references aso, that I can't compile it myself either.