Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libs/openFrameworks/video/ofDirectShowGrabber.cpp
Original file line number Diff line number Diff line change
@@ -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(){

Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 8 additions & 3 deletions libs/openFrameworks/video/ofDirectShowGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ofVideoDevice> listDevices() const;
bool setup(int w, int h);
void update();
Expand All @@ -56,9 +63,6 @@ class ofDirectShowGrabber : public ofBaseVideoGrabber{
void setDeviceID(int _deviceID);
void setDesiredFrameRate(int framerate);




protected:

bool bChooseDevice;
Expand All @@ -70,6 +74,7 @@ class ofDirectShowGrabber : public ofBaseVideoGrabber{
bool bIsFrameNew;

int width, height;
static int preferredFormat;
//--------------------------------- directshow
#ifdef OF_VIDEO_CAPTURE_DIRECTSHOW
int device;
Expand Down
Loading