Prevent GStreamer from changing camera format

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Prevent GStreamer from changing camera format

Nikola Pantelic
(This question is also available at
https://stackoverflow.com/questions/64415461.)


Running GStreamer pipeline that feeds from v4l2src element may change
camera format implicitly.

Here is an example (also note that /dev/video0 is everywhere implied).

One of my cameras supports these formats

$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
        Size: Discrete 1280x800
            Interval: Discrete 0.133s (7.500 fps)
        Size: Discrete 1280x1024
            Interval: Discrete 0.133s (7.500 fps)

The current format is

$ v4l2-ctl --get-fmt-video
Format Video Capture:
    Width/Height      : 640/480
    Pixel Format      : 'YUYV' (YUYV 4:2:2)
    Field             : None
    Bytes per Line    : 1280
    Size Image        : 614400
    Colorspace        : Default
    Transfer Function : Default (maps to Rec. 709)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Limited Range)
    Flags             :

If I just run this pipeline

$ gst-launch-1.0 -e v4l2src ! videoconvert ! autovideosink

This will change the current format (before the pipeline is run, but
it will also be left in that state) to

$ v4l2-ctl --get-fmt-video
Format Video Capture:
    Width/Height      : 1280/1024
    Pixel Format      : 'YUYV' (YUYV 4:2:2)
    Field             : None
    Bytes per Line    : 2560
    Size Image        : 2621440
    Colorspace        : Default
    Transfer Function : Default (maps to Rec. 709)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Limited Range)
    Flags             :

And this is not what I want. What I want is for GStreamer to use
already set format and not change it. How I can accomplish that
programmatically (gst-launch-1.0 was just an example, I'm primarily
interested in doing this in code)?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Prevent GStreamer from changing camera format

Nicolas Dufresne-5


Le dim. 18 oct. 2020 17 h 00, Nikola Pantelic <[hidden email]> a écrit :
(This question is also available at
https://stackoverflow.com/questions/64415461.)


Running GStreamer pipeline that feeds from v4l2src element may change
camera format implicitly.

Here is an example (also note that /dev/video0 is everywhere implied).

One of my cameras supports these formats

$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
        Size: Discrete 1280x800
            Interval: Discrete 0.133s (7.500 fps)
        Size: Discrete 1280x1024
            Interval: Discrete 0.133s (7.500 fps)

The current format is

$ v4l2-ctl --get-fmt-video
Format Video Capture:
    Width/Height      : 640/480
    Pixel Format      : 'YUYV' (YUYV 4:2:2)
    Field             : None
    Bytes per Line    : 1280
    Size Image        : 614400
    Colorspace        : Default
    Transfer Function : Default (maps to Rec. 709)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Limited Range)
    Flags             :

If I just run this pipeline

$ gst-launch-1.0 -e v4l2src ! videoconvert ! autovideosink

This will change the current format (before the pipeline is run, but
it will also be left in that state) to

$ v4l2-ctl --get-fmt-video
Format Video Capture:
    Width/Height      : 1280/1024
    Pixel Format      : 'YUYV' (YUYV 4:2:2)
    Field             : None
    Bytes per Line    : 2560
    Size Image        : 2621440
    Colorspace        : Default
    Transfer Function : Default (maps to Rec. 709)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Limited Range)
    Flags             :

And this is not what I want. What I want is for GStreamer to use
already set format and not change it. How I can accomplish that
programmatically (gst-launch-1.0 was just an example, I'm primarily
interested in doing this in code)?

When it reach ready state, you can get through properties the device fd, you can then configure a caps filter to preserve the last format used.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel