1

I've created a python script that checks muliple different urls and ports and detects if there is an RTSP stream on them - it is working fine, but it creates errors when the stream doesn't exist (which I'd obviously expect).

I'm getting [rtsp @ 0x16745c0] method DESCRIBE failed: 451 ERROR

What I want to do it add a line to my script so if I get the above error, then I just display it in a message on screen. I've tried the following with no luck:

for x in feedList:

    print("[INFO] Checking Link..." + x)

    cap=cv2.VideoCapture(x)

    try:

        # Check if camera opened successfully
        if (cap.isOpened()== True): 
            streamlink = x
            print("[INFO] FOUND! Stream Link..." + x)
            break
    except socket.error:
        print("[NO STREAM]" + x)
    except:
        print("[FAILED]" + x)
        pass

The Except cases never get hit, I always just get [rtsp @ 0x16745c0] method DESCRIBE failed: 451 ERROR

Any help would be appreciated.

Thanks Chris

1 Answer 1

2

If the stream on the link does not exist, creating VideoCapture object on that link would still be successful but you will not be able to process on the object.

You code's control flow just might be going in and checking if (cap.isOpened()== True) but there is no else block to handle what would happen if if (cap.isOpened() != True). So just try adding an else block to display the error message.

for x in feedList:

    print("[INFO] Checking Link..." + x)

    cap=cv2.VideoCapture(x)

    try:   
        # Check if camera opened successfully
        if (cap.isOpened()== True): 
            streamlink = x
            print("[INFO] FOUND! Stream Link..." + x)
            break
        # Else is important to display error message on the screen if can.isOpened returns false
        else
            print("[NO STREAM]" + x)
    except socket.error:
        print("[NO STREAM]" + x)
    except:
        print("[FAILED]" + x)
        pass

If this doesn't work: following might solve the issue:

One of the main issues is that every camera manufacturer uses their own protocol (RTSP URI formatting). Finding the correct URL for your IP-camera can be frustrating and time-intensive. When found you can try to open it with VLC, and afterwards with Kerberos.io.

Depending on the format of the RTSP URI things can go wrong, for example when using a format like above. To solve the problem you'll need to add an question mark "?" at the end of the url.

As example original link might be:

rtsp://192.168.2.109:554/user=admin&password=mammaloe&channel=1&stream=0.sdp

So with ? it would be:

rtsp://192.168.2.109:554/user=admin&password=mammaloe&channel=1&stream=0.sdp?

Source

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, unfortunately I still get the same: [INFO] Checking Link...rtsp://xx.xxx.xx.x:554/mpeg/media.amp [rtsp @ 0x18ad840] method DESCRIBE failed: 451 ERROR
Try adding a '?' at the RTSP link end, link: kerberosio.zendesk.com/hc/en-us/articles/…
Thanks, Unfortunately that didn't work either (Alot of my links so have a ? at the end), it's a strange one. It's not essential as the code is working fine, I just like to handle error correctly
Try adding else to if of cap.isOpened() as updated in my answer
[INFO] Testing Link...rtsp://92.236.66.2/live1.sdp? [rtsp @ 0x1bcc9c0] method DESCRIBE failed: 451 ERROR [NO STREAM]rtsp://92.236.66.2/live1.sdp?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.