ofxWMFVideoPlayer - a hardware accelerated video player using Windows Media Foundation

Hi guys,

Just a little message to let you know I’ve published a first version of a video player using Windows Media Foundation and hardware acceleration.

You can find it there : github

For the moment it only implements a hardware accelerated path… which is a bit finicky (I tested it on 6 computers and for some mysterious reason, it was only working on 4 of them…). I’ll be working on finding out why it’s failing on certain computers and keep the repository updated. My gut feeling is that I’m doing something wrong with Direct3D.

Another option would be to implement a CPU-side sample grabber (pretty much as what Theo did with Direct Show).

If you want more details, you can check the technical description of the project there : Technical Description

I’ll keep this topic updated when I modify the addon, and any feedback is greatly appreciated :smile:

And as a side note, I worked on this addon for various projectd I did with Second Story, so I thought putting a link back to our website is kind of appropriate (and it has tons of oF related project! ).

4 Likes

Okay guys, I might have found a work around for the failure I was experiencing, and now it works on all the (NVIDIA) machine I’ve tried it on ! (I’m using a shared texture instead of a shared surface, as the direct3d call for creating a surface was failing on certain machine)

@carmines, @theo you might find all this worth a look

Next I’m going to explore frame-syncing of multiple video and keep people posted if it raises any interest :slight_smile:

1 Like

Hi Philippe,
I was not able to get videos with alpha values to work with your code. I have tried several codecs on windows 7. Is it even possible? which codecs work?

thanks
Christoph

Hi Christoph,

My solution to this problem is to do some framesyncing between the RGB video I want to use, and an alpha mask video, and then do the masking in a shader. It’s a bit involved so I don’t know if it would work for you. (In after effect you can render your composition as an H264 video with only the RGB component, and one with only the alpha component)

Another solution if your videos are small enough is to use a quick time video player and use the quicktime animation codec (there’s a modified version of the quicktime video player out in the wild that can play transparent videos on windows)

You can also consider png sequences.

If I would go the “second video for transparency and mask in shader”
route, I would probably encode two videos in one file arranged above each
other, to avoid syncing problems. I will go and try how many 1920x2160
videos I can play simultaneously. The problem is my Videos are too long
and big to go the uncompressed route.

Edit: I am able to play 3 videos. with 4 videos, playback slows down noticeably

On windows 7, the H264 decoder falls apart beyond HD format (Windows 8 can do UHD though). You can use wmv videos they’ll work.
You will also need to tell your video driver to play videos on the full color range, otherwise the value will be stuck between 16-235 (see NVIDIA for instance). I couldn’t find a better way in windows media foundation to do it…

Do you know another way to do several HD layers (4-6) with transparency
of longish (1-2min) footage? Did you test gstreamer?

The only two codecs I know that are properly handling transparency are Quicktime Animation (which is roughly equivalent to zip the raw images) and webm (but the currently version for windows media player doesnt handle transparency, only the chrome one does). Maybe you can try to build your experience in chrome and see how good/bad it performs:

And I tried gstreamer, but never got crazy performance (it was a year ago, maybe now it’s different)

thanks for the info. I can also confirm that flash and its flash video codec can play 6-8 HD videos with transparency simultaneously. though there is studdering when videos restart.

Philippe, do you know why it is possible to open flash video files with windows media player (when a codec pack is installed) but not with your EVR player?

I think Windows media player can read video files two ways : using direct show (the old and deprecated way) and using windows media foundation (the new way). My hunch is that your codec packs comes with direct show filers, but nothing for windows media foundation. You could give a try to Theo’s addon (which is a direct show player) if you want to stick with flash (I’m not 100% sure the whole chain will do transparency though, as it’s a pretty big edge case for people developing filters having only windows media player in mind).

If you want to test any further what can be done with windows media foundation without relying on my addon, you can get a tool called “Topoedit” (it’s in the windows sdk samples, and you may be able to find it as a binary as well) which is the bare “let’s put a video in it, and I show you the magic I do” kind of thing. So if it won’t work with topoedit, it wont work with my addon either.

On the other hand you can also look the web for a Media Foundation Trasnform (a codec) for flash.