Some Notes on Upgrading WSL Debian to Trixie

This is how I upgraded my elderly WSL Debian install from Buster (version 10) to Trixie (version 13). This may only apply to Windows Subsystem for Linux (WSL) running Debian, although it may help with others like Ubuntu. For a smoother upgrade I worked through the versions: Bullseye > Bookworm > Trixie as Debian is really only happy updating one version at a time.

Upgrading from Buster to Bullseye:

As Buster is now out of support, no updates are available.

Going through each command, this changes the version in the sources.list file and after you update apt the database, we perform a full upgrade and then clean the old data. We then check the version with cat /etc/os-release.

Installing usrmerge resolves this error which can appear later:

Upgrading from Bullseye to Bookworm:

The intermediate step, if you are already at Bullseye then:

before embarking on the version upgrade.

Upgrading from Bookworm to Trixie:

And finally to Trixie using the same method as before, but with an update to how the sources are set out.

on one of my computers, the Nvidia drivers prevented the kernel upgrade:

to fix this I removed the Nvidia driver for reinstallation later:

The final installed version:

and the installed kernel:

Links and Sources

SSH Login into Squeezebox Radio

After around eleven years almost continual use my old Logitech Squeezebox Radio (now discontinued) started crashing and restarting on a regular basis, like every twenty minutes. In an attempt to tell if this is a software or hardware fail I started searching the internets and found that you can SSH into these over the network, but as OpenSSH updated and changed the security requirements the information given was out of date.

Squeezebox Radio
Squeezebox Radio

Some knowledge of SSH and the CLI Terminal is assumed (Bash, Zsh, etc), I am using a Raspberry Pi running Debian GNU/Linux 12 (bookworm) to SSH into the Radio.

Enable SSH on the Squeezebox Radio

The Option can be found in the menus:

  • Settings
    • Advanced
      • Remote Login
        • Enable SSH

Enable SSH on the Squeezebox Radio
Enable SSH on the Squeezebox Radio

The default settings are:

  • Username: root
  • Password: 1234
  • IP Address: <shown on your Remote Login screen>

Settings for SSH on your Computer

In my case the Radios IP address is 192.168.1.103, yours will be different. It will have shown you your address when you enabled SSH on the Radio.

The original instructions I found have become a little out of date and OpenSSH no longer directly supports some of the older ciphers and host-keys. One cannot simply SSH login to the Radio without some faffing about, for example using the settings from the original article:

To force the old protocols, the KexAlgorithms and Ciphers can be used, for this I added to my ~/.ssh/config file.

with this entry:

Don’t forget to change my IP address to yours, save the file and then attempt to connect with:

It should now ask you for a password, the default is the totally secure: 1234
Congratulations, your Squeezebox Radio is now open.

Successful login into Squeezebox Radio
Successful login into Squeezebox Radio

Alternativley, in the terminal you can set the options and connect with:

But for me an entry in ~/.ssh/config saves having to remember all of that.

In the end, a factory reset (in the menu settings) appears to have fixed the problem.

Copying Files

I found that using scp to copy a file to a remote computer while logged into the Radio didn’t work. Giving an assortment of errors, for example:

The fix for this is to copy the file using the computer you are connecting to the Radio with:

This makes use of the ~/.ssh/config file. The -O option forces use of the legacy SCP protocol for file transfers instead of SFTP as this is not implemented on the Radio.

Troubleshooting

I would hope the above saves you a couple of hours trying things from the internet, not everything is needed in that config file but as its working I stopped.

The version of Linux on this Squeezebox Radio dates from February 2014:

I have read there are newer versions of the firmware and a community version, but not felt the need to update.

Here is the main problem I found while working on this setup, I kept getting this unable to negotiate error:

This was caused by some of the Ciphers being included in my ~/.ssh/config not being in my OpenSSH install, probably because they are insecure. Changing the Ciphers line from:

to this:

fixed that problem. You can find the Ciphers installed in OpenSSH on your computer with % ssh -Q ciphers, the Squeezebox uses a very old version of Dropbear SSH.

Debian Trixie – Old Cyphers Not Welcome [Old Firmware]

Update: Following the February 2026 firmware update on the radio to 9.0.1-r17084 the SSH service got updated to dropbear_2025.88 and the following is no longer needed for access.

