Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

performance of videoCapture with gst pipeline

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");
}

performance of videoCapture with gst pipeline

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");
}

Edit: gst pipeline that generate the smaller file took less than a second, hence im expecting OpenCV will take less than 8 seconds instead of the actual 28 sec

performance of videoCapture with gst pipeline

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");
}

Edit: gst pipeline that generate generates the smaller file took less than a second, hence im expecting OpenCV will take less than 8 seconds instead of the actual 28 sec

performance of videoCapture with gst pipeline

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");
}

Edit: gst pipeline that generates the smaller file took less than a second, hence im expecting OpenCV will take less than 8 15 seconds instead of the actual 28 sec