Video file reading by cv::VideoCapture and Gstreamer is slow

I’m making a CUDA application that uses video from a file.

I’m using cv::VideoCapture to get frame from video file.
But takes about 10ms/frame on Jetson TX2.
The video is 1920*1080 size.
jetson_clocks is enabled, and nvp model in MAXN.

My kernel is faster than 10ms, so the input is bottlenecking.

I’ve tried to use Gstreamer, but no change appears.
Is it normal that takes about 10ms/frame?
And if there are any ways to make reading faster, please let me know.
Thank you.

This is my test code.

#include <opencv2/opencv.hpp>
#include <chrono>
int main()
    cv::VideoCapture cap("filesrc location=myvideo.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw, format=(string)BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=(string)BGR ! appsink sync=false", cv::CAP_GSTREAMER);

    cv::Mat frame;
    for(int i=0; i < 100; i++)
		auto time_start = std::chrono::high_resolution_clock::now();;

		auto duration = std::chrono::high_resolution_clock::now() - time_start;
		std::cout << std::chrono::duration_cast<std::chrono::microseconds>(duration).count() << std::endl;
    return 0;

Sorry for the late response, is this still an issue to support? Thanks

Please try

  1. Use nvv4l2decoder and set enable-max-performance.
  2. Run hardware converter(VIC engine) at max clock:
    Nvvideoconvert issue, nvvideoconvert in DS4 is better than Ds5? - #3 by DaneLLL
  3. Can execute sudo tegrastasts to get syatem status and check which hardware engine caps performance

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.