TzuHuanTai / Pi-Camera

Transform your Raspberry Pi into a powerful home security camera with the Pi Camera app.
26 stars 3 forks source link

Pi 4b latency demo

Pi Camera

Transform your Raspberry Pi into a powerful home security camera with the Pi Camera app. Using peer-to-peer (P2P) communication over WebRTC to make a decentralized monitor system, this app connects directly to your Raspberry Pi, allowing you to monitor live video with minimal delay and access historical footage. [demo video]

Key Features

πŸ‘‰ Low-Latency Live Monitoring: Achieve extremely low-latency video streaming through WebRTC technology, ensuring you don’t miss any important moments.

πŸ‘‰ Playback of Historical Footage: Easily view and manage recorded videos to meet your security needs.

πŸ‘‰ Simple Setup: Quickly configure your Raspberry Pi camera through a user-friendly interface.

πŸ‘‰ Privacy Protection: Direct P2P connection without relying on third-party servers ensures that your data is fully under your control.

πŸ‘‰ Open-Source Support: The camera source code is fully open-source, allowing you to customize and extend it as needed.

Setting Up a New Raspberry Pi

Step 0: Prerequisites

  1. A Raspberry Pi with a camera module attached.
  2. A MQTT server. (STUN and TURN servers are optional).


Important Notice

Step 1: Set Configurations on the App

  1. Go to Setting Page.
  2. Click 🌐 icon and paste your servers setting. Here is an example mqtt setting shown on HiveMQ.

    • Notice! Please use WebSocket Port here!


Step 2: Add a New Device in the Setting Page

  1. Click βž• icon
  2. The app will generate a UUID, which will be used on your Raspberry Pi later.
    If you'd like to assign a specific ID to the device, you can edit the UUID at the beginning. Once confirmed, the UUID cannot be edited; you will need to delete the device and add a new one if changes are needed.
  3. Enter a name in the "Alias", which can be edited at any time in the future.
  4. The new device will appear on the list after clicking the confirm button. You can change the order of devices on the selectors and home page by dragging the ☰ icon.

Step 3: Run Camera Software on Raspberry Pi

  1. Download the pi_webrtc software from the release page.

  2. Run the pi_webrtc on your Raspberry Pi. Here’s an example where the device uid is set to abcdefg-123-1qaz2wsx in the app.

    Important: The MQTT port specified in the command is NOT the WebSocket port (8884), but the standard MQTT protocol port (8883).

    /path/to/pi_webrtc --device=/dev/video0 --fps=30 --width=1280 --height=960 --v4l2_format=h264 --hw_accel --mqtt_host=example.s1.eu.hivemq.cloud --mqtt_port=8883 --mqtt_username=hakunamatata --mqtt_password=WonderfulPhrase --uid=abcdefg-123-1qaz2wsx --record_path=/mnt/ext_disk/video/

For detailed setup instructions, please refer to the guide on the RaspberryPi_WebRTC page.

Step 4: Verify the Connection

Step 5: Share to Other Phones

  1. Click the share button on the phone that can connect to Raspberry Pi already. It'll show the QR code.
  2. Pick up the second phone click the QR code button in the add device section, and scan the QR code will copy the device, including the network setting, to the second phone. Notice! The network setting will be replaced in the second phone if set before.

Contact & Support

If you have any questions, need support, or just want to provide feedback, you can reach out via

  1. Google Group

  2. GitHub Issues

Thank you for using Pi Camera!