alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.49k stars 213 forks source link

✨ [birdnet-pi] Ongoing work #1371

Closed alexbelgium closed 3 months ago

alexbelgium commented 5 months ago

Checked

Which addon?

Birdnet-pi as legacy alternative to birdnet-go while it is developed

Is your feature request related to a problem? Please describe

List ongoing work

Describe the solution you'd like

Todo :

Improve birndet-pi

deadrubberboy commented 4 months ago

Hello! Where do I configure an RTSP input? I tried the web interface but the "tools" button says I can't config there. I only see "default" as audio option in the config.

*I'm running Scrypted add on and can get rtsp rebroadcast from there or direct from Amcrest camera. Neither is "IN" HA currently.

alexbelgium commented 4 months ago

Hi ! Ingress isn't working that much for the moment but you can access it fine using ip:port!

deadrubberboy commented 4 months ago

Hello! Not sure what "ingress" is. I can access the green page. When I tried "tools" to get to settings the first time I got an error. I got in just now though! I'll see if I can get rtsp configured. Thanks!

alexbelgium commented 4 months ago

Ingress is when accessing from HA (in the sidebar) while ip:port is a direct access :)

deadrubberboy commented 4 months ago

Thanks! I made progress. When I go to "spectrogram" I can hear my camera audio. I can actively hear birds chirping too. No detections.

When I click on "log" from the web interface I see an error "rtsp @ 0xaaaaea3eba00] method SETUP failed: 461 Unsupported Transport".

Any ideas?

alexbelgium commented 4 months ago

Well that's great! Now it means (according to chatgpt) that you are using a protocol (either tcp or udp) not supported by ffmpeg, is that an option for you to change the rtsp sound options?

deadrubberboy commented 4 months ago

I'm using Scrypted rebroadcast stream. I changed it from "scrypted TCP" to "FFMPEG TCP". Rebooting.

How can I be sure it's saving /reading a file?I see in config the default location is /config/BirdSongs - Do I need to create that folder somewhere?

deadrubberboy commented 4 months ago

Should I go by "your" log or the one on web interface (green screen)?

deadrubberboy commented 4 months ago

Sorry. I keep peppering you with stuff! Not even sure this is the best format. Sorry, I'm totally new.

Good news though! I noticed the file reference in the log was ".wav" and the setting for recording was ".mp3". I changed the mp3 pulldown to .wav and rebooted again. There's a detection! Hopefully I got it sorted. Thank you for your work on this and your patience with me specifically!

alexbelgium commented 4 months ago

Should I go by "your" log or the one on web interface (green screen)?

It's the same! It both is stdout

How can I be sure it's saving /reading a file

Whey the spectrogram you can check that the rtsp stream works. With the log you can see if there is an error. On the first page you would see the spectrogram being analyzed, and detections!

alexbelgium commented 4 months ago

Sorry. I keep peppering you with stuff! Not even sure this is the best format. Sorry, I'm totally new.

Good news though! I noticed the file reference in the log was ".wav" and the setting for recording was ".mp3". I changed the mp3 pulldown to .wav and rebooted again. There's a detection! Hopefully I got it sorted. Thank you for your work on this and your patience with me specifically!

Great! There is actually no link : the stream is read as a wav, but it is saved as a mp3 (after analysis) for future reading as a very efficient storage method. I would recommend you keep it.

deadrubberboy commented 4 months ago

I'm still seeing the error. Must have been unrelated. I'll go back in and change back to mp3. Thank you again.

deadrubberboy commented 4 months ago

Does this tell you anything? I see the RTSP error but then still says analyzing audio file?

CleanShot 2024-05-15 at 16 22 36

deadrubberboy commented 4 months ago

I AM still seeing detection pop up... 🤷‍♂️

CleanShot 2024-05-15 at 16 27 08

deadrubberboy commented 4 months ago

Popped open log again and see what looks like a success in the RTSP. I guess it's hit and miss? CleanShot 2024-05-15 at 16 43 07

alexbelgium commented 4 months ago

Well as long as it works :) perhaps your rtsp stream is not stable? You could try with an app that connects to the rtsp stream to see if there is no interruptions in the stream. It could be seen from the live spectrogram too

deadrubberboy commented 4 months ago

I switched to the sub stream direct from camera instead of the rebroadcast from Scrypted. Now I don't see the "RTSP" line in the logs come up at all. I think that did the trick. Spectrogram works, and getting detections.

Thank you again! I saw you pushed updates yesterday. Appreciate all of your efforts!

alexbelgium commented 4 months ago

I'm still adding features & corrections based on the list in the first post :-) changing misidentified species works great!

deadrubberboy commented 4 months ago

Hi! Me again. Back to bug you. Everything has been working great and I even got my bird weather api working etc.

Something broke in a recent update and rolling back doesn't fix it. It was around the time with the port change to 8081 - I've been taking all updates as I get notified of them. Last recordings were on 5/21 if that helps narrow. I can still hear live audio etc but no detections anymore. I am seeing this in the logs: CleanShot 2024-05-23 at 08 55 00@2x

Any tips on what I should do?

deadrubberboy commented 4 months ago