I updated my Raspberry Pi 5 to Debian Trixie and in OpenSSH v10 the elderly diffie-hellman-group1-sha1 is no longer included, resulting in an Unable to negotiate error. A work around for this is to use debootstrap to install a Debian base system in a subdirectory of another already installed system, chroot for changing the apparent root directory for the current running process and its children, and schroot which lets users run commands or interactive shells in different chroots. Install with:

This creates a Debian Buster environment in /oldssh. On an intel x64 computer leave out the –arch=arm64. Now we need to access the Buster environment and get things setup:

you should now be able to login to the Squeezebox:

And because life is too short to remember all that, create a nano /root/.ssh/config file with the following:

This is slightly different from that used before, with the use of PubkeyAcceptedKeyTypes instead of PubkeyAcceptedAlgorithms this is because of a change in Version 7 we are using in the chroot and the Version 9 before the update to Trixie. With this we can now login to the Squeezebox with a mildly clunky workflow of:

Using schroot and a small shell script can make things easier, add the following to the end of /etc/schroot/schroot.conf and set your username:

and in your home directory add the file squeezessh.sh with the following:

now set it to executable chmod +x squeezessh.sh and run it ./squeezessh.sh

Links and Sources

UTC Time Confusion with PHP

With the coming of spring and just like the Daffodils erupting from the soil, a whole new selection of bugs appear in your code due to the clocks going forward one hour.

My matrix display project needs to refresh from the dataset once in a while and yesterday with the clocks going forward from GMT to BST a bug caused the refresh time to be set behind or at the same time as the current time in UTC resulting in the matrix display continually sending update requests to the server. As you are probably aware, GMT and UTC are the same time, while BST is one hour ahead.

The Problem

Skip to the end for the fix if you are impatient.

With the failure as described above, I quickly found the problem in my PHP code, the DateTime class automatically sets the timezone region to that used in the application, in my case Europe/London, any conversions made are set relative to that timezone. The matrix display uses a Unix Timestamp for all time calculations, I could have written the code on the server side to use Unix Timestamps, but it turns out that I didn’t and now I need to convert between date strings, date objects and timestamp integers.

In the MySQL database I store the date as a DATETIME but with no timezone information, like so:

I then go to retrieve this date from the database, and convert it back to a PHP datetime object, and in this case display it:

And the output for this would be:

What you can see here is that while the datetime object is correct the timezone is set to Europe/London so when this is converted to a unix timestamp with $nextUpdate->getTimestamp(); an hour is deducted to convert it to UTC.

My first attempt at fixing this (now omitting the database query for clarity):

made things worse:

While the timezone is now correct the datetime object has also lost an hour.

The Fix

Turns out all that is needed is to set the timezone when the datetime object is created:

to give this resulting output:

So setting the timezone after creating the datetime object modifies the time, giving the setTimeZone() function a bit of a misleading name.

Links and Sources

Setup a Challenger 2040 LoRa in VS Code

I have recently been wanting to play with LoRa radios because reasons. This gives me a way of sending short messages between devices using a lightweight protocol with a range of a couple of kilometres on a bad day. I ended up picking up a Challenger 2040 LoRa manufactured by iLabs from The PiHut, mostly because all the others were out of stock. I then spent three days just getting the radio to initialize in my code.

Challenger RP2040 LoRa

As the Challenger 2040 LoRa has a lot of unhelpful documentation, this is a practical getting started guide using Platform IO, an alternative to the Arduino IDE, in Visual Studio Code on Windows for this board. Some familiarity with VS Code and Platform IO is assumed.

Installing RP2040 Support for Platform IO

If you have used the Pico 2040 before then you have probably done this already, but if not here is a summary for Windows users – this is for a new installation. The full instructions are on readthedocs.io, if you have it installed already and see the depreciation warning, check the full instructions:

Prerequisites:

  • Exit from VS Code
  • Enable long path support:
    1. Windows 10/11 Home users may need to activate gpedit, see this Major Geeks how-to
    2. Click Window key and type gpedit.msc, then press the Enter key. This launches the Local Group Policy Editor.
    3. Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
    4. Double click Enable NTFS/Win32 long paths and close the dialog.
  • Install git from: https://git-scm.com/download/win using the defaults.
  • Restart the computer – this adds git to the path.
  • Open an Administrator Console/Terminal (Terminal > Right Mouse Click and choose Run As Administrator), then:
  • Enable long paths in git: git config ——system core.longpaths true

Adding to Platform IO
Now load up VS Code, and in Platform IO create new project, Give it a name (rp2040test) and select Raspberry Pi Pico as the board and Arduino as the framework.

