Running OBS from cron job - qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

tomcroll

New Member
Hi Folk,
This is my first time on this forum, so if I have logged this incorrectly please let me know.
I am relatively new to obs and Ubuntu.

I have written a script that runs obs as required when run from the command line.
But when I run it from my (user) crontab it fails with the error message:
"qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb."


I can see on various linux forums this is a frequent error when running "Qt platform" apps from crontab. Each app seems to have it's own unique fix.
Has anybody come across this with obs?
I am running Ubuntu 20.4 and installed OBS 27.0.1 64bit, using Ubuntu's "snap" installer.

My script: myobs.sh.
# Setup Debug to get error details.
export QT_DEBUG_PLUGINS=1
# Get Date and time for log file names.
now=$( date +%Y-%m-%d-%H:%M:%S )
myobs=`cat /home/pats/Documents/LiveStreamFiles/myobs.sh | grep Normal`
echo "$now, $myobs" >> /home/pats/Documents/myobs.log
# Test for day of week and run OBS Scene for that day.
case $(LC_ALL=C date +"%u") in
(1) obs-studio --startrecording --profile PATS --collection PatsScenes --scene mondayscene echo --disable-updater "$now, $myobs" >> /home/pats/Documents/myobs$now.log 2>&1 &;;
(2) obs-studio --startrecording --profile PATS --collection PatsScenes --scene tuesdayscene echo --disable-updater "$now, $myobs" >> /home/pats/Documents/myobs$now.log 2>&1 &;;
(3) obs-studio --startrecording --profile PATS --collection PatsScenes --scene wednesdayscene echo --disable-updater "$now, $myobs" >> /home/pats/Documents/myobs$now.log;;
(4) obs-studio --startrecording --profile PATS --collection PatsScenes --scene thursdayscene echo --disable-updater "$now, $myobs" >> /home/pats/Documents/myobs$now.log;;
(5) obs-studio --startrecording --profile PATS --collection PatsScenes --scene fridayscene echo --disable-updater "$now, $myobs" >> /home/pats/Documents/myobs$now.log;;
(6) obs-studio --startrecording --profile PATS --collection PatsScenes --scene saturdayscene --disable-updater echo "$now, $myobs" >> /home/pats/Documents/myobs$now.log;;
(7) obs-studio --startrecording --profile PATS --collection PatsScenes --scene sundayscene --disable-updater echo "$now, $myobs" >> /home/pats/Documents/myobs$now.log;;
esac

If I run this script from the command line it works well, obs runs with the correct Profile and Scene, recording starts, and log files are written as expected.

Now to automate using crontab.....
crontab entry:
# run obs at 17:55 every day with the scene for the appropriate day of the week.
55 20 * * * /home/pats/Documents/LiveStreamFiles/myobs.sh 2>&1 &

Obs does not run but the log files show:
1. myobs.log:
2021-09-14-00:45:01, rosary=`cat /home/pats/Documents/LiveStreamFiles/myobs.sh | grep Normal`
So, cron job is run.

2. myobsDateAandTime.log:
is created with errors.
QFactoryLoader::QFactoryLoader() checking directory path "/home/pats/platforms" ...
QFactoryLoader::QFactoryLoader() checking directory path "/snap/obs-studio/1258/opt/qt515/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqeglfs.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqeglfs.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"eglfs"
]
},
"archreq": 0,
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqlinuxfb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"linuxfb"
]
},
"archreq": 0,
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqminimal.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqminimal.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"archreq": 0,
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqminimalegl.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqminimalegl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimalegl"
]
},
"archreq": 0,
"className": "QMinimalEglIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqoffscreen.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqoffscreen.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"archreq": 0,
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqvnc.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqvnc.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"vnc"
]
},
"archreq": 0,
"className": "QVncIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-egl.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-egl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-egl"
]
},
"archreq": 0,
"className": "QWaylandEglPlatformIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("wayland-egl")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-generic.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-generic.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland"
]
},
"archreq": 0,
"className": "QWaylandIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("wayland")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-xcomposite-egl.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-xcomposite-egl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-xcomposite-egl"
]
},
"archreq": 0,
"className": "QWaylandXCompositeEglPlatformIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("wayland-xcomposite-egl")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-xcomposite-glx.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-xcomposite-glx"
]
},
"archreq": 0,
"className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("wayland-xcomposite-glx")
QFactoryLoader::QFactoryLoader() looking at "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqxcb.so"
Found metadata in lib /snap/obs-studio/1258/opt/qt515/plugins/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"xcb"
]
},
"archreq": 0,
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 331520
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/snap/obs-studio/1258/usr/lib/x86_64-linux-gnu/platforms" ...
QFactoryLoader::QFactoryLoader() checking directory path "/snap/obs-studio/1258/usr/bin/platforms" ...
loaded library "/snap/obs-studio/1258/opt/qt515/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.


