RaspberryPi_WebRTC icon indicating copy to clipboard operation
RaspberryPi_WebRTC copied to clipboard

Support: USB Camera

Open rkenzhebekov opened this issue 1 year ago • 2 comments

Can I use other cameras connected via USB with Raspberry PI 4, or is the raspberry pi based CSI Camera Module required?

Thank you

rkenzhebekov avatar Sep 22 '24 18:09 rkenzhebekov

Yes, you can. My Pi 4B uses a USB camera. I suggest running v4l2-ctl -d /dev/video0 --list-formats in advance to confirm the supported formats of the USB camera. My USB camera only supports specific formats, and V4L2 can't read it if my settings don't match.

TzuHuanTai avatar Sep 22 '24 20:09 TzuHuanTai

Thank you!

rkenzhebekov avatar Sep 23 '24 05:09 rkenzhebekov

@TzuHuanTai I am getting this error, what can I do?

Use h264 format source in v4l2
[v4l2_utils] Error: fd(16) set fps(30): Inappropriate ioctl for device

boredom1234 avatar Oct 30 '24 11:10 boredom1234

Could you please check the support format of your webcam? And what is your full command and settings right now?

Here is the way I use webcam on pi, fyi

  1. Enable lagecy v4l2 driver, ref

  2. Check the support format of the webcam and run it.

pi@home-pi-5:~ $ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'MJPG' (Motion-JPEG, compressed)
                Size: Discrete 352x288
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.050s (20.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
...

pi@home-pi-5:~ $ ./pi_webrtc --device=/dev/video0 --v4l2_format=mjpeg --fps=30 --width=1920 --height=1080 --mqtt_host=xxxx --mqtt_port=8883 --mqtt_username=xxxx --mqtt_password=xxxx --uid=xxxx
Use mjpeg format source in v4l2
[v4l2_utils] Error: fd(26) set ctrl(9963810): Invalid argument
[v4l2_utils] Error: fd(26) set ext ctrl(10029519): Invalid argument

Sometime it might show some errors about v4l2 setting while running pi_webrtc. Because not every webcam supplier implement all v4l2 setting support, and pi_webrtc always try to set bitrate/roration to the camera initially, but it doesn't bother the streaming.

TzuHuanTai avatar Oct 30 '24 18:10 TzuHuanTai

It worked thanks

boredom1234 avatar Nov 02 '24 18:11 boredom1234

see #237

TzuHuanTai avatar Feb 26 '25 22:02 TzuHuanTai