On a RPi 5 with AI HAT+ and latest software, I’m trying to set the OBS virtual camera output (/dev/video4) as the input for pose estimation (in Python) and I get this error message:
INFO | common.core | All required environment variables loaded successfully.
INFO | common.core | Using default model: yolov8m_pose
INFO | common.core | Found HEF in resources: /usr/local/hailo/resources/models/hailo8/yolov8m_pose.hef
INFO | pose_estimation.pose_estimation_pipeline | Pipeline created successfully.
ERROR | gstreamer.gstreamer_app | GStreamer Error: gst-stream-error-quark: Internal data stream error. (1), debug: ../libs/gst/base/gstbasesrc.c(3187): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:source:
streaming stopped, reason not-negotiated (-4)
WARNING | gstreamer.gstreamer_app | Shutdown initiated
Shutting down... Hit Ctrl-C again to force quit.
ERROR | gstreamer.gstreamer_app | Exiting with error
/dev/video4 is correct, I can view it in VLC.
Do I have to use a specific video size or aspect ratio in OBS? I’ve tried 640x640 and 640x480 but I’m getting the same error.
OBS uses v4l2loopback for the virtual camera output.
I use two USB webcams on /dev/video0 and /dev/video2 combined in OBS, and turn on the virtual camera.
In Terminal v4l2-ctl -A shows all the v4l devices (/dev/video*) including the OBS output:
OBS Virtual Camera (platform:v4l2loopback-000): /dev/video4
After starting the venv, python pose_estimation.py -i /dev/video4 leads to the GStreamer error messages (see my first post).
VLC can show the /dev/video4 source, a combined view of the two webcams.
The difference I see is that the two webcams’ lights are on as they are read by OBS, and then the pose estimation script should pick up the OBS stream. When I direct /dev/video0 to the pose estimation script (without OBS), then its light is off and it’s turned on as the script runs. I suspect that’s when the negotiation happens and somehow that doesn’t work with the OBS stream.
If you need any more info then please guide me.
Here is the OBS log:
17:17:19.596: Platform: Wayland
17:17:19.596: Physical Cores: 4, Logical Cores: 4
17:17:19.596: Physical Memory: 16218MB Total, 14339MB Free
17:17:19.596: Kernel Version: Linux 6.12.62+rpt-rpi-2712
17:17:19.596: Distribution: "Debian GNU/Linux" "13"
17:17:19.596: Desktop Environment: labwc:wlroots (rpd-labwc)
17:17:19.596: Session Type: wayland
17:17:19.600: Qt Version: 6.8.2 (runtime), 6.8.2 (compiled)
17:17:19.600: Portable mode: false
17:17:19.684: OBS 30.2.3.1-3 (linux)
17:17:19.684: ---------------------------------
17:17:19.684: ---------------------------------
17:17:19.684: audio settings reset:
17:17:19.684: samples per sec: 48000
17:17:19.684: speakers: 2
17:17:19.684: max buffering: 960 milliseconds
17:17:19.684: buffering type: dynamically increasing
17:17:19.686: ---------------------------------
17:17:19.686: Initializing OpenGL...
17:17:19.686: Using EGL/Wayland
17:17:19.765: Initialized EGL 1.5
17:17:19.786: Loading up OpenGL on adapter Broadcom V3D 7.1.10.2
17:17:19.786: glEnable failed, glGetError returned GL_INVALID_ENUM(0x500)
17:17:19.786: OpenGL loaded successfully, version 3.3 (Core Profile) Mesa 25.0.7-2+rpt3, shading language 3.30
17:17:19.828: ---------------------------------
17:17:19.829: video settings reset:
17:17:19.829: base resolution: 640x640
17:17:19.829: output resolution: 640x640
17:17:19.829: downscale filter: Bicubic
17:17:19.829: fps: 30/1
17:17:19.829: format: NV12
17:17:19.829: YUV mode: Rec. 709/Partial
17:17:19.829: NV12 texture support enabled
17:17:19.829: P010 texture support not available
17:17:19.830: Audio monitoring device:
17:17:19.830: name: Default
17:17:19.830: id: default
17:17:19.830: ---------------------------------
17:17:20.133: VAAPI: Failed to initialize display in vaapi_device_h264_supported
17:17:20.134: FFmpeg VAAPI H264 encoding not supported
17:17:20.134: VAAPI: Failed to initialize display in vaapi_device_av1_supported
17:17:20.134: FFmpeg VAAPI AV1 encoding not supported
17:17:20.134: VAAPI: Failed to initialize display in vaapi_device_hevc_supported
17:17:20.134: FFmpeg VAAPI HEVC encoding not supported
17:17:20.172: [obs-websocket] [obs_module_load] you can haz websockets (Version: 5.5.2 | RPC Version: 1)
17:17:20.172: [obs-websocket] [obs_module_load] Qt version (compile-time): 6.8.2 | Qt version (run-time): 6.8.2
17:17:20.172: [obs-websocket] [obs_module_load] Linked ASIO Version: 103002
17:17:20.180: [obs-websocket] [obs_module_load] Module loaded.
17:17:20.205: ---------------------------------
17:17:20.205: Loaded Modules:
17:17:20.205: text-freetype2.so
17:17:20.205: rtmp-services.so
17:17:20.205: obs-x264.so
17:17:20.205: obs-websocket.so
17:17:20.205: obs-transitions.so
17:17:20.205: obs-outputs.so
17:17:20.205: obs-filters.so
17:17:20.205: obs-ffmpeg.so
17:17:20.205: linux-v4l2.so
17:17:20.205: linux-pulseaudio.so
17:17:20.205: linux-capture.so
17:17:20.205: image-source.so
17:17:20.205: frontend-tools.so
17:17:20.205: ---------------------------------
17:17:20.205: ---------------------------------
17:17:20.205: Available Encoders:
17:17:20.205: Video Encoders:
17:17:20.205: - ffmpeg_svt_av1 (SVT-AV1)
17:17:20.205: - ffmpeg_aom_av1 (AOM AV1)
17:17:20.205: - obs_x264 (x264)
17:17:20.205: Audio Encoders:
17:17:20.205: - ffmpeg_aac (FFmpeg AAC)
17:17:20.205: - ffmpeg_opus (FFmpeg Opus)
17:17:20.205: - ffmpeg_pcm_s16le (FFmpeg PCM (16-bit))
17:17:20.205: - ffmpeg_pcm_s24le (FFmpeg PCM (24-bit))
17:17:20.205: - ffmpeg_pcm_f32le (FFmpeg PCM (32-bit float))
17:17:20.205: - ffmpeg_alac (FFmpeg ALAC (24-bit))
17:17:20.205: - ffmpeg_flac (FFmpeg FLAC (16-bit))
17:17:20.205: ==== Startup complete ===============================================
17:17:20.245: All scene data cleared
17:17:20.245: ------------------------------------------------
17:17:20.256: pulse-input: Server name: 'PulseAudio (on PipeWire 1.4.2) 15.0.0'
17:17:20.256: pulse-input: Audio format: float32le, 48000 Hz, 2 channels
17:17:20.256: pulse-input: Started recording from 'auto_null.monitor' (default)
17:17:20.257: [Loaded global audio device]: 'Desktop Audio'
17:17:20.257: pulse-input: Server name: 'PulseAudio (on PipeWire 1.4.2) 15.0.0'
17:17:20.258: pulse-input: Audio format: s16le, 32000 Hz, 2 channels
17:17:20.258: pulse-input: Started recording from 'alsa_input.usb-046d_Logitech_Webcam_C925e_8E8DF0BF-02.analog-stereo' (default)
17:17:20.258: [Loaded global audio device]: 'Mic/Aux'
17:17:20.259: v4l2-input: Start capture from /dev/v4l/by-id/usb-046d_Logitech_Webcam_C925e_8E8DF0BF-video-index0
17:17:20.375: v4l2-input: Input: 0
17:17:20.378: v4l2-input: Resolution: 640x480
17:17:20.378: v4l2-input: Pixelformat: YUYV
17:17:20.378: v4l2-input: Linesize: 1280 Bytes
17:17:20.378: v4l2-input: Framerate: 30.00 fps
17:17:20.379: v4l2-input: /dev/v4l/by-id/usb-046d_Logitech_Webcam_C925e_8E8DF0BF-video-index0: select timeout set to 166666 (5x frame periods)
17:17:20.379: v4l2-input: Start capture from /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0
17:17:20.490: v4l2-input: Input: 0
17:17:20.545: v4l2-input: Resolution: 640x480
17:17:20.545: v4l2-input: Pixelformat: YUYV
17:17:20.545: v4l2-input: Linesize: 1280 Bytes
17:17:20.545: v4l2-input: Framerate: 30.00 fps
17:17:20.545: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timeout set to 166666 (5x frame periods)
17:17:20.547: Switched to scene 'Scene'
17:17:20.547: ------------------------------------------------
17:17:20.547: Loaded scenes:
17:17:20.547: - scene 'Scene':
17:17:20.547: - source: 'Video Capture Device (V4L2)' (v4l2_input)
17:17:20.547: - source: 'Video Capture Device (V4L2) 2' (v4l2_input)
17:17:20.547: ------------------------------------------------
17:17:20.737: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:20.737: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:20.815: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: Desktop Audio)
17:17:20.815:
17:17:20.904: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:20.904: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.029: adding 21 milliseconds of audio buffering, total audio buffering is now 42 milliseconds (source: Mic/Aux)
17:17:21.029:
17:17:21.071: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.071: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.238: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.238: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.405: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.405: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.572: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.572: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.739: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.739: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:21.906: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:21.906: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:22.073: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:22.073: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:22.240: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: select timed out
17:17:22.240: v4l2-input: /dev/v4l/by-id/usb-046d_C505_HD_Webcam_4A7EE960-video-index0: failed to log status
17:17:32.497: Attempting to reset output capability of '/dev/video0'
17:17:32.497: Attempting to reset output capability of '/dev/video1'
17:17:32.497: Attempting to reset output capability of '/dev/video2'
17:17:32.497: Attempting to reset output capability of '/dev/video3'
17:17:32.498: Virtual camera started
17:17:32.500: ==== Virtual Camera Start ==========================================
17:17:32.501: Starting Virtual Camera output to Program
17:17:32.504: Failed to inhibit: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.Inhibit” on object at path /org/freedesktop/portal/desktop
By default OBS does not show the Virtual Camera button, so v4l2loopback needs to be installed with sudo apt install v4l2loopback-dkms. After rebooting the RPi, OBS shows the Virtual Camera button. (Source: OBS Studio Install Instructions at Install Instructions · obsproject/obs-studio Wiki · GitHub).
… the documentation of v4l2loopbackhere may help (also pasted below). I’m not confident with modprobe. Could someone help please?
Thanks,
Gabor
If you encounter problems detecting your device with Chrome/WebRTC you can try ‘exclusive_caps’ mode:
# modprobe v4l2loopback exclusive_caps=1
This will enable ‘exclusive_caps’ mode that only reports CAPTURE/OUTPUT capabilities exclusively. The newly created device will announce OUTPUT capabilities only (so ordinary webcam applications (including Chrome) won’t see it). As soon as you have attached a producer to the device, it will start announcing CAPTURE capabilities only (so applications that refuse to open devices that have other capabilities apart from capturing can open it too.)
CHANGING OPTIONS
Options that you provided when loading the module (e.g. via modprobe) cannot be easily changed on the fly. In order to change these options, you must first unload the module with rmmod (which will only work if no application is any longer accessing one of the loopback devices) and then load it again (with the new options).
I couldn’t resist it, so I tried sudo modprobe v4l2loopback exclusive_caps=1 but I get the same error message.
Now when I click Start Virtual Camera in OBS, I get a prompt for the password and this suggests that the exclusive_caps=1 parameter is set by OBS anyway.
It works! My hack in the code is a bit brute force, but it works.
I’m not sure where to set these parameters correctly, so I added no_webcam_compression = True just above if source_type == “usb” to force the branch that you’ve suggested.
Also, I had to set the OBS output to 640x480 to match the resolution in the source_element.
Now I have pose estimation on a composite video of two webcams in OBS. I’ll check fps, accuracy, etc. from home. The Raspberry Connect is great to access the Pi remotely, but a bit slow especially when there’s a lot of drawing on the screen.
Thanks @GaborLJMU glad to hear it works!
The way you implemented the brute force looks fine.
We will add a proper fix that will detect similar cases automatically to our next release.