3. syslog in /var/log has the following:

Sep 20 17:57:01 pats-AV-Tower CRON[21763]: (pats) CMD (/home/pats/Documents/LiveStreamFiles/myobs.sh 2>&1 & )
Sep 20 17:57:01 pats-AV-Tower dbus-daemon[3399]: [session uid=1000 pid=3399] Activating via systemd: service name='org.freedesktop.Tracker1' unit='tracker-store.service' requested by ':1.2' (uid=1000 pid=3395 comm="/usr/libexec/tracker-miner-fs " label="unconfined")
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: Starting Tracker metadata database store and lookup manager...
Sep 20 17:57:01 pats-AV-Tower dbus-daemon[3399]: [session uid=1000 pid=3399] Successfully activated service 'org.freedesktop.Tracker1'
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: Started Tracker metadata database store and lookup manager.
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: Started snap.obs-studio.obs-studio.3702e5b5-edb7-4a8f-8190-d8bef0734024.scope.
Sep 20 17:57:01 pats-AV-Tower dbus-daemon[3399]: [session uid=1000 pid=3399] Activating via systemd: service name='org.freedesktop.Tracker1.Miner.Extract' unit='tracker-extract.service' requested by ':1.2' (uid=1000 pid=3395 comm="/usr/libexec/tracker-miner-fs " label="unconfined")
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: Starting Tracker metadata extractor...
Sep 20 17:57:01 pats-AV-Tower tracker-extract[21854]: Set scheduler policy to SCHED_IDLE
Sep 20 17:57:01 pats-AV-Tower tracker-extract[21854]: Setting priority nice level to 19
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: snap.obs-studio.obs-studio.3702e5b5-edb7-4a8f-8190-d8bef0734024.scope: Succeeded.
Sep 20 17:57:01 pats-AV-Tower dbus-daemon[3399]: [session uid=1000 pid=3399] Successfully activated service 'org.freedesktop.Tracker1.Miner.Extract'
Sep 20 17:57:01 pats-AV-Tower systemd[3384]: Started Tracker metadata extractor.
Sep 20 17:57:13 pats-AV-Tower systemd[3384]: tracker-extract.service: Succeeded.

My attempts so far to fix this have been
Search the internet for the error shown in the log.

1. Remove and re-install obs with the included plugins from the Snap Store. Still did not work.
2. Remove and re-install obs direct from obs project.com then install the plugins I require as per the error message suggestions. Still did not work.
3. Remove and re-install obs with the plugins I require from the Snap Store. Still didn't work.
After each of the above 3 tries the error was the same (identical).

Several forums suggest the Qt Platform is loaded into directories for each App that uses it and the ENV PATH should reflect the appropriate directory structure for the App, obs in my case. Do I need to install the Qt Development platform? But surely not.

I am guessing this is valid information but unfortunately I can't work out what that path is therefore don't know what to add to PATH.

Also I don't understand how myobs.sh script works when I run it from the command line but does not run successfully from crontab.
a. permissions?
b. shell?
c. something else?

Any ideas or suggestions would be gratefully received.
Thanks in advance.
 

Attachments

  • myobs2021-09-20-17:57:01.log
    6.6 KB · Views: 19
  • syslog.log
    14.6 KB · Views: 9
  • myobs.log
    279 bytes · Views: 10

tomcroll

New Member
I have been trying to automatically LiveStream OBS-Studio, for sometime now.
My setup is Ubuntu 21.0.4 OBS-Studio 27.01.
After some research and me thinking about it I realised.....
crontab runs on the "console", if you like to think of it as an old tty terminal, not a GUI session.
Therefore I would have to tell crontab to run my script on my DISPLAY.

Now I understand what the problem was I put "DISPLAY=0" in the users crontab, before calling my script worked.

First I determined my DISPLAY number by: Typing echo $DISPLAY and pressing ENTER. This gave me 0 (zero).

My crontab now has: 55 20 * * * DISPLAY=:0 /home/pats/Documents/LiveStreamFiles/scripts/myscript.sh 2>&1 &
Thanks again and I hope this helps others...
 
Top