Cannot capture window image with ximagesrc and xid : X reports invalid parameter attributes
I am trying to pinpoint why I sometimes (and unpredictably !) get a black video instead of the image of the selected window in Kazam screencast. It uses GStreamer for capturing so I tried to run a capture using the command line example in the GStreamer documentation.
I can (seemingly always) capture the whole desktop with
gst-launch-1.0 ximagesrc ! video/x-raw,framerate=5/1 ! videoconvert ! theoraenc ! oggmux ! filesink location=/tmp/desktop.ogg
However, specifying an xid gives various results. Sometimes it just works. Sometimes it fails with
X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 130 (MIT-SHM) Minor opcode of failed request: 4 (X_ShmGetImage) Serial number of failed request: 42 Current serial number in output stream: 42
Sometimes it seems to start recording normally but on Ctrl-C'ing it, it says
^Chandling interrupt. Interruption : arrêt du pipeline… Execution ended after 0:00:04.728716374 Définition du pipeline à PAUSED... Définition du pipeline à READY (prêt)…
then seems to stall for several minutes before concluding
Définition du pipeline à NULL… Libération du pipeline…
and the resulting video is a corrupted file.
This is with
GStreamer 1.16.2 X.Org X Server 1.20.9 kernel 5.8.0-50-lowlatency KUbuntu 20.04 KDE Framework 5.68.0 nvidia driver, 460.73.01
Capturing the same window with OBS works without a problem on the same system.