Open JohnDMcMaster opened 10 months ago
Looks like the core issue is we ignore gst_toupcam_src_set_caps(). This can detect the error and/or actually change the resolution as needed
set_caps() doesn't appear to be being called at all. However the python code appears to be attempting caps negotiation. Maybe try CLi to isolate the issue
self.raw_capsfilter.props.caps = Gst.Caps(
"video/x-raw,width=%u,height=%u" % (raw_w, raw_h))
self.player.add(self.raw_capsfilter)
if not self.source.link(self.raw_capsfilter):
raise RuntimeError("Couldn't set capabilities on the source")
Here is a reduced test case outside of pyuscope:
mcmaster@thudpad:~/doc/ext/pyuscope$ GST_DEBUG=3,toupcamsrc:5 gst-launch-1.0 toupcamsrc esize=0 ! video/x-raw,width=1280,height=720 ! queue ! videoconvert ! xvimagesink
0:00:00.036572975 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:482:gst_toupcam_src_class_init: Using gst_toupcam_src_fill
Setting pipeline to PAUSED ...
0:00:00.043796227 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1174:gst_toupcam_src_start:<toupcamsrc0> gst_toupcam_src_start(): begin
0:00:00.043810526 769125 0x55f2eb9f2240 INFO toupcamsrc gsttoupcamsrc.c:1181:gst_toupcam_src_start:<toupcamsrc0> ToupCam Library Ver 53.21907.20221218
0:00:00.044223666 769125 0x55f2eb9f2240 INFO toupcamsrc gsttoupcamsrc.c:1186:gst_toupcam_src_start:<toupcamsrc0> Found 1 devices
0:00:00.044230195 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1192:gst_toupcam_src_start:<toupcamsrc0> Toupcam_Open()
0:00:00.408685355 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1273:gst_toupcam_src_start:<toupcamsrc0> setup image mode: regular
0:00:00.408709339 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1318:gst_toupcam_src_start:<toupcamsrc0> Image 5440 w x 3648 h, in 3 bytes / pix => 59535360 bytes (59.5 MB), out 3 bytes / pix => 59535360 bytes (59.5 MB)
0:00:00.484679020 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.484695545 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.556650497 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.556665940 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.648661455 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.648685636 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.650652179 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.650667200 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.658763025 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1337:gst_toupcam_src_start:<toupcamsrc0> gst_toupcam_src_start(): ok
Pipeline is live and does not need PREROLL ...
0:00:00.658900217 769125 0x55f2eba2d860 FIXME default gstutils.c:3980:gst_pad_create_stream_id_internal:<toupcamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.659001925 769125 0x55f2eba2d860 WARN video-info video-info.c:727:gst_video_info_to_caps: invalid matrix 0 for RGB format, using RGB
0:00:00.659026836 769125 0x55f2eba2d860 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop:<toupcamsrc0> error: Internal data stream error.
0:00:00.659032225 769125 0x55f2eba2d860 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop:<toupcamsrc0> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstToupCamSrc:toupcamsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstToupCamSrc:toupcamsrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
0:00:00.659296659 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1355:gst_toupcam_src_stop:<toupcamsrc0> gst_toupcam_src_stop()
Freeing pipeline ...
0:00:00.745420017 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:996:gst_toupcam_src_dispose:<toupcamsrc0> dispose
0:00:00.745431129 769125 0x55f2eb9f2240 DEBUG toupcamsrc gsttoupcamsrc.c:1010:gst_toupcam_src_finalize:<toupcamsrc0> finalize
Here is a "working" run. Hmm the caps negotiation maybe happens later and gstreamer makes bad assumptions about the format being supported?
mcmaster@thudpad:~/doc/ext/pyuscope$ GST_DEBUG=3,toupcamsrc:5 gst-launch-1.0 toupcamsrc esize=0 ! video/x-raw,width=5440,height=3648 ! queue ! videoconvert ! xvimagesink
0:00:00.038986141 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:482:gst_toupcam_src_class_init: Using gst_toupcam_src_fill
Setting pipeline to PAUSED ...
0:00:00.108452945 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1174:gst_toupcam_src_start:<toupcamsrc0> gst_toupcam_src_start(): begin
0:00:00.108473085 769169 0x5623536c9240 INFO toupcamsrc gsttoupcamsrc.c:1181:gst_toupcam_src_start:<toupcamsrc0> ToupCam Library Ver 53.21907.20221218
0:00:00.108864387 769169 0x5623536c9240 INFO toupcamsrc gsttoupcamsrc.c:1186:gst_toupcam_src_start:<toupcamsrc0> Found 1 devices
0:00:00.108871639 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1192:gst_toupcam_src_start:<toupcamsrc0> Toupcam_Open()
0:00:00.476196277 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1273:gst_toupcam_src_start:<toupcamsrc0> setup image mode: regular
0:00:00.476297110 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1318:gst_toupcam_src_start:<toupcamsrc0> Image 5440 w x 3648 h, in 3 bytes / pix => 59535360 bytes (59.5 MB), out 3 bytes / pix => 59535360 bytes (59.5 MB)
0:00:00.552927147 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.552952558 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.624980222 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.625036302 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.716613208 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.716668788 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.718666231 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.718720638 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:00.726844848 769169 0x5623536c9240 DEBUG toupcamsrc gsttoupcamsrc.c:1337:gst_toupcam_src_start:<toupcamsrc0> gst_toupcam_src_start(): ok
Pipeline is live and does not need PREROLL ...
0:00:00.727316942 769169 0x562353707460 FIXME default gstutils.c:3980:gst_pad_create_stream_id_internal:<toupcamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.727690352 769169 0x562353707460 WARN video-info video-info.c:727:gst_video_info_to_caps: invalid matrix 0 for RGB format, using RGB
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.728320675 769169 0x562353707460 INFO toupcamsrc gsttoupcamsrc.c:1425:gst_toupcam_src_set_caps:<toupcamsrc0> The caps being set are video/x-raw, format=(string)RGB, width=(int)5440, height=(int)3648, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)0:1:0:0, framerate=(fraction)0/1
0:00:00.732738077 769169 0x562353707460 DEBUG toupcamsrc gsttoupcamsrc.c:1684:gst_toupcam_src_fill:<toupcamsrc0> gst_toupcam_src_fill()
0:00:00.732779189 769169 0x562353707460 DEBUG toupcamsrc gsttoupcamsrc.c:1696:gst_toupcam_src_fill:<toupcamsrc0>
0:00:00.732797571 769169 0x562353707460 DEBUG toupcamsrc gsttoupcamsrc.c:1697:gst_toupcam_src_fill:<toupcamsrc0> waiting for new image
0:00:00.892604670 769169 0x7f9e5c002350 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) begin, want 4
0:00:00.892715459 769169 0x7f9e5c002350 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=1) end, images now 0 w/ 0 pulled
0:00:01.139174908 769169 0x7f9e64003af0 DEBUG toupcamsrc gsttoupcamsrc.c:1020:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=4) begin, want 4
0:00:01.139214302 769169 0x7f9e64003af0 DEBUG toupcamsrc gsttoupcamsrc.c:1029:sdk_callback_PullMode:<toupcamsrc0> sdk_callback_PullMode(nEvent=4) end, images now 1 w/ 0 pulled
0:00:01.139230475 769169 0x562353707460 DEBUG toupcamsrc gsttoupcamsrc.c:1563:pull_decode_frame:<toupcamsrc0> minfo size 59535360, maxsize 59535367, flags 0x00000002
Maybe there are some issues related to this starting as a 0.10 plugin? There are some points on Pad (not Element) get vs query caps. But its unclear if these effect GstElement
https://github.com/ApsOps/GStreamer-0.10-to-1.0-porting-guide/blob/master/porting-to-1.0.md
"GstPad: gst_pad_get_caps() was replaced by gst_pad_query_caps(), it does not return writable caps anymore and an explicit gst_caps_make_writable() needs to be performed. This was the functionality of gst_pad_get_caps_reffed(), which is removed now."
What happens if we have a resolution mismatch with a v4l2src? Does it handle it more gracefully?
I've posted this question to the gstreamer IRC channel, hopefully can help provide some guidance
Some confusing debugging after cascading error from https://github.com/Labsmore/pyuscope/issues/370
Sample crash below. We should at a minimum detect the resolution mismatch if we can't somehow better detect a caps negotation failure