Closed DD4WH closed 2 years ago
@DD4WH Hi, Frank! So great to hear from you and to get the update on your long-running setup! November! That's great! It is also really gratifying to hear that you have learned new behavioral patterns for the Pygmy Owls from using BirdNET-Pi -- what a wonderful outcome.
Thank you also for this thoughtful and, as always, very clear and manageable request. I should be able to implement this for you. I am still away from my installation and forgot to arrange remote SSH access to it, so I cannot reach it for testing at this time. But here is what I'm thinking:
NEWFILE="${COMMON_NAME// /_}-${CONFIDENCE_SCORE}-${OLDFILE}"
could look like
NEWFILE="${COMMON_NAME// /_}-${OLDFILE}"
I believe this would achieve what you are hoping for (in the short term without a birdnet.conf
option). The thought behind this is that there is a check in the script that will not make an extraction if any extraction with the exact same name already exists. See the excerpt below, starting at line 72:
# If the extracted file already exists, move on
if [[ -f "${NEWSPECIES_BYDATE}/${NEWFILE}" ]];then
echo "Extraction exists. Moving on"
continue
fi
Most of the time, each detection within a recorded audio clip will receive different confidence scores, so extract_new_birdsounds.sh
will see the difference in confidence score and will create a new extraction that reflects that difference. If the extracted file names do not report the confidence score, however, the script (should) only make 1 extraction per recording per species. That way, if 2 distinct species are detected within the same original audio clip, an extraction will be made for each species. However, if 2 detections of the same species are detected within the same original audio clip, only 1 extraction will be made for that species for that recording.
The method above may work (it may not, but I think it will), though I know it is not the request you put forward. Likewise, I would like to devise a method that retains the highest confidence score per species per recording so that you know what the most confident detection score was for a given species within a recording.
I'm going to keep this open as I tinker with possibilities. In the meantime, if you are able to make the adjustment above to test, it would be really helpful. If you are unable to test that, please don't worry as I should be back with my installation later this evening or tomorrow.
My best regards as always! Patrick
Hi Patrick, thanks a lot for your very quick and very helpful answer. I tried that and it worked ! I now get one extraction each for every recorded file. However, the length of the files differ, they are shorter than the original files . . . What I would like is to extract the original file with its original length. Maybe you also have a quick fix for that ? Maybe set START = 0 and END = EXTRACTION_LENGTH permanently ?
Hey, that's great news! Thanks for testing that out.
However, the length of the files differ, they are shorter than the original files . . . What I would like is to extract the original file with its original length. Maybe you also have a quick fix for that ? Maybe set START = 0 and END = EXTRACTION_LENGTH permanently ?
That would certainly work as a short-term solution. Starting at line 127:
ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
-acodec copy -ss "${START}" -to "${END}"\
"${NEWSPECIES_BYDATE}/${NEWFILE}"
You can change that to:
ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
-acodec copy -ss "0" -to "30"\
"${NEWSPECIES_BYDATE}/${NEWFILE}"
And you should always get an extraction of 30 seconds. I'm able to tinker with my installation, now, so I will circle back with a more elegant and permanent solution for you that can be set in birdnet.conf
instead of hard-coding in the extraction script.
Thanks again for testing that out for me -- super helpful!
Yes, that hard-coded 0 to 30s works well! Thank you, it already runs on my remote BirdNET-Pi :-) Of course, you are right, would be good to be able to set this behaviour in birdnet.conf
Quick small update:
This is built into extract_new_birdsounds.sh
now, so anytime the ${RECORDING_LENGTH} == ${EXTRACTION_LENGTH}
, ${START}
will =0
and ${END}
will =${RECORDING_LENGTH}
I am still working on having only 1 extraction per recording with the highest confidence score as the keeper.
I think this was addressed -- please let me know if I am wrong about that, but it seems now that you should be able to set the extraction length to equal the recording length to achieve the desired results. I'll reopen if this is not the case.
Hi Patrick, I am still very happy with BirdNET-Pi and it is a very valuable tool for me in monitoring Pygmy Owls, as you know. I discovered they are more active in Janauary than in March (where most of the monitoring is regularly done) . . . :-) and my remote BirdNET-pi has been running successfully since November 2021 now!
This is a request for a "new"/modified feature:
This would be awesome, if you could implement it! I tried to fiddle with the script file extract_new_birdsound.sh line 115ff., but my knowledge in shell script language is very poor, so your help would be very much appreciated !
Best regards, Frank DD4WH