I want to use the test-launch command to create an RTSP streaming server for testing the stream of cameras on Orin Nano, but after executing the following command, it cannot pass rtsp://:8554/test Obtain stream data
The error looks to be on the nvarguscamerasrc element. Have you tried a simple basic capture-display pipe? Just to validate you can get frames from the source?
Hi @enrique.ramirez
When I use gst-launch-1.0 to preview, it works. Now I have successfully implemented streaming using RTSP。The command is as follows:
After executing the command, there were no errors, but there was also no preview. I would like to modify the command to be implemented in Python after successful testing to facilitate obtaining frame data for target recognition。
It seems to be a data format issue sent to appsink, but I don’t know what data formats appsink supports
How can I use python/c++ to implement the function of pulling RTSP stream?
Hi @DaneLLL :
Thank for your answer.
I only use the command to test that RTSP is working properly. I need to use Python/C++to obtain the RTSP stream and decode it into the format required by the object recognition algorithm. When I use the command to test, both xvimagesink and nv3dsink can work properly.
I am currently using Python to obtain the stream, but it always fails. I tested and found that Python requires the sink to be appsink, but when I use the appsink program, it blocks in cv2. VideoCap().
Here is my program:
import cv2
def gstreamer_pipeline():
return (
"rtspsrc location=rtsp://192.168.0.12:8554/test protocols=udp latency=100 ! "
"rtph264depay ! h264parse ! nvv4l2decoder ! "
"videoconvert ! appsink"
)
#gst-launch-1.0 rtspsrc location=rtsp://192.168.0.12:8554/test protocols=udp latency=100 ! rtph264depay ! h264parse ! nvv4l2decoder ! autovideoconvert ! autovideosink
def show_camera():
window_title = "gimabal camera"
print(gstreamer_pipeline())
cap = cv2.VideoCapture(gstreamer_pipeline(), cv2.CAP_GSTREAMER)
if not cap.isOpened():
print("Unable to open camera...")
exit()
try:
winHdl = cv2.namedWindow(window_title, cv2.WINDOW_AUTOSIZE)
while True:
ret, frame = cap.read()
if not ret:
print("Err: unable to read frame...")
exit()
if cv2.getWindowProperty(window_title,cv2.WND_PROP_AUTOSIZE) >= 0:
cv2.imshow(window_title, frame)
else:
break
keyCode = cv2.waitKey(10) & 0xFF
if keyCode == 27 or keyCode == ord('q'):
break
finally:
cap.release()
winHdl.destroyAllWindows()
if __name__ == "__main__":
show_camera()
Hi,
From our experience, if the gstreamer pipeline works in gst-launch-1.0 command with fakesink, it shall work same in cv2.VideoCapture() with appsink. It’s strange you can successfully run the gst-launch-1.0 command but fails in OpenCV.