Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First of all, if you use ffmpeg as a backend for cv::VideoCapture, cap.open() will actually return after some time (more specifically, the timeout is defined in ffmpeg (somewhere in source):

#define LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS 30000
#define LIBAVFORMAT_INTERRUPT_READ_TIMEOUT_MS 30000

If you are unsatisfied with these timeout values, I see two options. First - compile ffmpeg with changed constants and link against it, and second - try to use another backend (the list is here) like this:

cap.open(url, cv::CAP_XIAPI); // or cv::CAP_<something else>

First of all, if you use ffmpeg as a backend for cv::VideoCaptureVideoCapture, cap.open() will actually return after some time (more specifically, the timeout is defined in ffmpeg (somewhere in source):

#define LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS 30000
#define LIBAVFORMAT_INTERRUPT_READ_TIMEOUT_MS 30000

If you are unsatisfied with these timeout values, I see two options. First - compile ffmpeg with changed constants and link against it, and second - try to use another backend (the list is here) like this:

cap.open(url, cap.open(0, cv::CAP_XIAPI); // or cv::CAP_<something else>

Update: this example is valid in C++, but maybe there is a similar workaround in Java.

First of all, if you use ffmpeg as a backend for VideoCapture, cap.open() will actually return after some time (more specifically, the timeout is defined in ffmpeg (somewhere somewhere in source):

#define LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS 30000
#define LIBAVFORMAT_INTERRUPT_READ_TIMEOUT_MS 30000

If you are unsatisfied with these timeout values, I see two options. First - compile ffmpeg with changed constants and link against it, and second - try to use another backend (the list is here) like this:

cap.open(0, cv::CAP_XIAPI); // or cv::CAP_<something else>

Update: this example is valid in C++, but maybe there is a similar workaround in Java.