Pi Pico - Platform IO Selection
Pi Pico – Platform IO Selection

Click Finish and let it do its thing. This will give us a platformio.ini file to edit.

Update this file to be like:

When you save the file it takes a few minutes to automatically add the RP2040 SDK and long list of development boards including the Challenger 2040 LoRa to those available in Platform IO. You can now create a new project and choose the Challenger 2040 LoRa from the list of boards, which will give you this default platformio.ini:

but I prefer to use the one below.

Initializing the LoRa Radio

This is the part that took me the most time to get working, here is the cheat-sheet. Set platformio.ini as:

this also includes the LoRa library.

This is a modified version of the LoRaDumpRegisters.ino example just to show it working. The changes are to have it selecting SPI1 and setting the correct pins for the radio. Remember to set the correct frequency for your region:

The expected output on the serial port is a list of numbers in hexadecimal format ending with “LoRa init succeeded.”

I hope this is useful and saves much faffing about.

Converting a UTC date time to local in PHP

Here is a thing that took me longer to work out than it should have. I am storing some dates in a MySql database in the UTC timezone, but on my webpage I want to have them show as the local time. The problem I found is that PHP assumed that the date from the database was already in the local time (BST) and so did not adjust the hour on the datetime object when the timezone was applied.

This is fixed by setting the timezone when creating the datetime object from the string:

Also here it is again, but with a Unix Timestamp:

I hope this saves someone half a day. Although it occurs to me that I should really have the PHP output the date as the UTC and then have the javascript deal with it. Then the date would be displayed as how the users timezone is set rather than the servers.

So, in our PHP code, we setup a suitable output:

and in your javascript file, after you have picked up the data with your ajax call, or whatever, I have two functions, one to convert the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ) UTC date time to local and another to make for a nicely formatted output:

I’ve created the separate function for the date formatting as this has more flexibility.

Links and Sources

Fancy Blink for Arduino

This little blink program for the Arduino blinks an LED to give two short flashes and then a longer pause. The milliseconds are kept in an array ledDelays. It iterates through the array, setting the class=’bash’>interval according where the delayCount pointer is set. The LED state is toggled when the interval is complete.

The char pout[50] is used as a tidy way of outputting to the serial port as some older Arduino board don’t support Serial.printf.

Setting up SSH in VS Code to connect to a Raspberry Pi

There have been a lot of posts written about how to connect from Visual Studio Code (VS Code) on a Windows PC to a Raspberry PI over SSH using public/private keys avoiding the need to use a password. This is another one, and I aim to be fairly terse.

The PC is running Windows 11, the Raspberry Pi is running the latest version of Raspberry Pi OS – Debian Bullseye. Note that <username> is a placeholder for your own username, the greater than symbol: > represents a Windows PowerShell prompt and the dollar sign: $ is a Linux Bash prompt.

Setup The PI

SSH needs enabling on the PI and an ~/.ssh directory needs creating in your users home directory.

On the Pi, in the terminal enable SSH with: sudo raspi-config then select 3 Interface Options > I2 SSH and choose Yes – Enable. Now create the directory where your keys will be kept: mkdir ~/.ssh

It is also useful to find the IP address of your PI with: hostname -I Mine is 192.168.2.45 and I shall being using this in the examples.

You should now be able to login to the Pi from the Windows PC, open Windows Terminal or PowerShell and use ssh <username>@192.168.2.45 answer yes to add it to the known hosts file and it will ask for your PI’s password. If your Windows username is the same as that on the PI you can login with ssh 192.168.2.45.

Setup Windows for SSH

This stage installs the SSH client on the PC, creates a keypair and copied the public key to the PI.

The OpenSSH client can be installed using Windows Settings on Windows Server 2019 and Windows 10 and above devices.

  • Open Settings, select Apps > Apps & Features, then select Optional Features.
  • Scan the list to see if the OpenSSH is already installed. If not, at the top of the page, select Add a feature, then:
  • Find OpenSSH Client, then click Install

A full description is given on Microsofts Get started with OpenSSH page.

On the Windows PC, in your PowerShell create the directory for your keys if it doesn’t exist already mkdir ~/.ssh and then change into it cd ~/.ssh generate a keypair and add it to the ssh-agent:

We now need to copy the public key to the PI:

And on the PI we need to add that public key to the authorized keys, connect into the PI ssh <username>@192.168.2.45 and:

