• This repository has been archived on 05/Apr/2024
  • Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Network Camera with Raspberry Pi and WebRTC. Tutorial:

Live stream your balena device's camera feed.

Getting started

Running this project is as simple as deploying it to a fleet.

One-click deploy to balenaCloud:

or

  • Sign up on balena.io and follow our Getting Started Guide.

  • Clone this repository to your local workspace.

  • Unset (delete) the environment variable BALENA_HOST_CONFIG_gpu_mem or RESIN_HOST_CONFIG_gpu_mem if exists, from the Configuration side tab under "fleets".

  • Set these variables in the Configuration side tab under "fleets".

    • BALENA_HOST_CONFIG_start_x = 1

    • Set all the following gpu_mem variables so your Pi can autoselect how much memory to allocate for hardware accelerated graphics, based on how much RAM it has available

      Key Value
      BALENA_HOST_CONFIG_gpu_mem_256 192
      BALENA_HOST_CONFIG_gpu_mem_512 256
      BALENA_HOST_CONFIG_gpu_mem_1024 448
  • Using Balena CLI, push the code with balena push <fleet-name>.

  • See the magic happening, your device is getting updated 🌟Over-The-Air🌟!

  • In order for your device to be accessible over the internet, toggle the switch called PUBLIC DEVICE URL.

  • Once your device finishes updating, you can watch the live feed by visiting your device's public URL.

Password Protect your balenaCam device

To protect your balenaCam devices using a username and a password set the following environment variables.

Key Value
username yourUserNameGoesHere
password yourPasswordGoesHere

💡 Tips: 💡

Optional Settings

  • To rotate the camera feed by 180 degrees, add a device variable: rotation = 1 (More information about this on the docs).
  • To suppress any warnings, add a device variable: PYTHONWARNINGS = ignore

TURN server configuration

If you have access to a TURN server and you want your balenaCam devices to use it. You can easily configure it using the following environment variables. When you set them all the app will use that TURN server as a fallback mechanism when a direct WebRTC connection is not possible.

Key Value
STUN_SERVER stun:stun.l.google.com:19302
TURN_SERVER turn:<yourTURNserverIP>:<yourTURNserverPORT>
TURN_USERNAME <yourTURNserverUsername>
TURN_PASSWORD yourTURNserverPassword

Additional Information

  • This project uses WebRTC (a Real-Time Communication protocol).
  • A direct WebRTC connection fails in some cases.
  • This current version uses mjpeg streaming when the webRTC connection fails.
  • Chrome browsers will hide the local IP address from WebRTC, making the page appear but no camera view. To resolve this try the following
    • Navigate to chrome://flags/#enable-webrtc-hide-local-ips-with-mdns and set it to Disabled
    • You will need to relaunch Chrome after altering the setting
  • Firefox may also hide local IP address from WebRTC, confirm following in 'config:about'
    • media.peerconnection.enabled: true
    • media.peerconnection.ice.obfuscate_host_addresses: false

Supported Browsers

  • Chrome (but see note above)
  • Firefox (but see note above)
  • Safari
  • Edge (only mjpeg stream)

Become a balena poweruser

Want to learn more about what makes balena work? Try one of our masterclasses. Each lesson is a self-contained, deeply detailed walkthrough on core skills to be successful with your next edge project.

Check them out at our docs. Also, reach out to us on the Forums if you need help.

More Repositories

1

balena-dash

Build a Raspberry Pi based desktop dashboard for stats, photos, videos and more!
Shell
431
star
2

balena-sense

Take readings from a BME680 or similar sensor on a Raspberry Pi, store with InfluxDB and view with Grafana
Shell
284
star
3

wifi-repeater

Easily create a WiFi Access Point or WiFi repeater with balenaOS
TypeScript
189
star
4

inkyshot

Get a daily random inspirational quote delivered direct to your desk with Inkyshot. Build multiple Inkyshots and share the inspiration with your friends, family and loved ones ❤️
Python
115
star
5

rosetta-at-home

EJS
80
star
6

balena-node-red

a node-red application with balena-supervisor support, can be managed remotely via balena publicURL
JavaScript
60
star
7

audio

Audio building block for balenaOS, based on pulseaudio.
Shell
31
star
8

bluetooth

Optimized bluetooth agent for balenaOS. Based on BlueZ 5.0.
Python
23
star
9

dashboard

Grafana dashboard block with auto-visualization of InfluxDB databases to get your data visualized instantly!
Python
23
star
10

connector

Auto-configured data connector block based on Telegraf
Python
15
star
11

xserver

A simple X11 server block
Shell
15
star
12

sensor

Auto-detects connected i2c sensors and published data on HTTP or MQTT.
Python
14
star
13

fbcp

fbcp driver for SPI based displays for Raspberry Pis via fbcp-ili9341
Dockerfile
14
star
14

multiroom

Set up multiroom audio for your fleet of devices. Uses the Snapcast audio player.
Shell
9
star
15

autohupr

Automatically keep your balenaOS host release up-to-date with this block!
TypeScript
8
star
16

plate-recognizer

Using balena to easily deploy Plate Recognizer to one or more Raspberry Pi 4 devices.
Shell
7
star
17

log2screen

Shell
7
star
18

project-template

Project template for new Balena projects
Dockerfile
7
star
19

dbus

Shell
6
star
20

pulse

A block for counting pulses on a Raspberry Pi GPIO pin.
Python
4
star
21

video-capture

Provide an RTSP stream for a connected video source.
C
3
star
22

browsercontrol

HTML
3
star
23

logwatcher

TypeScript
3
star
24

balena-openvino

experiments aimed at creating an openvino balena block
C
1
star
25

lockr-block

Create or remove application update locks with the return code of any command.
TypeScript
1
star