diff --git a/libs/openFrameworks/video/ofDirectShowGrabber.cpp b/libs/openFrameworks/video/ofDirectShowGrabber.cpp index a29428d8604..39f4e486a2a 100644 --- a/libs/openFrameworks/video/ofDirectShowGrabber.cpp +++ b/libs/openFrameworks/video/ofDirectShowGrabber.cpp @@ -1,6 +1,17 @@ #include "ofDirectShowGrabber.h" #include "ofUtils.h" #ifdef TARGET_WIN32 + +//-------------------------------------------------------------------- +//Static members / functions + +int ofDirectShowGrabber::preferredFormat = -1; + +void ofDirectShowGrabber::setPreferredFormat(int aPreferredFormat) { + preferredFormat = aPreferredFormat; +} + + //-------------------------------------------------------------------- ofDirectShowGrabber::ofDirectShowGrabber(){ @@ -51,6 +62,9 @@ bool ofDirectShowGrabber::setup(int w, int h){ height = h; bGrabberInited = false; + if (preferredFormat >= 0) { + VI.setRequestedMediaSubType(preferredFormat); + } if( attemptFramerate >= 0){ VI.setIdealFramerate(device, attemptFramerate); } diff --git a/libs/openFrameworks/video/ofDirectShowGrabber.h b/libs/openFrameworks/video/ofDirectShowGrabber.h index 96545e48dcb..bacdbc21b5f 100644 --- a/libs/openFrameworks/video/ofDirectShowGrabber.h +++ b/libs/openFrameworks/video/ofDirectShowGrabber.h @@ -32,6 +32,13 @@ class ofDirectShowGrabber : public ofBaseVideoGrabber{ ofDirectShowGrabber(); virtual ~ofDirectShowGrabber(); + /// \brief Sets the preffered DirectShow media subtype - MJPG / H264 can provide faster framerates + /// + /// /use formats like: MEDIASUBTYPE_H264, MEDIASUBTYPE_MJPG, MEDIASUBTYPE_Y800 etc, default is: MEDIASUBTYPE_RGB24 + /// /use -1 to revert to the default behavior + /// + static void setPreferredFormat(int aPreferredFormat); + std::vector listDevices() const; bool setup(int w, int h); void update(); @@ -56,9 +63,6 @@ class ofDirectShowGrabber : public ofBaseVideoGrabber{ void setDeviceID(int _deviceID); void setDesiredFrameRate(int framerate); - - - protected: bool bChooseDevice; @@ -70,6 +74,7 @@ class ofDirectShowGrabber : public ofBaseVideoGrabber{ bool bIsFrameNew; int width, height; + static int preferredFormat; //--------------------------------- directshow #ifdef OF_VIDEO_CAPTURE_DIRECTSHOW int device;