thinking it's related to the new instructions are Let's Encrypt? I'm installing that add on now. Didn't have before.

alexbelgium commented 4 months ago

Hi, sorry for all the versions there was many things to adapt to be able to use ssl while taking into account Homeassistant's and docker limitations... I think it is a permission issue, I encountered the same. The thing is that each time the addon is closed or restarted, all files not yet analyzed are copied in /data/Streamdata, then put back in the analysis queue when the addon is started again.

What I would propose to you : enable the web terminal from the Tools/Service tab, then go to the Web terminal, login with the user "pi" and the password that you put in the addon options, and type : chown -R pi:pi /tmp/StreamData && chmod -R 777 /tmp/StreamData && echo "done"

alexbelgium commented 4 months ago

thinking it's related to the new instructions are Let's Encrypt? I'm installing that add on now. Didn't have before.

There is 2 mutually exclusive ways to achieve ssl :

alexbelgium commented 4 months ago

Btw (sorry for the multiposts) ; in theory a script exists that checks the content of StreamData. when there is more than 100 files ; it will restart services and redo permissions to fix potential issues

The only failure I saw was when the disk is full ; it seems to analyse but actually don't save anything

deadrubberboy commented 4 months ago

Hi, sorry for all the versions there was many things to adapt to be able to use ssl while taking into account Homeassistant's and docker limitations... I think it is a permission issue, I encountered the same. The thing is that each time the addon is closed or restarted, all files not yet analyzed are copied in /data/Streamdata, then put back in the analysis queue when the addon is started again.

What I would propose to you : enable the web terminal from the Tools/Service tab, then go to the Web terminal, login with the user "pi" and the password that you put in the addon options, and type : chown -R pi:pi /tmp/StreamData && chmod -R 777 /tmp/StreamData && echo "done"

Thanks for the quick reply! Did this (had to add sudo to front of that command - got error otherwise). Seems to have fixed it! Will I need to run that whenever there is an update?

Do I need to enable SSL? What are the risks if I don't? I run HA in a VM on an always on MacMini. It has its own (internal/local) IP address. I don't need to access the web interface of Bridnet-Pi outside of home. If I do, I can always do it in the HA app via iPhone/Mac via the Nubocasa link. I pay for the remote access to support them, but rarely use it.

alexbelgium commented 4 months ago

I've added this permissions fix in the startup script ; it won't happen again :) that's the good thing about debugging like that on github, once I'm aware I try to find a solution that should avoid the issue for other users or in the future :-)

For ssl it's only recommended if you use it externally... I've put so much effort on it because my domain forces me to use https and it was bugging me not to be able to use it :-)

deadrubberboy commented 4 months ago

Thanks again!

deadrubberboy commented 3 months ago

Hello again! Got this after today's update. Stopped detecting:

CleanShot 2024-06-04 at 16 07 08@2x

deadrubberboy commented 3 months ago

Bigger section from "your log":

CleanShot 2024-06-04 at 16 14 14@2x

alexbelgium commented 3 months ago

Thanks! Argh I'm sorry. Please try adding PROCESSED_SIZE=0 to your birdnet.conf. I'll revert the change to avoid issue for other users

deadrubberboy commented 3 months ago

Happy to help!

And thanks! That (PROCESSED_SIZE=0) seems to have solved it!

*no apology needed! Appreciate your efforts

deadrubberboy commented 3 months ago

Just sent a coffee your way 😉

alexbelgium commented 3 months ago

Thanks very much! I tried to readd the Processed folders to be able to retrieve wav file for analysis if we are not happy about detections but it seems something messed out as it doesn'r automatically add the value to the birdnet.conf... And this value is costumizable from the settings page :)

But seeing your issue i'll revert so other people don't lose detections

knobunc commented 3 months ago

Something weird happens with the timezone. It's set correctly in /etc/timezone and $TZ. But /home/pi/BirdNET-Pi/scripts/common.phpuses timedatectl and that fails...:

# timedatectl show --value --property=Timezone
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

And I have tried setting the timezone in several different areas, but it ends up as UTC rather than America/New_York

knobunc commented 3 months ago

Also, the live audio stream service doesn't correctly start automatically... I have to go and restart it after the container boots and then it is fine.

alexbelgium commented 3 months ago

Thanks! Audio stream not starting automatically is actually the normal feature, as it is not enabled in Birdnet-Pi startup sequence that I saw online... I could indeed add it. I think by default it is disabled to reduce resources usage. Terminal is also inactive by default, more likely for security reasons.

For the time, is it a real issue (= time not correct for observations) or a UI issue (= time not correct in the settings)? On my pi the detections are right but not the settings. I had not thought about it but thanks very much for finding the cause, I'll find a way to get time another way!

alexbelgium commented 3 months ago

Something weird happens with the timezone. It's set correctly in /etc/timezone and $TZ. But /home/pi/BirdNET-Pi/scripts/common.phpuses timedatectl and that fails...:

# timedatectl show --value --property=Timezone
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

And I have tried setting the timezone in several different areas, but it ends up as UTC rather than America/New_York

Both your points will be corrected in the next build