views:

225

answers:

4

My team is tasked with building a full screen, kiosk-style application for playing back media files. Initially we need to support WMV / MP4 as well as some images in full 1080p, although down the line we will need to extend this to cover other formats (different videos formats as well as display of HTML, SWF, etc).

The application also contains a decent chunk of business logic relating to scheduling, logging, performance monitoring as well as network code to talk to a central server through web services (or maybe TCP) and potentially act as a server itself.

For our WMV / MP4 video playback, hardware acceleration will be a massive bonus. The targetted hardware has weak CPUs but strong graphics cards.

Here's the kicker: we're a .NET shop (our existing application is a WinForms smart client) and extremely experienced and productive in C# and the .NET stack. The app will initially be targetting Windows Embedded (.NET 3.0), but we will quickly need a Linux version as well. Between us we have some C/C++ experience and some Linux experience but we do not anticipate good productivity on that platform.

So I am soliciting recommendations specfically on the following points:

  1. Video. On Windows we have seen good success using DirectShow.NET. On capable hardware, the WPF MediaElement also seems to perform well. What should we be using on Linux? libavcodec seems like a common choice. Is it hardware accelerated on NVidia graphics cards on Linux? What other options do we have on Linux? Is there something cross-platform that I could consider?

  2. Stack. a) Ideally we could write the whole thing in .NET and then run under Mono on Linux. The video playback and presumably some other components (like performance monitoring) would not be supported on Mono. I guess we could rewrite these elements in, say, C++; but I'm guessing that most stuff on the business logic side would work. b) Maybe it's better to forfeit our up-front productivity on the Windows version for something that's cross platform out of the gate. What about Java? Do we have different options when it comes to video there? How about another framework? Something like QT? Can anyone else suggest something cross platform that would be relevant?

Broadly speaking, given the requirements, what would you use?

I appreciate any anwsers you might have.

+1  A: 

One option would be to use Silverlight, and explore Moonlight as an option for the linux version. My understanding is that Moonlight has several media/codec plugins (I believe ffmpeg is the main provider) and can additionally use the MS codec pack to give you support for things like WMV/MP4.

Pete
libavcodec is a part of ffmpeg, and yeah, moonlight uses ffmpeg. ffmpeg just decodes video, it does not handle display at all, not to mention hardware accelleration. Moonlight has GPU accelleration on its todo list, but does not provide it yet.
Justin Smith
Also, from what I hear, ffmpeg wmv/mp4 support is at least competitive with the MS Windows codecs, if not better in the case of mp4.
Justin Smith
Thanks. We actually dismissed Silverlight early on (although we are big proponents of the technology generally). We require a lot of space on the client for storing media files, need a local data storage story (DB like SQLLite or VistaDB), and we need to be close enough to the OS to do things like performance monitoring and changing settings of the host machine.
TheNextman
A: 

You can use ffmpeg in mono and .net. This may or may not include video display - ffmpeg usually just provides you with a decoded bitmap that you can do whatever you want with, be it display it in a window, save it in a file, whatever. If you use ffmpeg-sharp the same code should work on Windows or Linux. Really, putting the bitmap in a window is the easy part.

Justin Smith
Thanks. I've been looking at libavcodec (and, by extension, ffmpeg). It seems (please correct me if I'm wrong) that it doesn't take advantage of the video hardware on Windows. Certainly it uses much more CPU than simply playing the video in WPF, DirectShow or even Windows Media Player.That said, I don't mind using the most appropriate tool for each platform. Do you know if ffmpeg can use hardware acceleration on Linux?
TheNextman
The ffmpeg standalone application uses hardware acceleration for display, when available, as far as I know. But libavcodec does not use the GPU for accelerated decoding, and does not do video display - all it does is return bitmaps. I don't think any existing video library for Linux does GPU accelerated decoding, but I would guess that if any library does, libavcodec will.
Justin Smith
I will have to install Linux and see, I guess... Thanks!
TheNextman
+2  A: 

My suggestion is that you use Fluendo's GStreamer components for the video playback as it has support for hardware acceleration where available and fully licensed codecs.

You can look at the Banshee media player which support video playback if you have the Fluendo/GStreamer packages installed. Get OpenSUSE 11.2 which contains everything you need to try it and develop, and then buy and install the Fluendo codecs.

Source code wise, Banshee does the video display from C#, look here:

The C# source code consuming GStreamer and doing the video rendering is here:

http://git.gnome.org/browse/banshee/tree/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying

The C supporting library to call into Fluendo is available here:

http://git.gnome.org/browse/banshee/tree/libbanshee

For testing Banshee, you do not need to buy anything, but your video codecs will be limited to Ogg/Theora encoded videos. Once you get Fluendo's codecs you will be able to play WMV files.

miguel.de.icaza
This is great stuff, thanks for the answer. I will take a close look at Banshee.For fun, I tried to play back one of my media files on Linux and it prompted me to search for the codec; which it downloaded and installed (it was a gstreamer plug in) and then the file played. I understand why common codecs aren't included in Linux distributions but I guess it's not clear to me how Fluendo charge for plugins on their site, but the OS can just grab them and use them.Maybe that's another question though! Thanks again.
TheNextman
It all depends on whether you want to get into a lawsuit with the MPEGLA or not. The "automatically download codecs" dialog box contains some pretty sketchy wording that most users at home ignore, but it might not be something that you want to ignore for a commercial product.
miguel.de.icaza
A: 

Moonlight offers two codecs: (a) A fully licensed version that comes straight from Microsoft and requires no further negotiation with the MPEG-LA and other patent holders, or (b) an ffmpeg backend that requires you to negotiate with the patent stock holders if you plan on using.

You could build a Silverlight-based application, the trick to get access to the local system is very simple: you run a local web server that exposes those services.

You can still use C#/Sqlite or VistaDB as your storage system as part of your Silverlight application.

You could host the silverlight app in http://localhost/App.xap and this app would gain local access to the machine by contacting a REST or SOAP web service on http://localhost/rest.ashx or http://localhost/soap.asmx

For example, if you needed to read some values from a scanner connected to the machine, you would issue this request:

http://localhost/scanner.ashx?operation=scan_badge

Then your scanner.ashx HttpHandler will do the actual scanning (this one has full system rights) and return the value to the Silverlight application.

miguel.de.icaza
I like the idea of using Silverlight, and using local web services to access the system is a great idea! However without going into real specifics, we think that a 'thick' client is probably a better fit for us moving forwards.
TheNextman