Stream Raspberry Pi Camera to OBS over LAN

This article explains how to capture high-frame-rate (HFR) video from a Raspberry Pi camera module and stream it directly into OBS Studio over a local area network (LAN). By utilizing the native libcamera tools on Raspberry Pi OS and the Secure Reliable Transport (SRT) protocol, you can achieve a low-latency, high-performance video feed suitable for live streaming, recording, or monitoring.

Step 1: Prepare the Hardware and Network

To achieve high frame rates (such as 60 FPS or higher) with minimal latency, ensure your hardware and network meet the following requirements: * Raspberry Pi: A Raspberry Pi 4 or Raspberry Pi 5 is recommended for hardware-accelerated encoding. * Camera Module: Raspberry Pi Camera Module V2 (supports up to 720p at 60 FPS) or Camera Module 3 / HQ Camera. * Network: Connect both the Raspberry Pi and the OBS computer to the same router via wired Ethernet cables. If Wi-Fi must be used, ensure both devices are on a stable 5 GHz band.

Step 2: Configure the Raspberry Pi Stream

Modern Raspberry Pi OS releases use the libcamera framework. We will use libcamera-vid to capture the video and stream it using the SRT protocol in listener mode. This allows OBS to initiate the connection.

  1. Open a terminal on your Raspberry Pi.
  2. Run the following command to start a 1280x720 stream at 60 frames per second:
libcamera-vid -t 0 --inline --width 1280 --height 720 --framerate 60 --codec h264 -o srt://0.0.0.0:1234?mode=listener

Note the IP address of your Raspberry Pi by running hostname -I in the terminal.

Step 3: Set Up OBS Studio to Receive the Stream

Now configure OBS Studio on your main computer to capture the incoming SRT feed.

  1. Open OBS Studio.
  2. In the Sources dock, click the + icon and select Media Source.
  3. Name the source (e.g., “Pi Camera”) and click OK.
  4. In the properties window, uncheck the box labeled Local File.
  5. In the Input field, enter the SRT address of your Raspberry Pi: srt://<RASPBERRY_PI_IP>:1234?mode=caller (Replace <RASPBERRY_PI_IP> with the actual IP address of your Raspberry Pi).
  6. In the Input Format field, type: mpegts
  7. Set the Network Buffering option to 1 MB (or lower) to minimize latency.
  8. Click OK. The high-frame-rate video feed from your Raspberry Pi will appear in the OBS viewport.

Step 4: Fine-Tuning for Ultra-Low Latency

If you experience stuttering or lag, apply these optimizations: * Reduce OBS Buffering: Re-open the Media Source properties in OBS and set the “Network Buffering” to the minimum allowed or use the “Speed” preset. * Adjust Bitrate on the Pi: You can limit the bandwidth usage of the stream by adding the --bitrate flag to your Raspberry Pi command. For example, adding --bitrate 5000000 limits the stream to 5 Mbps, which is ideal for a stable 720p60 stream.