the commands, touch creates a blank file if it doesn’t exist, cat appends the pub file to authorized_keys, making sure that any existing keys are preserved permissions are set with chmod and finally the pub file is deleted.

Setup VS Code

Load up VS Code and add the Remote – SSH and Remote SSH: Editing Configuration Files extensions, once restarted you will see a >< icon in the bottom left-hand corner with a green background, click that and select Edit SSH Configuration file…, choose the one in your home directory C:\Users\<username>\.ssh\config and add the following:

The Host “piComputer_192.168.2.45” is the friendly name displayed within VS Code for when you are choosing it from lists, the User id your user on the PI. Save the config file when complete.

You should now be able to connect to the PI. Click the >< icon in the bottom left-hand corner, and choose Connect To Host… A popup saying Setting Up… should appear, it may ask if the host is Linux or Windows, choose Linux, and within a few seconds it’ll be connected and ready. From within VS Code you can open a Bash Terminal – Ctrl+Shift+’

If it asks for a password, you may have missed a stage, or copied the private key to the PI instead of the public one.

Links and Sources

Debian Linux Post Install Notes

I have just installed a new Debian Linux server, this will be running mainly as a web server without a GUI and console access will be via an SSH login, some knowledge of using Linux is assumed as these notes are intended as a prompt or overview of things to do to as part of a Linux server installation.

I am using Debian version 11.2 – Bullseye, the current version at time of writing, but these notes should work with any distribution that uses the apt package manager like Ubuntu. The ISO image used for installation came from https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/ and I have used the Xfce install: debian-live-11.2.0-amd64-xfce.iso (2.4G download). A guide for installing the Debian image can be found on this TecAdmin page.

At the Console

Your computer is now inviting you to login, do so with your local user and once the default desktop has been created open a terminal window to complete the following; switch to the root user and add your local user to the sudoers group:

Now logout and back in, this updates your user account settings, and go back to the terminal to update the system, install ssh access and a couple of useful tools, and finally set the computer to boot to console rather than the GUI:

If you have installed into a virtual machine now is a good time to install the guest client, links to popular VM’s:

Finding your IP address is useful:

In this instance it is 192.168.1.20. For a server I would normally fix the IP address in my router as a Reserved Address using the MAC (in this case: 02:11:32:23:83:6c).

Removing libreoffice clears a useful amount of diskspace:

Restart with $ sudo reboot You can now login via SSH from your other computer or continue at the console.

Installing the LAMP service – MySql, Apache and PHP

Start with MySql (MariaDB being the open source version), installing, configuring and starting:

For the secure installation, use the defaults and set the password when prompted. Next is Apache and PHP:

Point your web browser to the server address, in my case: http://192.168.1.20, and you should see the default Apache page. The web pages are in /var/www I normally add a symbolic link and change permissions on the html directory so I can add files easily:

Accessing a Network Drive

I want to be able to access some network drives from this server, these are setup as Windows (SMB) file shares.

create a file with your file share username and password, this should go into /etc, I normally call the file the name of the server I want to connect to, and set permissions so it is only readable by root:

And add the connection to the end of your /etc/fstab file, and mount the drives:

Check that it mounted with $ df -h. The file share will also automatically mount at boot.

Other Useful Things

Installing a downloaded .deb file with dependencies, in this case for the no longer manufactured Logitech Media Server:

Links and Sources

Setting up a Cisco SPA122 for use with UK Telephones

This is more of a nostalgia trip / messing about thing rather than a serious use of Voice over IP (VoIP). The Cisco SPA122 ATA with Router (Analog Telephone Adapter) is a small box that allows old analog phones to be connected to a VoIP network. At the time of writing Cisco no longer manufactures these and they are currently in an end of life plan.

Cisco SPA122 ATA
Cisco SPA122 ATA with Router

I am setting this up to use two handsets that can be used to call each other through the SPA122. I don’t have a VoIP service here and don’t have need for one. Later, I will be setting up a couple of modems and using them for a dialup connection, in this part I will be going through the setup and configuration of the SPA122.
SPA122 And Two Telephones

You will need:

  • An SPA122 – I got mine from eBay, check that you are purchasing a vanilla model, rather than one that has been configured by a carrier, be wary if it has any other logos printed on it as it may be locked to that carrier.
  • A 5V power supply, this must be capable of providing at least 2A.
  • Two telephones – I got these from the Charity Shop, get ones with tone dialing (DTMF), pulse dialing will not work – I’ve also found using better quality phones made in the early 2000’s work better than cheap new ones, I ended up with BT Decor 1100 and BT Decor 1200 phones.
  • Two adapters to convert the UK phone plug to RJ11 sockets on the SPA122. Search for “RJ11 to BT Socket” on eBay or Amazon, these are cheap.
  • A wired LAN connection to your network.
  • A computer, preferably with WiFi as well as a Wired Connection, I used a Raspberry Pi 4.
