Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

unfortunately, there is no way to check this programatically.

you can check cv::getBuildInformation() as a human, and you can set a preference flag in the constructor, but in the end, you'll have to write code like this:

String gstreamer_pipeline = ...
String filename = -...

VideoCapture cap;
// try gstreamer first:
if ( ! cap.open(gstreamer_pipeline, CAP_GSTREAMER) ) 
{
      // fall back to ffmpeg
      if ( ! cap.open(filename, CAP_FFMPEG) )
            exit(-1)
}

unfortunately, there is no way to check this programatically.

you can check cv::getBuildInformation() as a human, and you can set a preference flag in the constructor, but in the end, you'll have to write code like this:

String gstreamer_pipeline = ...
String filename = -...

VideoCapture cap;
// try gstreamer first:
if ( ! cap.open(gstreamer_pipeline, CAP_GSTREAMER) ) 
{
      // fall back to ffmpeg
      if ( ! cap.open(filename, CAP_FFMPEG) )
            exit(-1)
}

[edit:] you can check at compile time, it's just clumsy:

#include <opencv2/opencv.hpp>
#include <opencv2/cvconfig.h>
using namespace std;
int main(int argc, char** argv)
{
    #if defined(HAVE_FFMPEG)
        cerr << 1 << endl;
    #else
        cerr << 0 << endl;
    #endif
    return 0;
}