dactylroot/rtsp

Assertion fctx->async_lock failed at libavcodec/pthread_frame.c:155

iBelow opened this issue · 3 comments

code:

import rtsp

uri = f"rtsp://user:pass@192.168.78.201:554/live"
with rtsp.Client(rtsp_server_uri=uri) as client:
    client.preview()

ERROR:

Assertion fctx->async_lock failed at libavcodec/pthread_frame.c:155

j13tw commented

Hello iBelow,
I doing my python flask project to capture the RTSP Camera have same problem
I think the problem is base on the client = rtsp.Client("rtspUrl") is not ready to connect rtsp server
then the check connection status command "client.isOpened()" is true
and the python code sequence execute the client.preview() command to read the rtsp video frame
so when you call the function client.preview() or client.read().save()
it will alert the thread fail message on terminal
in my solution to fix it,
i import "time" package and add the "time.sleep(1)" to wait the connection

import rtsp
import time

uri = f"rtsp://10.0.0.160:554/live.sdp"
with rtsp.Client(rtsp_server_uri=uri) as client:
    time.sleep(1)
    client.preview()

Hello iBelow,
I doing my python flask project to capture the RTSP Camera have same problem
I think the problem is base on the client = rtsp.Client("rtspUrl") is not ready to connect rtsp server
then the check connection status command "client.isOpened()" is true
and the python code sequence execute the client.preview() command to read the rtsp video frame
so when you call the function client.preview() or client.read().save()
it will alert the thread fail message on terminal
in my solution to fix it,
i import "time" package and add the "time.sleep(1)" to wait the connection

import rtsp
import time

uri = f"rtsp://10.0.0.160:554/live.sdp"
with rtsp.Client(rtsp_server_uri=uri) as client:
    time.sleep(1)
    client.preview()

Thanx!

Add time.sleep(1) does solve the above Assertion, but the gunicorn consumes too much CPU 90-100% and start spawning new PID:
gunicorn[32285]: [2021-07-06 22:47:08 +0700] [13893] [INFO] Booting worker with pid: 13893.

Any suggestion?