RJ11 to BT Socket Connector

Default Settings

  • IP Address: 192.168.15.1 – with a computer plugged into the yellow ethernet port
  • Username: admin
  • Password: admin

Resetting the SPA122 and Gaining Access

With a network lead from your computer to the yellow ethernet port on the SPA122 open your web browser and try the address 192.168.1.15. You should now see the login screen, try the login details above.

That probably didn’t work. To reset to factory default settings use a paperclip on the rear panel reset button. With the unit powered on, use the end of a paperclip to press into the red hole marked RESET located on the bottom-left side of the back panel of the SPA122. Press and hold for at least a full 20 seconds and the Power LED will start to blink when the restore process begins, this will take around two minutes to complete. Now try logging in as admin again.

Once logged in, change the admin password to something else, if left at the default it will refuse to work.

If you are really unlucky the reset button may have been disabled in the firmware. At this stage I don’t know what to do if this has happened.

You can also configure the device by pressing the star button on your handset four times (****) but that way madness lies.

Upgrade the Firmware

At time of writing, the firmware version available from Cisco is Release 1.4.1 SR5. The update appears to be fixing a variety of security problems. You can find the current Firmware Version in Status > System Information.

Updating is straight forward. Download the file, and unzip it to extract the Payton_1.4.1_SR5_101419_1250_pfmwr.bin file, then in the SPA122 pages in your web browser go to Administration > Firmware Upgrade and follow the instructions. Everything here has been written for this version of the firmware.

Network Configuration

Even though in this case we won’t be using this as VoIP over the network, it still needs a network connection to operate.

In the Network Setup > Network Service set this to Bridge. This will allow a computer plugged into the yellow ethernet port to access / pass through to the blue Internet port which would be connected to your LAN.

Make a note of the SPA122’s WAN MAC Address, found in Status > System Settings, it may be useful for finding the box on your network when you make it available on your LAN in the next step.

Now to access the SPA122’s web pages from your LAN, go to Administration > Web Access Management and set Admin Access to Enable. Apply the changes and attach a cable from your LAN to the blue Internet port, you should now be able to login from any computer on your network. Your main router will have a list of attached devices, use the MAC address to help quickly find the designated IP address. The computer you were using to configure the ATA may need restarting to pick up an IP address from the LAN.

Although I have not tested this, with a handset attached to one of the phone ports dial * * * * and listen, if you can hear a slightly sinister automated voice saying “System Configuration Menu” then dial 1 1 0 # slowly, the key presses are read back to you, the device will then tell you its IP address 192.168.x.x.

SPA122 Ports
SPA122 Ports

Telephone Configuration

Now we are in the Voice section. At this stage listening on a handset just produces silence, or a quiet buzzing, like from a poor power supply. For setting up the ATA will need to be restarted several times. Go to Quick Setup and set the user and dial plan for each line. The dial plan describes how the call is to be handled, numbers can be blocked, routed to different ones, or in this case be routed to another port.

Line 1:
User ID: 101
Dial Plan:
(*xx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.|<018118055:101>S0<:@127.0.0.1:5061>|)

Line 2:
User ID: 100
Dial Plan:
(*xx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.|<018118055:100>S0<:@127.0.0.1:5060>|)

I have used 018118055 as the number, but you can set this to anything you like. Both phones are on the same number, but they behave separately so you can ring one from the other. If the phone has a caller ID display it will show the user ID, 100 or 101.

Click submit to save the changes, once restarted and logged back in, we now need to add a bit more detail, go to Voice > Line 1, and set the following:

Proxy and Registration:
Make Call Without Reg: yes
Ans Call Without Reg: yes
Audio Configuration:
Preferred Codec: G729a
Second Preferred Codec: G711u
All lines that start with FAX: set to no or none as appropriate
Modem Line: yes

The FAX settings are to do with using modems in the future. All other settings can be left at their defaults. Click submit to save the settings, this takes a few seconds, and once you have logged back in go to Voice > Line 2 and set the same settings as those you just set for Line 1.

