In 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?
Use the method cv::VideoCapture::isOpened()
to make sure that the constructor was successful in initializing the VideoCapture object.
Note that even if it was possible to get a list of supported container formats from OpenCV (AVI, MKV for instance) with their typical filename extensions, you would still need to know the exact list of supported codecs (and even then the exact file you want to open might be corrupted, etc...). So a list of filename extensions is not enough to accurately describe what is internally supported by OpenCV, and the simplest solution at the OpenCV API level is this isOpened()
method.
For imread()
(more info here):
For VideoCapture()
:
AVI files - *.avi
It seems that AVI is the only format with decent cross-platform support. See here for more info.
Just update:
cv::VideoCapture cap("D:\\test.mp4")
works for me.