Ask Your Question
0

Check, is FFmpeg or GStreamer available

asked 2017-07-29 03:46:46 -0600

Guy78 gravatar image

What's the easiest way to check in OpenCV code, is FFmpeg or GStreamer (or both) available. I've understood that in VideoCapture class FFmpeg requires filename or device ID, but GStreamer a pipeline, so same code doesn't work in both.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-07-29 04:24:37 -0600

berak gravatar image

updated 2017-07-29 05:01:22 -0600

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;
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-29 03:46:46 -0600

Seen: 4,402 times

Last updated: Jul 29 '17