Open jgelsey opened 1 year ago
I've hit this one twice so far. I'll collect more data next time if needed, but for whatever reason, Analyzer is reading in more data (in my case, 5 chunks instead of 10); if there's a successful detection in the latter half, this error occurs when it tries to write the resulting .mp3.
To temporarily fix this issue, you simply need to edit the offending .csv in StreamData-Analyzed to claim the detection occurred earlier in the file. (You can also simply delete it, but this way you don't even lose the detection!)
I'll gather more data next time (the offending .csv and .wav, and the following .csv and .wav.) Don't quote me on this, but I do think that the .wav was indeed twice as long as it should have been.
And this certainly will happen again, so I expect to have a re-create in the next day or two: I searched the logs, and "READ 10 CHUNKS" (signaling a too-long file) seems to occur once or twice an hour. The next time there's a successful detection in the 2nd half of one of those, the bug will trigger again.
So I can be helpful, what would be useful to collect? Besides the relevant journalctl entries (although they don't reveal anything interesting; it looks like the sound file should only be 15 seconds long.)
Here's my diagnostic data:
Here's a script I put in place to work around the issue: (courtesy chatgpt... I dimly remember shell scripting from college a quarter-century ago... took me minutes instead of hours to write this!) This looks for the oldest file of a particular type in a directory, and if it's still there 30 seconds later, delete it. In our case, we want to delete a .csv file that's still there 30 seconds after creation, since it's supposed to process these in less than 15 seconds. (After the deletion, the normal BirdNet scripts will clean up the whole directory once it gets caught up, including the over-sized .wav file.)
Obviously you'll want to modify the sleep time if your interval is different from 15 seconds. (e.g. If running on a Pi Zero once a minutes, you'll want to sleep for two minutes.)
The script is stored in /root.
@#!/bin/bash
# Define the directory and file extension
directory="/home/pi/BirdSongs/StreamData-Analyzed"
extension=".csv" # Change this to your desired file extension
logfile="/root/csv_logfile.txt" # Specify the path to your logfile
# Check if the directory exists
if [ ! -d "$directory" ]; then
echo "Error: Directory does not exist.">> "$logfile"
exit 1
fi
# Check if there are any files with the specified extension
files=("$directory"/*"$extension")
if [ ${#files[@]} -eq 0 ]; then
echo "No files with the specified extension found." >> "$logfile"
exit 0
fi
# Find the oldest file
oldest_file="${files[0]}"
oldest_time=$(stat -c %Y "$oldest_file") 2>> /dev/null
for file in "${files[@]}"; do
file_time=$(stat -c %Y "$file") 2>> /dev/null
if [ "$file_time" -lt "$oldest_time" ]; then
oldest_file="$file"
oldest_time="$file_time"
fi
done
# Wait for 30 seconds
sleep 30
# Check if the oldest file is still present
if [ -e "$oldest_file" ]; then
# Delete the oldest file
rm "$oldest_file"
echo "$(date '+%Y-%m-%d %H:%M:%S') Deleted the oldest file: $oldest_file" >> "$logfile"
fi
And don't forget to chmod 755 csv_cleanup.sh to make it executable!
I put in a crontab entry of /5 * /root/csv_cleanup.sh
and that seems to have stopped the problem cold. I had it set to every 30 minutes, but if the problem happened twice in a half-hour, it still got stuck.
Obviously, you will not have recordings for these particular birds in your files, though birdweather still runs on the detection.
BirdNet stoped analyzing yesterday with "
sox FAIL trim: Position 1 is behind the following position
" in the log. I see "unable to reach network" in the output ofprint_diagnostic_info.sh
(below) but a ping has no trouble reaching the mentioned network device, and the rtsp streams play fine in VLC media player.Tools->System Controls->Clear ALL Data
got detections started again. FWIW using 7 rtsp streams for audio input (from Unifi cameras), no USB microphone.