A DirectShow video player for openFrameworks

Hi Im atemping the same thing and getting identical errors - did you manage to solve this?



Hi, I am getting those exact errors in CodeBlocks, and in VS2012 I’m getting the following:

Error 5 error C2065: ‘dPlayer’ : undeclared identifier C:\of_v0.8.1_vs_release\examples\video\videoPlayerExample\src\ofApp.cpp 13 1 videoPlayerExample

Any help would be appreciated!


@twina did you do:

#include "ofDirectShowVideoPlayer.h" 

in ofApp.h?
and then create the object in the ofApp class?

it should run fine in VS2012

Just to note that ofDirectShowPlayer does not currently compile on Code::Blocks.
I think its doable it will just be a matter of pulling in the right MS includes.

Theo, thanks again! This implementation is really nice.
Any suggestions on the best video codec to use with DirectShow?
I’m playing 4k video and from what i’ve found Apple MPEG4 Compressor seems to be the smoothest.

Cheers from Argentina!


First of all thanks for making this!

Here’s the deal, I want to play two 720p videos at the same time, one of them with a custom fragment shader. I’ve been banging my head against a wall with this stuff for a couple of weeks now, I’ve tried using the default quicktime video player (performance is too bad), arturoc’s gstreamer video player addon (could not get it to link properly due to libc issues, might go back and try again), and this!

My issue is that, while the application is running at around 40 fps with both videos playing and rendering with the correct shader, the videos seem to be playing in slow motion. Any advice?

Also, I have absolutely no idea on how to install other codecs. All I’ve managed to play is completely uncompressed avi, h264 compressed avi gives me “Error occurred while playing or pausing or opening the file”

I’ve looked into http://www.gdcl.co.uk/mpeg4/ but I’m clueless as to how to integrate it into the player.

I’m on windows 7.

Here are the most relevant code snippets

//in setup

ofDirectShowPlayer* dPlayer = new ofDirectShowPlayer(); 
ofPtr <ofDirectShowPlayer> ptr(dPlayer);

ofDirectShowPlayer* dPlayer2 = new ofDirectShowPlayer(); 
ofPtr <ofDirectShowPlayer> ptr2(dPlayer2);


//in update


//and in draw

bg.movie.draw(0, 0, 1280, 720);

fg.movie.draw(0, 0, 1280, 720);

(Removing the shader makes no difference)

I thought this would be quite a simple project but so far I’ve failed spectacularly. Any help? Thanks in advance

hello @PavleMiha,

your setup shouldn’t give much problems actually. Try installing the k-lite codecpack from here, this will solve your codec issues. Using this, Directshow is able to decode a huge amount of codecs. I for instance can play two fullHD H264 movies without stutter and issues. It would probably even work with more movies.
What kind of machine are you working on?

Best, V

1 Like

OK, got to the bottom of a few more things today. A big part of the issue was that my laptop is running nvidia’s optimus, which was forcing my application to run on the integrated intel card. Forcing either Visual Studio or the executable itself to run on my graphics card made the videos run smoothly.

The codecs worked! But they still seem to have a lot of issues, like sometimes the video just doesn’t decode (I get magenta and black squares or no video at all or a frozen frame from the last time I ran the application).
Also would it be possible to package this, or an alternative to it, with an application?

Luckily, with it running on the graphics card it seems the default video player is doing alright, although it does stutter every now and then.

So for now I think I’ll move back to quicktime, until I can figure out whether I can package codecs for directshow with my stuff…

Thanks Vjacobs!

As a rule of the thumb, with no extra codec installed, what can be played by windows media player should be able to play in a Direct Show player. I think by default windows 7 has a H264 and VC1 (wmv) decoder.

You could give a try to my addon (ofxWMFVideoPlayer) that gives you a texture rather than the pixel, and is supposedly faster thanks to that. It runs with Windows Media foundation, a evolution of direct show.

Hm my current installation doesn’t play h264 with windows media player. Currently playing around with h263 and other more available codecs on windows machines. I’ll definitely find something that works and looks good.
I actually tried your addon a couple of days ago and I had issues with unresolved symbols in glew (wglewissupported was somehow unresolved) and this was after updating the glew files in openframeworks. Any ideas?
Thanks for making it and helping out though!
I’m also currently trying to figure out whether I can load videos while playing other videos, so while I have your attention I’d appreciate any advice (although I haven’t done too much work on it myself yet).

Have you replaced glew32s.lib in your oF folder as well ? (the version of the lib on our github should have the function that’s missing). Or worst case scenario you can try to comment out the call for this function in the addon code (as it’s only used to warn the user if an extension is missing)

Windows media player should be able to play avi and .mp4 files on a windows 7 machine (by default I doubt it will play .mkv or other exotic container format).

Regarding loading video while playing other… it may cause a freeze of a few frames unless you load the video in a separate thread.

ofxWMFVideoPlayer is definitely more efficient, but the DirectShow with K-lite codec pack is a good solution on Windows. With the K-lite make sure to change the default from software renderer to one of the hardware renderer options. With both wmf and ds, upgrading to Windows 8.1 from Win 7 provided significant improvements to playback on my machine. Of course if you really need to push, it’s hard to beat the Hap codec and player, though I’ve experienced some issues with the ofxHapPlayer on Windows.

Thanks,Theo,and I wonder whether it can be used on video synchronization?if could,how to do it

Just to clarify, the issues I was having with ofxHapPlayer was my fault. Works well on Windows.

Related question (I hope). I’ve got this bit of code:

for (int i = 0; i < 5; i++ ) 
        ofVideoPlayer* player = new ofVideoPlayer();
        ofDirectShowPlayer* dPlayer = new ofDirectShowPlayer(); 
        ofPtr <ofBaseVideoPlayer> ptr(dPlayer);

But I’m getting this error:

error C2228: left of ‘.setPlayer’ must have class/struct/union

I usually think I understand this error. But am I not doing the exact same thing as the example? If anybody can help me, that would be nice. Thanks a lot


player is a pointer, so you should use -> to access member functions of the object being pointed to, not .



You’re completely right. Thank you! Pointers are still a point of confusion for me every now and then.

I am getting this error:

ofApp.obj : error LNK2019: unresolved external symbol “public: __thiscall ofDirectShowPlayer::ofDirectShowPlayer(void)” (??0ofDirectShowPlayer@@QAE@XZ) referenced in function “public: virtual void __thiscall ofApp::setup(void)” (?setup@ofApp@@UAEXXZ)

which is the best codec for seekable movie with this addon?

Is there a way to use other decoders than K-Lite? K-Lite pack is quite ugly in terms of installation (adds, toolbars, etc) and I’m building an application for non-IT customers. I found other small decoders (ffdshow) for the format I need (h264 encoded .MP4 ), but the videos can’t play.

Any ideas?