Using OBS to capture multiple USB camera streams connected to raspberry Pi 4.

islam2222

New Member
Hi
I was wondering what is the correct way to capture multiple USB cameras streams connected to a Raspberry Pi and the raspberry is connected to the laptop using an ethernet cable. I want to stream the output of the cameras in an OBS scene.
 

yellowsheep

New Member
Hi, actually i'm making tha same thing. using ffmpeg and v4l2loopback, and finally OBS. the solution I adopt is:
first step, raspberry: capture cam (dev/video0) in mjpeg format and trasmit to raspberry own IP, via TCP connection:

ffmpeg -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 25 -i /dev/video0 -c:v copy -f mjpeg tcp://192.168.2.109:8080?listen

second step, PC, laptop: receive TCP flow, from raspberry IP, decode mjpeg to rawvideo and put the video in a v4l2loopback virtual device (dev/video0):

ffmpeg -f mjpeg -c:v mjpeg_cuvid -r 25 -i tcp://192.168.2.109:8080 -f v4l2 -pix_fmt yuv420p /dev/video0

third step: open OBS anc add a v4l2 device, select /dev/video0 (or whatever is your video loopback), you'll find your streamed video.
after a lot of research and experiments I find is best to manage the streaming part outside OBS, and leave OBS to only capture a video device.
note that from capturing USB to OBS signal is never converted, and quality is at its best. you have only to decode mjpeg to raw before sending to video loopback device. this is esaly done with mjpeg decoder in ffmpeg which can be software (mjpeg) or hardware accelerated (mjpeg_cuvid for Nvidia or mjpeg_qsv for Intel).
hope it helps. if you have others ideas, please let me know.
Bye!!
 

TonyKSussex

New Member
This is partly what I need to do, but I need also to transmit control codes to the remote camera via the virtual USB link. Has anyone done this? Another minor problem is powering the Raspberry Pi from a battery at the camera location. The camera wants 12v, the Pi 5v.
 
Top