Ask Your Question

Revision history [back]

list extensions supported by OpenCV

I see imread() and VideoCapture() both take a string to a file path of multiple extensions. Is there a way to get a list of extensions that are supported by them? For example, getting a list of "jpg", "png", "mov", "mpg", etc.? I assume this is system dependent and others have needed to query this at runtime.

Furthermore, how is support determined? If have something like the below code and the Mat I get back always seems partially corrupted (I can see a bit of the image). It doesn't seem to change regardless of the frame number I ask for. I can play this video in my video player "totem", but I'm not sure if totem and OpenCV are even using the same codec for this file.

Mat fromVideo(std::string _videoPath, int frame) {
    VideoCapture capture(_videoPath);

    Mat f;
    for (int i = 0; i < frame; i++) {
        capture >> f;
    }
    return f;
}