switchbin doesn't negotiate requested resolution from webcam
Describe your issue
I'm a somewhat puzzled on how switchbin element does negotiation.
Below are minimal examples just for the problem demonstration. Real life code will include more paths to switchbin.
# Next 3 work well
gst-launch-1.0 -v v4l2src device=/dev/video0 ! switchbin num-paths=1 path0::caps="image/jpeg,with=1280,height=720" ! jpegdec ! videoconvert ! autovideosink
gst-launch-1.0 -v v4l2src device=/dev/video0 ! switchbin num-paths=1 path0::caps="image/jpeg,with=320,height=240" ! jpegdec ! videoconvert ! autovideosink
gst-launch-1.0 -v v4l2src device=/dev/video0 ! switchbin num-paths=1 path0::caps="image/jpeg,with=1280,height=720" path0::element="jpegdec" ! videoconvert ! autovideosink
# but the next one doesn't work
gst-launch-1.0 -v v4l2src device=/dev/video0 ! switchbin num-paths=1 path0::caps="image/jpeg,with=320,height=240" path0::element="jpegdec" ! videoconvert ! autovideosink
I can't explain why. But according to the log the failing sample just took the first available caps from v4l2src, which is image/jpeg, width=1280, height=720, framerate=30/1
and didn't even try to negotiate with any other, regardless v4l2src also declares image/jpeg, width=320, height=240, framerate=30/1
.
Looks like a bug.
Expected Behavior
Requested resolution is negotiated
Observed Behavior
Setup
- Operating System: Gentoo
- Device: Laptop MSI GL75 9SDK
- GStreamer Version: 1.22.3
- Command line: ? bash/konsole
Steps to reproduce the bug
- open terminal
- type
gst-launch-1.0 -v v4l2src device=/dev/video0 ! switchbin num-paths=1 path0::caps="image/jpeg,with=320,height=240" path0::element="jpegdec" ! videoconvert ! autovideosink
Additional Information
The command above opens a window with single static frame for less than a second and closes immediately.
0:00:00.674750199 373216 0x7f7428000d10 INFO GST_STATES gstelement.c:2716:_priv_gst_element_state_changed:<pipeline0> notifying about state-changed PAUSED to PLAYING (VOID_PENDING pending)
0:00:00.674894259 373216 0x55ce4cadf330 INFO bin gstbin.c:2767:gst_bin_do_latency_func:<pipeline0> configured latency of 0:00:00.048333333
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0: crop-bounds = < (int)0, (int)0, (int)424, (int)240 >
0:00:00.687233331 373216 0x7f7428000b70 INFO v4l2src gstv4l2src.c:854:gst_v4l2src_negotiate:<v4l2src0> fixated to: image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1
0:00:00.687266699 373216 0x7f7428000b70 INFO GST_EVENT gstevent.c:918:gst_event_new_caps: creating caps event image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1
0:00:00.687322122 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
0:00:00.687337726 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
0:00:00.687343283 373216 0x7f7428000b70 WARN GST_PADS gstpad.c:4361:gst_pad_peer_query:<v4l2src0:src> could not send sticky events
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1
0:00:00.688144772 373216 0x7f7428000b70 WARN v4l2 gstv4l2object.c:4440:gst_v4l2_object_set_crop:<v4l2src0:src> VIDIOC_S_CROP failed
0:00:00.712830318 373216 0x7f7428000b70 INFO v4l2 gstv4l2object.c:4035:gst_v4l2_object_set_format_full:<v4l2src0:src> Set capture framerate to 30/1
0:00:00.712850244 373216 0x7f7428000b70 WARN v4l2 gstv4l2object.c:3258:gst_v4l2_object_reset_compose_region:<v4l2src0:src> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Недопустимый аргумент
0:00:00.712855689 373216 0x7f7428000b70 INFO v4l2 gstv4l2object.c:3194:gst_v4l2_object_setup_pool:<v4l2src0:src> accessing buffers via mode 4
0:00:00.712924496 373216 0x7f7428000b70 INFO v4l2bufferpool gstv4l2bufferpool.c:586:gst_v4l2_buffer_pool_set_config:<v4l2src0:pool1:src> increasing minimum buffers to 2
0:00:00.712929207 373216 0x7f7428000b70 INFO v4l2bufferpool gstv4l2bufferpool.c:599:gst_v4l2_buffer_pool_set_config:<v4l2src0:pool1:src> reducing maximum buffers to 32
0:00:00.712952484 373216 0x7f7428000b70 INFO v4l2bufferpool gstv4l2bufferpool.c:599:gst_v4l2_buffer_pool_set_config:<v4l2src0:pool1:src> reducing maximum buffers to 32
0:00:00.713605268 373216 0x7f7428000b70 WARN v4l2bufferpool gstv4l2bufferpool.c:848:gst_v4l2_buffer_pool_start:<v4l2src0:pool1:src> Uncertain or not enough buffers, enabling copy threshold
0:00:01.128822853 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
0:00:01.128907610 373216 0x7f7428000b70 WARN basesrc gstbasesrc.c:3132:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:01.128928899 373216 0x7f7428000b70 WARN basesrc gstbasesrc.c:3132:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
0:00:01.128965241 373216 0x7f7428000b70 INFO GST_ERROR_SYSTEM gstelement.c:2281:gst_element_message_full_with_details:<v4l2src0> posting message: Internal data stream error.
ОШИБКА: из элемента /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Дополнительная отладочная информация:
../gstreamer-1.22.3/libs/gst/base/gstbasesrc.c(3132): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
0:00:01.129116749 373216 0x7f7428000b70 INFO GST_ERROR_SYSTEM gstelement.c:2308:gst_element_message_full_with_details:<v4l2src0> posted error message: Internal data stream error.
0:00:01.129170285 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
0:00:01.129208187 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)true, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
0:00:01.129260135 373216 0x7f7428000b70 WARN GST_CAPS gstpad.c:5787:pre_eventfunc_check:<switchbin0:sink> caps image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, parsed=(boolean)truExecution ended after 0:00:00.997273841
e, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:5:1 not accepted
Установка конвейера в состояние NULL…
0:00:01.129366704 373216 0x55ce4cadf330 INFO GST_STATES gstbin.c:2480:gst_bin_element_set_state:<autovideosink0> current PLAYING pending VOID_PENDING, desired next PAUSED
name : HD Webcam (V4L2)
class : Video/Source
caps : image/jpeg, width=1280, height=720, framerate=30/1
image/jpeg, width=320, height=180, framerate=30/1
image/jpeg, width=320, height=240, framerate=30/1
image/jpeg, width=352, height=288, framerate=30/1
image/jpeg, width=424, height=240, framerate=30/1
image/jpeg, width=640, height=360, framerate=30/1
image/jpeg, width=640, height=480, framerate=30/1
image/jpeg, width=848, height=480, framerate=30/1
image/jpeg, width=960, height=540, framerate=30/1
video/x-raw, format=YUY2, width=1280, height=720, framerate=10/1
video/x-raw, format=YUY2, width=320, height=180, framerate=30/1
video/x-raw, format=YUY2, width=320, height=240, framerate=30/1
video/x-raw, format=YUY2, width=352, height=288, framerate=30/1
video/x-raw, format=YUY2, width=424, height=240, framerate=30/1
video/x-raw, format=YUY2, width=640, height=360, framerate=30/1
video/x-raw, format=YUY2, width=640, height=480, framerate=30/1
video/x-raw, format=YUY2, width=848, height=480, framerate=20/1
video/x-raw, format=YUY2, width=960, height=540, framerate=15/1
properties:
api.v4l2.cap.bus_info = usb-0000:00:14.0-13
api.v4l2.cap.capabilities = 84a00001
api.v4l2.cap.card = HD Webcam: HD Webcam
api.v4l2.cap.device-caps = 04200001
api.v4l2.cap.driver = uvcvideo
api.v4l2.cap.version = 6.8.1
api.v4l2.path = /dev/video0
device.api = v4l2
device.devids = 20736
device.id = 41
device.product.id = 0x211
device.vendor.id = 0x598
factory.name = api.v4l2.source
media.class = Video/Source
node.description = HD Webcam (V4L2)
node.name = v4l2_input.pci-0000_00_14.0-usb-0_13_1.0
node.nick = HD Webcam
node.pause-on-idle = false
object.path = v4l2:/dev/video0
priority.session = 1000
factory.id = 10
client.id = 34
clock.quantum-limit = 8192
media.role = Camera
node.driver = true
object.id = 45
object.serial = 45
gst-launch-1.0 pipewiresrc target-object=45 ! ...