Hi,
i have 2 files "t1.ts" & "t1_small.ts". t1_small.ts is a 1fps version of the t1.ts (which is 8fps) and generated by gst pipeline:
gst-launch-1.0 -v filesrc location="t1.ts" ! decodebin ! videorate ! video/x-raw,framerate=1/1 ! omxh264enc ! h264parse ! mpegtsmux ! filesink location=t1_small.ts
Now I'm just reading the frames of those files using
VideoCapture videoCapture = new VideoCapture("t1_small.ts", CAP_GSTREAMER);
and
VideoCapture videoCapture = new VideoCapture("filesrc location=t1.ts ! decodebin ! videorate ! video/x-raw,framerate=1/1 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink", CAP_GSTREAMER);
My question: the first one took 14 seconds (with t1_small) and the second took 28 seconds (t1.ts) even though it read the same number of frames (28 frames total in both cases). the pipeline which generated the smaller file is the same one that we passed to VideoCapture. why there is a big difference in performance
the code that i used for testing
Test(final String path)
{
final Mat f = new Mat(640, 480, CvType.CV_8UC3);
final long start = System.nanoTime();
final VideoCapture videoCapture = new VideoCapture("filesrc location="+path+" ! decodebin ! videorate ! video/x-raw,framerate=1/1 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink", CAP_GSTREAMER);
//final VideoCapture videoCapture = new VideoCapture(path, CAP_GSTREAMER);
if (videoCapture.isOpened())
{
while (videoCapture.read(f))
{
double pos_frame = videoCapture.get(CAP_PROP_POS_FRAMES);
System.out.println("pos_frame: " + pos_frame);
}
}
f.release();
videoCapture.release();
final long milliseconds = (System.nanoTime() - start) / 1000000L;
System.out.println("[Time]: " + milliseconds / 1000f + " s");
}