Streaming Multiple USB Cameras at Once

EDIT: this comment applies to Companion 0. The new BlueOS uses a different camera manager, and supports multiple h264 camera streams without modification.


This took longer to get back to than I’d hoped, and you might already have a working solution for your use case, but in case it’s relevant I spent some time on it today, so now have an approach that makes it easy to add extra videos. The relevant code changes are here:

After that, adding extra video streams basically just requires creating the two extra parameter files for each one, and adding a line for it in .companion.rc. As an example, for a second BR camera the H264 access is likely at /dev/video3, and if we want we can stream it to port 5610 (the default stream goes to 5600), so to add that you’d make

vidformat-extra.param

1920
1080
30
/dev/video3

gstreamer-extra.param

! h264parse
! queue
! rtph264pay config-interval=10 pt=96
! udpsink host=192.168.2.1 port=5610

and change .companion.rc to have

	...
	sudo -H -u pi screen -dm -S video $COMPANION_DIR/tools/streamer.py vidformat.param gstreamer2.param
	sudo -H -u pi screen -dm -S video2 $COMPANION_DIR/tools/streamer.py vidformat-extra.param gstreamer-extra.param
	...

And then the receiving end can be handled as in the post I linked you to in my first comment. More streams can be added in the same way, making sure to select the correct device in the vidformat parameters and set a unique port in the gstreamer ones.


@UnderseaROV If you’re still working with this stuff, this approach might be worth considering :slight_smile:

4 Likes