Using Gstreamer Pipeline in openCV, Why my pipeline works when I add videoconvert element before appsink ?

asked 2020-09-28 07:23:22 -0600

sarslan gravatar image

Hello, I am trying to use gstreamer pipeline in OpenCV. For this purpose, I created the instance of VideoCapture class as following:

cv::VideoCapture cap{"filesrc location=/home/10_Years_Compiling_blue_1280x720.jpg ! "
        "jpegdec ! "
        "videoconvert ! "
        "video/x-raw, format=RGB ! "
        "videoconvert ! "
        "video/x-raw, format=UYVY ! "
        "appsink "};

Then I apply mine custom convertion algorithm and the resulting output of this algorithm is raw frame with nv12 format. I am trying to send this frame to gstreamer pipeline using following VideoWriter instance.

cv::VideoWriter writer { "appsrc ! "
        "videoconvert ! "
        "filesink location=/home/refout.nv12",
        30.0, // fps
        cv::Size{WIDTH, HEIGHT},

But the resulting refout.nv12 file does not contain any bytes. When I insert videoconvert element right before the appsink element in VideoCapture, I can successfully obtain the "refout.nv12".

So, What is the effect of "videoconvert" element in this situation ? Is there any way to run spesified example successfully without "videoconvert" element ?


edit retag flag offensive close merge delete