Search code examples
windowscameravideo-streaminggstreameruvc

How to get encoded stream coming from UVC with Gstreamer on Windows


I want to get encoded stream coming from Logitech HD Webcam (UVC) on Windows with Gstreamer. I know on Linux you can access via /dev/video1 and etc. However, I don't know how to do it on Windows.

I can get raw buffers via ksvideosrc on Windows but that doesn't solve my problem. I must get hardware encoded stream. If you know any other library rather than Gstreamer, guide me please.

I expect the output like this but for Windows version.
gst-launch-1.0 v4l2src device=/dev/video0 ! decodebin ! ximagesink


Solution

  • I found a solution for people who will have this problem.

    gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! decodebin ! ximagesink
    


    This will attach the camera's encoded stream, and decode with decodebin and gives the output to the Window. If you do not write image/jpeg etc. , it will automatically attachs to the raw buffer from camera.

    In C++ Code, it is like

    GstElement* v4l2src = gst_element_factory_make("v4l2src","Source");
    GstElement* srcFilter = gst_element_factory_make("capsfilter","Filter");
    

    then you will add them into pipeline and link them. That will do.
    Note: If the camera does not support that resolution and media type, it will give

    streaming stopped, reason not-negotiated (-4)
    

    error.