IC1

My Blog

Test

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea…

Read more →

Home Assistant on a Pi5

1. Install Home Assistant OS Follow: https://www.home-assistant.io/installation/raspberrypi Download and install HAOS through Raspberry Pi Imager Plug in to Pi and connect network cable Connect to…

Read more →

Pi5 Birdbox Webcam Setup (Motion & Icecast)

 Installing a H264 webcam on a Raspberry Pi. The following can be completed in 15-30 minutes... Ingredients Memory Card for the Pi (e.g. 16Gb) Raspberry Pi 5 USB Webcam Setting up the Basics Installing The…

Read more →

Re-connecting Home Assistant to Google Home

 These steps assume that the Google Home has been previously paired with Home Assistant, and the settings in the Google Cloud API pages are correct; the Home Assistant has been installed and is accessible to…

Read more →

VOIP PABX on A Raspberry Pi 5

Install PiOs Lite 64 Bit Select your Pi And PiOS 64-bit Lite And your memory card Ensure that you set the hostname, enable ssh and set the username to something obscure Select 'Write' and wait .... Once installed, boot…

Read more →

Pi5 Birdbox Webcam Setup (Motion & Icecast)

 Installing a H264 webcam on a Raspberry Pi.

The following can be completed in 15-30 minutes...

Ingredients

  • Memory Card for the Pi (e.g. 16Gb)
  • Raspberry Pi 5
  • USB Webcam

Setting up the Basics

Installing The Operating System

On a Windows or Linux PC, Run the Raspberry Pi Imager, and Select:

  • Raspberry Pi 5
  • Select Rasberry Pi OS (64-bit)
  • Your memory card (e.g. 16Gb)

Edit Settings, and:

  • Set the device name, e.g. 'camserver'
  • Fill in your Username and Password (for this example, we assume the username is 'user')
  • Fill in the WiFi SSID and Password
  • Under 'Services', ensure that SSH is enabled, and select 'Use password authentication'

Then select Install, and wait.

Booting the Pi

Connect a webcam (preferably one supporting H.264)
Insert the memory card into the Pi, and power up
The LED will flash Red, then Green, and after that will blink green every time the memory card is accessed.
If the LED remains Red, this indicates that your power supply cannot provide sufficient current.

Logging In
ssh -l user camserver.local

Disabling USB Auto Suspend and Swapping to Memory Card


Modify the cmdline.txt to add an additional switch to the end, use systemctl to disable the swapfile and then reboot the device:

$ sudo vi /boot/firmware/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=ef0fb16a-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=GB usbcore.autosuspend=-1
$ sudo systemctl disable dphys-swapfile.service
$ sync; sudo reboot

Setting up the Audio

Finding the Webcam Audio Stream


$ ssh -l user camserver.local

 Run the lsusb command to identify the webcam.  If it is not obvious which of the devices _is_ the webcam, unplug it and run lsusb again to see what is missing. 

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 05a3:9331 ARC International Camera
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Now run the alsactl info command, and look for the device (which will have a matching ID - in this case, 05A3:9331).  Note the card and device number.

 $ alsactl info | more

...
#
# Sound card
#
- card: 2
 id: Camera
 name: HD Web Camera
 longname: HD Web Camera HD Web Camera at usb-xhci-hcd.1-1, high speed
 driver_name: USB-Audio
 mixer_name: USB Mixer
 components: USB 05a3:9331
 controls_count: 3
 pcm:
   - stream: CAPTURE
     devices:
       - device: 0
         id: USB Audio
         name: USB Audio
         subdevices:
           - subdevice: 0
             name: subdevice #0
...

The card and device number form the hardware ID, which is used in ffmpeg in later sections.  In this example, the hardware ID is hw:2,0

Install  Icecast2
Install icecast 2 
$ sudo apt-get icecast2 
Add an Audio Streaming Service

Edit / create an alsa2icecast service, making sure that you set the correct address for the the device (in this case: hw:2,0).
$ sudo vi /etc/systemd/system/alsa2icecast.service
[Unit]
Description=Alsa to Icecast2 Streamer
After=network.target

[Service]
ExecStart=/bin/bash -c '\
ffmpeg -v fatal \
 -nostdin \
 -f alsa \
 -thread_queue_size 512 \
 -channels 1 \
 -sample_rate 44100 \
 -i hw:2,0 \
 -filter:a "volume=18dB" \
 -err_detect compliant \
 -codec:a libmp3lame \
 -b:a 256k \
 -f mp3 \
 icecast://source:source@127.0.0.1:8000/birdbox.mp3'

Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target
Once created, start and enable the service.

$ sudo systemctl start alsa2icecast
$ sudo systemctl enable alsa2icecast

Configure Icecast2


Setting up the Video

Installing Motion

...