Nvv4l2decoder rtsp delay

hello, i I use a webcam on nx, this is my code:

int main(void)
std::string pipe = “rtspsrc protocols=0x00000001 location=rtsp://admin:admin123@ latency=0 drop-on-latency=true max-size-buffers=0 ! rtph264depay ! nvv4l2decoder enable-max-performance=1 disable-dpb=1 ! nvvidconv output-buffers=1 ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink sync=0”;
cv::VideoCapture cap(pipe, cv::CAP_GSTREAMER);

    if( !cap.isOpened() )
            std::cout << "Not good, open camera failed" << std::endl;
            return 0;
    cv::namedWindow("Frame", cv::WINDOW_AUTOSIZE);
    cv::Mat frame;
            cap >> frame;
            cv::resize(frame, frame, cv::Size(800, 640), 0, 0);
            cv::imshow("Frame", frame);


now i got 200ms delay, I want to reduce the delay to 100 milliseconds or less,what can i do?

A few things to try:

  • resize with nvvidconv instead of opencv that is CPU implementation, that may help. Just resize specifying new resolution in caps after nvvidconv:
... ! nvvidconv ! video/x-raw, format=BGRx, width=800, height=640 ! ...
  • opencv imshow is not very fast on Jetson. You may try a VideoWriter with a gstreamer pipeline to a displaysink instead. Searching this forum you may find some examples.

  • Using rtspsrc latency=0 may not lead to best latency… It depends on your network. Better start with a few (say 10) frames latency and use sync=true, then try decreasing and see.

thanks a lot, i will try。