I’m working on a program that passes a Gstreamer pipeline to OpenCV via the cv2.VideoCapture() function on a Jetson Xavier NX board, but I’ve been running into issues. Every few seconds, the video becomes pixelated and distorted, like so:
Here is the pipeline I’ve been using:
"rtspsrc location=rtsp://local-ip/ latency=15 ! rtph265depay ! h265parse ! nvv4l2decoder ! "
"nvvidconv ! video/x-raw, width=640, height=480, format=BGRx ! videoconvert ! appsink"
After exploring posts for similar issues, it seems the likeliest culprit is packets getting lost across the rtsp network.
Looking through some options, I found that there is a plugin called rtpjitterbuffer, where:
If the “do-lost” property is set, lost packets will result in a custom serialized
downstream event of name GstRTPPacketLost. The lost packet events are
usually used by a depayloader or other element to create concealment data
or some other logic to gracefully handle the missing packets.
I reworked my pipeline to have jitter buffer leading into a rtph265depay plugin in the hopes the above-mentioned data concealment would appear, but the pixelation still occurred at approximately the same rate. Here is that pipeline:
"rtspsrc location=rtsp://local-ip/ latency=15 ! rtpjitterbuffer do-lost=true ! rtph265depay ! h265parse ! "
"nvv4l2decoder ! nvvidconv ! video/x-raw, width=640, height=480, format=BGRx ! videoconvert ! appsink"
The next thing I found was that rtpjitterbuffer has two parameters stats
and post-drop-messages
that can output the number of packets lost during a stream. I was hoping to use one of these to verify my packet loss theory, but for the life of me I could not figure out how to set them up or save the output data.
stats
info found here: link
post-drop-messages
info found here: link
With that all out of the way, I was wondering if anyone knew either:
-
How to configure rtpjitterbuffer to conceal lost packets across an rtsp gstreamer pipeline
-
How to configure rtpjitterbuffer to print/write the number of lost packets in a stream to the command line or a file
Any help or advice would be greatly appreciated!