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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Preconfiguring packages...
(Reading database...33018files anddirectories currently installed.)
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
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
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:
Don’t forget to change my IP address to yours, save the file and then attempt to connect with:
1
%ssh root@192.168.1.103
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
Alternativley, in the terminal you can set the options and connect with:
/usr/bin/dbclient: connection to karlm@192.168.1.58:22 exited: no matching algo kex
lost connection
The fix for this is to copy the file using the computer you are connecting to the Radio with:
1
2
3
4
%scp-Oroot@192.168.1.103:~/crashlog.KDYe8t.
root@192.168.1.103'spassword:
crashlog.KDYe8t
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:
1
2
# uname -a
Linux SqueezeboxRadio2.6.26.8-rt16#1 PREEMPT RT Fri Feb 14 09:02:51 PST 2014 armv5tejl GNU/Linux
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:
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:
1
2
3
4
sudo chroot/oldssh/bin/bash
apt get update
apt install bash openssh-client nano
mkdir/root/.ssh
you should now be able to login to the Squeezebox:
1
2
3
4
5
ssh-oKexAlgorithms=+diffie-hellman-group1-sha1\
-oHostKeyAlgorithms=+ssh-rsa,ssh-dss\
-oPubkeyAcceptedKeyTypes=+ssh-rsa\
-oCiphers=+aes128-cbc,3des-cbc,aes256-cbc\
root@192.168.1.103
And because life is too short to remember all that, create a nano /root/.ssh/config file with the following:
1
2
3
4
5
6
Host192.168.1.103
User root
KexAlgorithms diffie-hellman-group1-sha1
HostKeyAlgorithms ssh-rsa,ssh-dss
PubkeyAcceptedKeyTypes ssh-rsa,ssh-dss
Ciphers aes128-cbc,3des-cbc,aes256-cbc
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:
1
2
sudo chroot/oldssh/bin/bash
ssh root@192.168.1.103
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:
1
2
3
4
5
6
[buster-oldssh]
description=Debian Buster chroot forlegacy SSH
directory=/oldssh
users=yourusername
root-users=yourusername
type=directory
and in your home directory add the file squeezessh.sh with the following:
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
IP_ADDRESS='192.168.1.103'
schroot-cbuster-oldssh--ssh\
-oKexAlgorithms=+diffie-hellman-group1-sha1\
-oHostKeyAlgorithms=+ssh-rsa,ssh-dss\
-oPubkeyAcceptedKeyTypes=+ssh-rsa\
-oCiphers=+aes128-cbc,3des-cbc,aes256-cbc\
root@$IP_ADDRESS
now set it to executable chmod +x squeezessh.sh and run it ./squeezessh.sh
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:
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
>ssh-keygen-ted25519
Generating public/privateed25519 key pair.
Enter file inwhich tosave the key(C:\Users\<username>/.ssh/id_ed25519):
Enter passphrase(empty forno passphrase):
Enter same passphrase again:
Your identification has been saved inC:\Users\<username>/.ssh/id_ed25519.
Your publickey has been saved inC:\Users\<username>/.ssh/id_ed25519.pub.
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:
1
2
3
4
5
$cd~/.ssh
$touch authorized_keys
$cat id_ed25519.pub>>authorized_keys
$chmod600authorized_keys
$rm id_ed25519.pub
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:
1
2
3
4
5
Host piComputer_192.168.2.45
HostName192.168.2.45
User<username>
ForwardAgent yes
IdentityFileC:/Users/<username>/.ssh/id_ed25519
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.
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.
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:
To setup V4L, edit the configuration file $ sudo nano /etc/uv4l/uv4l-raspicam.conf and update the driver options and uncomment the h264 options:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
##################################
# raspicam driver options
##################################
encoding=h264
#720p
width=1280
height=720
framerate=12
### h264 options:
profile=high
level=4.2
bitrate=8000000
intra-refresh-mode=dummy
intra-period=#arg
inline-headers=yes
sps-timing=no
quantisation-parameter#arg
Restart the service once you have saved the file:
1
$sudo service uv4l_raspicam restart
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.
Play thisstream using the URL"rtsp://192.168.2.33:8555/unicast"
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/env python
import os
import cv2
# if the script doesn't work, uncomment the following, OpenCV may be
# defaulting to TCP when we are wanting to use UDP.
The Jetson Nano Developer kit – B01 is a small computer comprising of an NVIDA Maxwell GPU, Quad-Core ARM Cortex-A57 Processor and 4GB of Memory along with four USB 3 ports, Gigabit Ethernet, HDMI and Display Port output, main storage is on a MicroSD card and there is a variety of selection of expansion available via GPIO, I2C and UART. On the software side NVIDIA provide their JetPack SDK – a customised version of Ubuntu. This development kit has been produced to provide an entry point into Machine Learning, for which I will be using Python programming language. I got my board from Pimoroni
These notes cover my process of setting one up and links to the documentation, it not intended to repeat those install guides but to provide an install sequence and any additional commentary as needed. I’m going to assume you have a little experience of using the terminal and am familiar with using the bash command line – I’ve no idea how this would be done through the GUI.
Jetson Nano ports [source: NVIDIA]
Initial Startup
I followed the instructions for downloading and installing JetPack 4.4 on https://nvidia.com/jetsonnano-start I used a 64GB Class 10, UHS-I, U3, V30 SanDisk card. I formatted the card in a camera before using balenaEtcher to write the JetPack SDK image, this creates a partition of about 16GB on the card formatted to ext4, during installation the volume is resized to fill the card.
Jetson Nano connections [source: NVIDIA]
Despite using a good quality USB power supply with an output of 3 Amps at 5 Volts into the Micro USB port the computer would only boot long enough for the NVIDIA logo to appear on screen but after a few seconds the green power LED would go out and it would be off, the same happened when I tried a variety of USB power supplies used. I got round the problem buy using a 5 Amp power supply connected to the barrel jack J25 on the left (centre pin positive) and connecting the jumper J48 located just behind this connector.
Customising the Setup
There are a couple of thigs to do, get a network volume mounted and set the default version of python.
For the network share install samba, some network utilities and the nano text editor:
1
$sudo apt install samba cifs-utils nano
create a text file: sudo nano /etc/samaba/videoserver with the following:
1
2
username=<your network username>
password=<your network password>
And set the permissions sudo chmod 600 /etc/samba/videoserver. In this example I have a network share on my server; 192.168.1.30, called video. Create a mount point for the share: sudo mkdir /mnt/video now you need to edit fstab, sudo nano /etc/fstab and add your network connection to the end:
Reload fstab with sudo mount -a and check for any errors. Because of the way that Jetpack boots it does not appear to wait for the network so the share needs to be set to automount and this causes it to only appear in drive listings when accessed. Further reading can be found in this excellent guide to fstab: https://wiki.archlinux.org/index.php/fstab.
Jetpack 4.4 comes with two versions of Python, 2.7 and 3.6, I want it to default to 3.6 and while this is rather out of date I don’t want to go down the hole of upgrading just yet, you will also need to install pip and set pip3 as the default too.
I did get an error later on, a crash was reported on the desktop when an occasional python 2 script ran. I fixed the error in /usr/sbin/l4t_payload_updater_t210 by changing the first line of the file from !#/user/bin/python to !#/user/bin/python2
Post Install Problems
A recent update occured, so I did the usual sudo apt get update && sudo apt get upgrade but one of the files gave a script error, this turned out to be with nvidia-l4t-bootloader, like so:
Setting up nvidia-l4t-bootloader(32.4.3-20200924161615)...
3448-300---1--jetson-nano-qspi-sd-mmcblk0p1
Starting bootloader post-install procedure.
Update bootloader completed.
Reboot the target system forchanges totake effect.
Updating extlinux.conf...
Root device isset inthe extlinux.conf
Afterwards I set the default back to python 3.6 again.
Setup the Machine Learning
There are three Machine Learning packages, OpenCV for Computer Vison, Tensorflow for machine learning models, and TensorRT – accelerated deep learning networks for image recognition.
The Micro SD Card I use in a Raspberry PI ran out of space so here is how I copied the contents of the 15GB drive to a new 64GB card and resized the partition. I used a separate computer running Debian and as the machine does not have a monitor or keyboard attached this will be being completed through the bash command line using SSH.
1. Making a copy of the SD Card.
Insert the old card into your computer, if the computer attempts to mount the drive then unmount it. We need to find which mount point has been used, do this with the lsblk command:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda8:00477G0disk
āāsda18:10512M0part/boot/efi
āāsda28:20468.9G0part/
āāsda38:307.6G0part[SWAP]
sdb8:160477G0disk
āāsdb18:170477G0part/mnt/external_ssd
sdc8:3201.8T0disk
āāsdc18:3301.8T0part/data
sdd8:4803.7T0disk
āāsdd18:4903.7T0part/mnt/external_hdd
sde8:64114.9G0disk
āāsde18:65143.8M0part
āāsde28:66114.8G0part
The device sde matches our SD card. So we will use that. The dd command is used to create the ISO image, I am creating the file in my home directory:
The copied partition is now the same size as the original. If you have space remaining, the new card can be put back in the Pi and use the raspi-config utility, and using the Expand Filesystem option in the Advanced Settings section. However if the drive is completely full you won’t be able to login as there won’t be enough space available for the temporary files created at login, to get round this you can use parted to resize, start with:
1
$sudo parted/dev/sde
if you get the following message:
1
Warning:Unable toopen/dev/sde read-write(Read-only file system)./dev/sde has been opened read-only.
then quit from parted, if you are using a full size SD Card, check the Write Protect tab on the side of the card and try again, otherwise try:
1
2
3
4
5
$sudo hdparm-r0/dev/sde
/dev/sde:
setting readonly to0(off)
readonly=0(off)
If problem persists try formatting the new card in a camera, as these have a simple file system, and write the ISO image again.
We need to resize the larger partition /dev/sde2 with the ext4 file system, the smaller is used to boot the Pi and can be ignored. In parted, list the partitions with the print command:
1
2
3
4
5
6
7
8
9
10
11
$sudo parted/dev/sde
(parted)print
Model:Generic-USB3.0CRW-SD(scsi)
Disk/dev/sde:63.9GB
Sector size(logical/physical):512B/512B
Partition Table:msdos
Disk Flags:
Number Start EndSize Type File system Flags
14194kB50.1MB45.9MBprimary fat32 lba
250.3MB15.9GB15.9GBprimary ext4
Using resizepart set the new size, I set this to larger than the 15GB but smaller than the unallocated space, this to save me having to accurately work out the remaining space manually:
1
2
(parted)resizepart2
End?[15.9GB]?40GB
Now update the boundaries to grow and resize the partition into the freshly allocated space:
1
2
$sudo/sbin/e2fsck-f/dev/sde2
$sudo/sbin/resize2fs/dev/sde2
Now boot the Pi with the new card, login and use the raspi-config utility then in Advanced Options choose Expand Filesystem and follow the onscreen instructions. Once rebooted you should now be set to fill up your new card.
While extracting the telemetry data from the GoPro is reasonably well documented I have found some gaps for getting the extracting utilities installed and when extracting and combining data from multiple files. These notes are for a Debian/Ubuntu installation in a BASH Shell.
Installing the gopro-utils
As I couldn’t find any straightforward instructions for installation, I’ll be going through everything I needed to do to get it working, you may have some of these packages installed already.
1
2
3
sudo apt update
sudo apt upgrade
sudo apt install ffmpeg golang gpsbabel git
Now to get the gopro-utils and install them, I’m placing the source files into my Downloads directory, as well as the GPS data extractor we’ll be adding the other telemetry tools too, this is all a bit long winded.
go get github.com/JuanIrache/gopro-utils/telemetry
go get github.com/mlouielu/gpxgo/gpx
cd bin/gopro2gpx
go build gopro2gpx.go
sudo cp gopro2gpx/usr/local/bin/
cd../bin/gopro2geojson/
go build gopro2geojson.go
sudo cp gopro2geojson/usr/local/bin/
cd../gopro2json/
go build gopro2json.go
sudo cp gopro2json/usr/local/bin/
cd../gpmd2csv/
go build gpmd2csv.go
sudo cp gpmd2csv/usr/local/bin/
cd../gpmd2info/
go build gpmd2info.go
sudo cp gpmd2info/usr/local/bin/
cd../gps2kml/
go build gps2kml.go
sudo cp gps2kml/usr/local/bin/
Extracting the Data
You will need to find which stream in the video recording the data has been saved to, to find this use ffprobe to examine the recording and look for the stream that contains GoPro MET, for example:
You can see that what we are wanting is on stream 3, as far as I can tell this stays the same every time, I don’t know if it is different for other GoPro models.
This bash script extracts the GPS data in GPX format from all the GoPro GX recordings in the directory, other options have been commented out, if you are using Garmin VIRB edit there is also an option for use with that. The script creates two files, one that contains the raw data and another with the desired GPS data, the GPS output file has the same name as the recording, but in lowercase with a .gpx extension.
#gopro2gpx -i "$BINFILE" -a 200 -f 3 -o "$OUTFILE-virb.gpx"
#gopro2json -i "$BINFILE" -o "$OUTFILE.json"
done
Merging GPX files
As the GoPro splits recordings into 4GB blocks, when extracting you will get a single GPX file for each recording. Many pages found by Google say that to create a single track from these all you need to do is append the files into one big file. This is wrong, what you end up with is a single file with many short tracks, when what you are after is one long track covering the entire journey. This bash script uses gpsbabel to create single merged file from the extracted GPX data, it creates a file called “gpsoutput.gpx”.
FFmpeg is a command line program to manipulate, convert, record and stream video and audio, it is available for Mac, Linux and Windows. Here is a handy list of commands for reference, these have been tested with version 3.1.12 in a Debian Linux environment. I expect this list to grow over time as needs arise.
Using this codec reduces the time it takes for the video to be available after upload, however YouTube converts the file again to the VP9 codec and unless you have a popular channel, 100 subscribers or more, then this can take a few days or weeks and in the meantime your video can appear quite poor and blocky even when watching at 1080p, especially when there is a lot of movement like in a car dash-cam video. You can use FFmpeg to encode to VP9 webm format with this bash script:
This script is based on the encoding method shown in the WebM Wiki on my computer it is very slow and takes a quite a few hours to encode just nine minutes of video and the eventual results are so poor you’ll be wondering why you bothered.
⢠Convert to MP4 for use in Vegas Studio:
1
2
3
ffmpeg-iinputFile.mkv-codec copy outputFile.mp4
If you have a particularly old/odd video and get lots of pts has no value errors, then try this:
The -fflags +genpts option adds a Presentation Timestamp (PTS) to the frames, this must be before the -i as shown to work. Source.
⢠Set the video playback speed, this method adjusts the Presentation Timestamp (PTS) on each frame which may not work with older software. To slow down video divide the PTS by your required speed, this example slows the action by two times setpts=PTS/2.0. You can also reduce the number of dropped frames by increasing the frame-rate -r 50, in this case I went from 25fps to 50fps, but depending in the chosen speed frames may still be dropped.
⢠Concatenate Video Files
This combines two video files, when using formats such as MP4 or MKV you will need to create intermediate files, otherwise only the first file will be included in the output:
⢠The opus not found error
When converting a file and you see an error like Could not find tag for codec opus in stream #1… you will need to state the output format
Here is a small Bash script that converts any supported ffmpeg video format; such as .MKV, .MP4 or .MOV and extracts the audio to an .MP3 file, It will also split that MP3 file into chunks and put them in a convenient directory. You will need to install ffmpeg and mp3splt for your particular platform.
Example Usage:
mkv2mp3 example
Shell
1
./mkv2mp3"big fat file.mkv"
This uses ffmpeg to convert “big fat file.mkv” toĀ “big fat file.mp3” and then uses mp3splt to create a directory “big fat file” containing the files 01 – big fat file.mp3,Ā 02 – big fat file.mp3, etc. The MP3 files will be encoded at 128k Constant Bit Rate and each file will be around 50 minutes in length. To install in Debian/Ubuntu use: sudo apt-get install ffmpeg mp3splt
mp3splt can find the audio in a quiet region near where the split is desired rather than midway through a word, this should make for much cleaner playback across tracks.
Alternative Method
This script gives the same results but uses ffmpeg to split the large MP3 file and then adds track numbering metadata using id3v2. To install in Debian/Ubuntu use: sudo apt-get install ffmpeg id3v2
Taking this further, I was thinking that it would be nice to have these converted into the M4B Audiobook format for use on my elderly iPod. The script below assumes that you have processed the files as above and have added metadata tags using a tool like mp3tag (yes I know this is for Windows).
To complete this we need to: Combine the multiple MP3 files into one big file, or read the original big file then convert that to M4B format at 96K bit and add chapter marks every ten minutes. For this I have used ffmpeg v3.2.12 and libmp4v2 (for the mp4chaps utility), to install in Debian/Ubuntu use: sudo apt-get install libmp4v2-dev mp4v2-utils ffmpeg
This script works best from a single MP3 file rather than from those that have been re-combined back into a single file, recombining the files caused ffmpeg to exclaim “invalid packet size” and “invalid data” errors. It is able to tell the difference between a directory and a single MP3 and processes the file accordingly, don’t forget to add metadata tags and cover art before you run the script.
mp3tom4b
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
INFILE="$1"
BITRATE="96k"
MP3TITLE=""
MP3ARTIST=""
MP3ALBUM=""
MP3COMMENT=""
MP3YEAR=""
MP3PERFORMER=""
####
#### FUNCTIONS
####
functionsetMP3variables(){
TAG="$1"
VALUE="$2"
case"$TAG"in
title)
MP3TITLE="$VALUE"
;;
artist)
MP3ARTIST="$VALUE"
;;
comment)
MP3COMMENT="$VALUE"
;;
album_artist)
MP3PERFORMER="$VALUE"
;;
album)
MP3ALBUM="$VALUE"
;;
date)
MP3YEAR="$VALUE"
;;
esac
}
## get the tag text from the metadata
## if the line contains an equals (=) then split by the first equals.
functiongetMP3tags(){
MP3METADATA="$1"
whileread-rline
do
case"$line"in
*=*)
TAG=${line%%"="*}
VALUE=${line#*"="}
setMP3variables"$TAG""$VALUE"
;;
esac
done<"$MP3METADATA"
if[[!-z"${MP3TITLE// }"]];then
OUTFILE="$MP3TITLE".mp3
M4BFILE="$MP3TITLE".m4b
fi
}
####
#### BEGINS
####
FILENAME=$(basename"$INFILE"|cut-d.-f1)
if[[-z"${FILENAME// }"]];then
echo"filename missing"
exit1
fi
OLDIFS=$IFS
OUTFILE="$FILENAME"_out.mp3
M4BFILE="${OUTFILE:0:-4}".m4b
METADATA="${OUTFILE:0:-4}".metadata
JPGFILE="${OUTFILE:0:-4}".jpg
## check if input is a diretory
if[-d"$INFILE"];then
# get the name of the first MP3 file in the directory
These appear to be caused by the mp3splt program from when the original MP3 file was being split into 50 minute chunks, but I can’t hear any effect on the output.
Lots of information about the file can be gotten using mediainfo, to install in Debian/Ubuntu use: sudo apt-get install mediainfo, example use:
Bluetooth Low Energy – BLE – Bluetooth 4.0 is an industry-standard wireless protocol built for the Internet of Things – IoT, it is designed to provide connectivity for devices operating from low capacity power sources such as coin cell batteries.
Raspberry Pi2 with ASUS USB-BT400 Bluetooth 4.0 Dongle
In this introduction to BLE I’ll be configuring a Raspberry Pi2 computer to talk to a smart watch. We will be installing the latest version of BlueZ from source, enabling BLE support. This is not a tutorial on decoding the data from the watch I am just using it as an example, although I may write about decoding it in a future posting.
I am using a ASUS USB-BT400 Bluetooth 4.0 Dongle on a Raspberry Pi2 but this will work on any computer with a Debian based distribution. Your dongle must be BLE/Bluetooth 4.0 capable otherwise this won’t work. I am using an ID107HR activity tracker with pedometer and heart rate monitor, randomly chosen from the list of cheap ones available on Amazon. While using the Pi to talk to the the watch make sure Bluetooth on the phone is off as it can only connect to one device at a time.
The current distribution of Raspbian – jessie on the Raspberry Pi comes with version 5.23 of the BlueZ Bluetooth stack that’s rather old, dating from September 2014 which lacks many of the features we will be needing. The current version 5.44 of the BlueZ has many changes in the package with many familiar components such as hcitool and gatttool being depreciated, so I will be ignoring those and using the available commands, bluetoothctl, on the terminal.
Installing BlueZ
With Raspbian – jessie installed we will need to update the Pi make sure some packages are installed and then installing the latest version of BlueZ. But first, remove the installed version 5.23 of BlueZ:
removing the installed bluez
1
2
$sudo apt-get--purge remove bluez
$sudo apt-get autoremove
Next, perform the traditional housekeeping updates then install the build tools and USB libraries. Those parts that are installed already will be automatically skipped.
Inside the BlueZ directory, configure, make (this takes a while), and install. The experimental option adds BLE support and enabling the library allows for python use later on:
installing bluez
1
2
3
$./configure--enable-experimental--enable-library
$make
$sudo make install
Configuring and Starting BlueZ
At this stage we will need to check that the installation worked and that we can see your bluetooth dongle. With your bluetooth dongle in a USB port you should see it on your list of USB devices, here you see mine as device ID: 0b05:17cb ASUSTek Computer, Inc.:
dongle view
1
2
3
4
5
6
$lsusb
Bus001Device006:ID0b05:17cbASUSTek Computer,Inc.
Bus001Device004:ID046d:c52e Logitech,Inc.
Bus001Device003:ID0424:ec00 Standard Microsystems Corp.SMSC9512/9514Fast Ethernet Adapter
You will also need to enable the experimental services, edit the file /lib/systemd/system/bluetooth.service and in the [Service] section change the ExecStart line to end with –experimental:
for first time use, try scanning to find your watch, if it doesn’t appear it is out of range, its battery is flat, or your dongle does not support BLE, here you can see it as ID107 HR:
bluetoothctl remembers your devices, so when you next use the program the watch appears on the list at the start. The controller has a number of options, these can be seen with help command. You can use show to view the status of your dongle:
UUID:A/VRemote Control Target(0000110c-0000-1000-8000-00805f9b34fb)
Modalias:usb:v1D6Bp0246d052C
Discovering:no
The list of UUID’s show the services supported by the Dongle. Now we can power the dongle on, set the agent – this manages the connection, and then connect to the watch on which the bluetooth symbol will appear. Once connected there will be a pause then you will see a list of attributes supported by the watch, it is advertising the services available:
These UUID’s are used to describe the sevices available on the device, some are pre-defined and can be found in the a href=”https://www.bluetooth.com/specifications/gatt/characteristics” target=”_blank” rel=”noopener noreferrer”>GATT schema, others are vendor specific and unless they publicly release these, decoding can become rather difficult. There are four types of attribute:
Services – collections of characteristics and relationships to other services that encapsulate the behavior of part of a device
Characteristics – attribute types that contain a single logical value
Descriptors – defined attributes that describe a characteristic value
Declarations – defined GATT profile attribute types
Each attribute is identified by a 128 bit ID, for example, one of the characteristics from the list above: 00002902-0000-1000-8000-00805f9b34fb, the first eight bits are used as an unique identifier: 00002902 and are shown as UUID’s: 0x2902. Data is contained in services, each service has a number of characteristics that may contain further descriptions depending on the requirement of the characteristic. You can see how the data is mapped out in this chart:
Service Containers
A spreadsheet with the watch data reformatted and tastefully coloured to illustrates this. Observe the Service URL column, it looks a lot like a directory structure:
Here we see two services /service0008 and /service000c looking further into the second service: /service000c we see that it has four characteristics, and to of those have descriptors. We can interrogate the characteristics and descriptors to glean further information by selecting the attribute and reading, like so:
Which is all very nice, but not particularly helpful as the manufacturer has chosen to use custom, proprietary, UUID’s for the watch. We don’t know the instructions to send to have the watch realease its data.
Those Scripting BlueZ
Inevitably, you’ll be wanting to automate connections. This becomes easy with the automation scripting language expect. Install, then make a script file:
install expect
1
2
3
4
$sudo apt-get install expect
$cd~
$nano bttest
$chmod+xbttest
In this example the script forgets the watch, finds the watch, connects to the watch, gets some info and then disconnects:
expect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/expect -f
set timeout10
set prompt".*#"
set usrpasswd""
set address"C5:E8:FB:BF:F2:6C"
## execute blutetoothctl
spawn sudo bluetoothctl
expect-re".*password.*"
send"$usrpasswd\r"
## forget about the device - if connected previously
expect-re$prompt
send"remove $address\r"
expect-re$prompt
sleep3
## switch on the dongle
send"power on\r"
expect"Changing power on succeeded"
expect-re$prompt
## scan for devices
send"scan on\r"
expect-re$prompt
sleep5
send"scan off\r"
expect-re$prompt
## set the agent
send"agent on\r"
expect"Agent registered"
send"default-agent\r"
expect-re$prompt
sleep2
## connect to watch
send"connect $address\r"
expect-re$prompt
## get some info
send"info $address\r"
expect-re$prompt
## disconnect
send"disconnect $address\r"
sleep2
expect-re"\[bluetooth\]#"
## bye
send"exit\r"
in the script, send sends a command, don’t forget to add the carriage return – \r and expect is used to wait for a response within the timeout period, here it is set to 10 seconds. expect -re is using regex when looking for a reply, otherwise it uses a literal string. So much more can be done with expect and there are many tutorials, such as this one written by FluidBank.
More Bluetooth Data
For analysing bluetooth data a couple of very useful tools are available, Wireshark and Android data logging. I will go through the installation but not look at the data in any detail, this posting is getting a bit long. This Section is in two parts, installing Wireshark and Android Debug Bridge.
Sniffing with the Shark
Wireshark is a network and bluetooth packet sniffer, it shows you network and bluetooth traffic occurring on your Pi. HereĀ is a quick installation method for a reasonably new version of Wireshark (v2.2.4) from the backports, answer yes to the question “Should non-superusers be able to capture packets?”:
and if you get a message about permissions, reconfigure the package and answer yes:
wireshark install
1
$sudo dpkg-reconfigure wireshark-common
Start Wireshark and double click your bluetooth device on the list, in my case bluetooth0. There is not much to see as Wireshark will only see traffic between the watch and the Pi:
Wireshark Data Capture
Android Debug Bridge – ADB
For Anroid 4.2.2 and above, activate developer mode on the phone, go to Settings, tap About Phone and at the bottom of the list tap Build Number three times. Back in the main settings page Developer Options has appeared, tap developer and turn USB debugging On. With the phone plugged into a USB port a little Android head should appear in the information bar at the top-left of the screen. To begin we will need to install some udev rules written by Nicolas Bernaerts:
At this point on the phone an allow USB debugging dialog will appear, give permission and always trust to authorise it. ADB will now show the device as a device:
android tools install
1
2
3
$adb devices
List of devices attached
064be417008eef9fdevice
If the device list is empty, with everything plugged in good and proper and the phone setup in developer mode, start your diagnosis by checking udev; open another terminal window and view logging with udevadm monitor –environment and reload with sudo udevadm control –reload I’m not entirely sure what I did to get it from ‘not working’ to ‘working’. If all else fails elevate yourself to root.
Data Capture
With ADB now setup we can capture the Bluetooth data being exchanged. With bluetooth off, in the Developer Settings find Enable Bluetooth HCI snoop log and turn it On. In the smartwatch app synchronise with your watch, once complete turn Bluetooth off manually – this is to minimise the amount of captured data. Don’t forget to turn logging off on the phone when done. To find where the log file has been stored and copy the file from the phone to the Pi use:
This wasn’t quite the posting I originally had in mind, I wanted to decode the data from the watch for my own use, making something more useful, impressive graphs and charts, than that provided by the Android App VeryFit 2.0 but as the manufacturer has chosen to use proprietary GATT codes it makes the job that much harder. It may be much simpler to just buy an expensive FitBit and download the data from them. But with writing this I now know a few things that were previously unknown, and I hope that this has provided some light to your BlueZ (a pun!, right at the end!).