Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

RSTP video stream freezes the program while connection is lost..


I have a fairly simple Java app which connects to few cameras through rstp stream, grabs the image and shows it in swing JFrame usnig OpenCV SwingWorker. My reconnect() method looks like this:

public void reconnect(String address) {
    if (new ConnectionTester().pingHost(NETWORK_HOST, NETWORK_PORT, 50)); // networkAddress
    System.out.println("Still running");

    if (!capturedVideo.isOpened()) {
        System.out.println("Error while opening the camera!");

Because of a weak WiFi signal ( connection breaks) between the camera and my pc I sometimes get result like:

    Connection avaliable

and the program hangs while performing;

or on method:

if (isOpened) {;

Is there any way to avoid such situations by maybe waiting a set amount of time before stopping everything and reconnect again ?