I’m trying to develop an application that processes frames from an IP camera.
The IP camera streams at 30fps (fixed).
However, the processing in my application works at 10fps.
Therefore, it is necessary to thin out the frames.
How can I achieve this?
For now, we are considering a method that uses multithreading.
Development Environment
HW : Xavier NX
SW : JetaPack 4.4
Thank you for your suggestion.
I use gstreamer pipeline and opencv videocapture.
Your code is pass through situation (IP cam → DIsplay) .
But my goal is " IP cam@30fps → some processing( need 10fps=100ms) → display, other)".
Hi,
Please try nvv4l2decoder and configure the property:
drop-frame-interval : Interval to drop the frames,ex: value of 5 means every 5th frame will be given by decoder, rest all dropped
flags: readable, writable, changeable only in NULL or READY state
Unsigned Integer. Range: 0 - 30 Default: 0
For 30fps → 10fps, please set drop-frame-interval=3.
The solution provided by @DaneLLL would be much more efficient than videorate.
Just remove h264parse before nvv4l2decoder (this is a known issue in nvv4l2decoder with H264 streams in byte-stream format).
The problem may be with framerate not set. You may try to specify one such as: ... ! rtph264depay ! video/x-h264, clock-rate=90000, framerate=24/1 ! nvv4l2decoder ...
I tried to set frame rate as below, but it did not play.
“rtspsrc location=rtsp:// latency=300 ! rtph264depay ! video/x-h264, clock-rate=90000, framerate=30/1 ! nvv4l2decoder drop-frame-interval=10 ! nvvidconv ! video/x-raw,format=BGRx, width=1920, height=1080, framerate=30/1 ! videoconvert ! video/x-raw, format=BGR ! appsink”
And my opencv code is as below.
//get pipeline from command line
pipeline = std::string(argv[1]);
std::cout << pipeline << std::endl;
cap = cv::VideoCapture(pipeline);
cap.open();
if (cap.isOpened()){
cv::namedWindow(“demo”, cv::WINDOW_AUTOSIZE);
while(1){
cap.read(img);
cv::imshow(“demo”,img);
//cv::waitKey(10);
}
}
else{
std::cout << " rtsp open failed \n";
}
cv::destroyAllWindows();
return 0;}
First try my pipeline, it uses a public online sample, so it should be ok for you if your jetson is connected to internet.
You would specify gstreamer API for videoCapture:
cap = cv::VideoCapture(pipeline, cv::CAP_GTSREAMER);
And you would uncomment the waitKey which is mandatory after imshow (you may use 1ms instead of 10).