You should now be able to make a call from one phone to the other, but the ring and dial tones will sound wrong as they are for those used in the USA.

Setting the Tones

Now we need to set the dial tones and ringer for those used in the UK, in Voice > Regional you can see there are quite a few options to be set, but here I will only be setting the ones most commonly used.

Call Progress Tones:
Dial Tone: 350@-19,440@-22;10(*/0/1+2)
Busy Tone: 400@-20;10(.375/.375/1)
Off Hook Warning Tone: 480@-10,620@-16,1400@0,2060@0,2450@0,2600@0;60(.2/0/1,.2/0/2);240(.1/.1/3+4+5+6)
Distinctive Ring/CWT Pattern Names:
Ring1 Cadence: 60(.4/.2,.4/2)
Ring2 Cadence: 60(1/2)
Ring3 Cadence: 60(.25/.25,.25/.25,.25/1.75)
Ring4 Cadence: 60(.4/.8)
Ring5 Cadence: 60(2/4)
Ring and Call Waiting Tone Spec:
Ring Waveform: Trapezoid
Ring Frequency: 25
Ring Voltage: 60
Frequency: 400@-10
Miscellaneous:
FXS Port Impedance: 370+620||310nF
FXS Port Input Gain: 0
Caller ID Method: ETSI FSK With PR (UK)

My source for UK Regional Settings is below in the Links and Sources where you can find the complete list.

My Work Here is Done

Congratulations, you can now ring one telephone from another using the old fashioned technique of pushing buttons.

Next in this series will be setting up for modems, and involves using a Raspberry Pi as a router.

Links and Sources

Setup a Network Camera with a Raspberry PI

In this post I am setting up a network available RTSP video camera on a Raspberry Pi 4 Model B with the latest Debian Buster installed, you will also want another ‘remote’ computer with VLC installed on the same network. I have used a camera module connected via a ribbon cable to the Pi’s video port. The performance is more like what you would see from a security camera rather than some fancy dedicated device. I will be making the configuration with a bash shell using SSH rather than the GUI.
A Camera for the Pi

Installation

If you haven’t already, enable the camera on the Pi with sudo raspi-config and go to Interface Options > Camera. To reduce the load on the computer I also set the Pi to boot to the Console in System Options > Boot / Auto Login and selecting Console, you should also check that at least 256MB of memory is allocated to the GPU in Performance Options > GPU Memory, when complete reboot to set the updated configuration.

Install some prerequisites, you may have some or all of these installed already:

Next add the Video For Linux (V4L) Repository, this adds the drivers for the video on the hardware side

and add the following line to your apt sources with $ sudo nano /etc/apt/sources.list

We can now install the V4L packages:

We now need to install the RTSP server from Git, this server connects to the V4L drivers above:

Configuration

To setup V4L, edit the configuration file $ sudo nano /etc/uv4l/uv4l-raspicam.conf and update the driver options and uncomment the h264 options:

Restart the service once you have saved the file:

Useful screen Resolutions; designation, ratio: width x height:

  • 1080p, 16:9: 1920 x 1080
  • 720p, 16:9: 1280 x 720
  • 720, 4:3: 1296 x 792
  • Standard Definition, 4:3: 640 x 480

I’ve chosen 720p 16:9 widescreen, this gives a good image quality without stressing the Pi 4B. The framerate is a compromise between quality and usability, its unlikely you would want to go above 25fps.

Connecting

If you don’t know it already, find the IP address of your Pi with $ ip a. Look for the address in eth0 or wlan0 depending on if you are using ethernet or wireless. In this case I will be using 192.168.2.33 in the examples.

Start the RTSP server with:

Replace user:password with a suitable username and password. I have assumed that the camera is on /dev/video0, you can test this with:

and look for a line such as Driver version: 5.10.17, if this is 0.0.0 then try a different device, /dev/video1, /dev/video2 etc.

On a successful load it will tell you the connection:

Now on your ‘remote’ computer open VLC and choose Media > Open Network Stream and place the given stream address into the network URL, you will then be asked for the username and password. For me it took less than five seconds for an image to appear, there is a fairly high latency on the image shown, the picture lags by about a second from reality.

Using OpenCV

You can access the stream using Python scripts and OpenCV on your ‘remote’ computer for AI/Machine Learning. For me this is a Debian Linux box with FFmpeg as OpenCV uses this to access the stream.

You can check OpenCV is working with FFmpeg with:

and looking in the output for FFMPEG saying YES:

Links and Sources