theyosh / TerrariumPI

Home automated terrarium/aquarium or other enclosed environment with a Raspberry Pi
https://terrarium.theyosh.nl
GNU General Public License v3.0
408 stars 98 forks source link

Webcam stream (as option) #223

Closed Swiftnesses closed 5 years ago

Swiftnesses commented 5 years ago

Hey @theyosh,

Loving this controller, mega work my friend - thank you.

I'm currently using MJPG Streamer (available here on Github) to stream my Duck COOP webcam, rather than use static images. On my Pi 3 (A+ with only 512MB RAM), I can stream and use the controller while only using around 15% CPU (which is amazing tbh!). I doubt this is even an effective method of streaming - likely modern browsers support much better alternatives (H264/265?).

I'd love to have the stream inside Terrarium Pi rather than running via another application. Could you please add streaming as an option, given the low CPU utilisation, it seems a real possibility which would hugely improve the options available to people wanting live updates (I need them, as there's a small chance a Duck could get caught in the door, sure this applies to reptiles too?).

Many thanks,

Mark

Swiftnesses commented 5 years ago

Saving a RAW displays this, so does the webcam settings page?

Not sure archive is working, I click it and nothing happens?

screenshot 2018-12-08 at 16 14 52

Error in console: 2018-12-08 16:34:58,101 - ERROR - terrariumWebcam - Raw image 'Coop Interior' at location rpicam_live is not available!

Swiftnesses commented 5 years ago

BTW, seems my delay is about 20 seconds :-/

theyosh commented 5 years ago

Unless you can reduce the lag, we can call it a success!

I have 2 cameras that offer static jpg, I'm hoping to add them to my duck run in various places, remote is supported right @theyosh ?

Static jpg is supported. Just enter the full url as address

theyosh commented 5 years ago

Saving a RAW displays this, so does the webcam settings page?

Not sure archive is working, I click it and nothing happens?

screenshot 2018-12-08 at 16 14 52

Error in console: 2018-12-08 16:34:58,101 - ERROR - terrariumWebcam - Raw image 'Coop Interior' at location rpicam_live is not available!

This happens in the first 30 seconds after startup. After 1 minute full running, it should show the right image. This is due to the use of the internal webserver, which will be started as latest. Therefore, the first attempt to get a image of the webcam fails and show an offline message. This will disappear in about 30-60 seconds after startup

theyosh commented 5 years ago

Also, I noticed there's a nice time overlay on iOS (but not on desktop), will you be adding archiving and overlays back?

iOS has it's own native players. So they can do more stuff. For now, the desktop is as is....

Swiftnesses commented 5 years ago

Happens to me all the time. I never get an image here, nor can I seem to access the archive, albeit perhaps there isn’t one if it isn’t working right...

Sent from my iPhone

On 9 Dec 2018, at 11:21, TheYOSH notifications@github.com wrote:

Saving a RAW displays this, so does the webcam settings page?

Not sure archive is working, I click it and nothing happens?

Error in console: 2018-12-08 16:34:58,101 - ERROR - terrariumWebcam - Raw image 'Coop Interior' at location rpicam_live is not available!

This happens in the first 30 seconds after startup. After 1 minute full running, it should show the right image. This is due to the use of the internal webserver, which will be started as latest. Therefore, the first attempt to get a image of the webcam fails and show an offline message. This will disappear in about 30-60 seconds after startup

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Swiftnesses commented 5 years ago

@theyosh I have 4 cameras in my garden which output:

H264 Streams: Path to feed : rtsp://192.168.1.220:8554/unicast HLS : http://192.168.1.220:8554/unicast.m3u8 MPEG-DASH : http://192.168.1.220:8554/unicast.mpd

Is it possible to feed these in as a webcam?

kaju666 commented 5 years ago

Ok, found the issue... it is getting late so stupid errors... Anyway, resolutions and rotations should work now

Updated today to 3.9.1 and in rpicam_live rotation not work for me.

theyosh commented 5 years ago

Hi, I am currently a bit bussy with some code refactoring. So not sure how fast I can fix stuff right now.

If the camera was already running, then a restart is needed to get the rotation working. Else I do not have an idea why.

For remote cams, I do have a solution for: HLS : http://192.168.1.220:8554/unicast.m3u8 So that will be added in the next release

Swiftnesses commented 5 years ago

@theyosh You're a bloody legend my friend, thank you! @kaju666 Works great here, if I remember I had to restart as @theyosh said.

Things are working perfect, apart from my DHT22 which seems to have stopped reporting readings. I assume it's died.

Swiftnesses commented 5 years ago

@theyosh Any idea when the next release is planned (even for testing...)...

kaju666 commented 5 years ago

unfortunatly not for me. Only rpicam works and can be turned 90 degrees. When i use rpicam_live it does not want to rotate even after restarts or readding camera.

theyosh commented 5 years ago

@kaju666 That is correct and a bug. In the development version I have it working. Will get in the next release.

@Swiftnesses if you want to test: checkout the development branch. Keep in mind, that this is an upgrade, and needs the installer to be re-run. And not sure if everything will work at once. Also, there will be some sensor data rewritten. And therefore, you can not go back to the master if something is failing... So keep a local copy of the TerrariumPI folder before trying

Swiftnesses commented 5 years ago

@theyosh I'm on it... wish me luck ;-)

Swiftnesses commented 5 years ago

@theyosh Up and running will configure now and test (btw you have some default wemo plugs in switches), any idea when you'll try and take a first shot at HLS?

EDIT: They are my Wemo's, I'm dumb. Can I avoid them being added?

theyosh commented 5 years ago

@Swiftnesses HLS is already working... maybe clear browser cache?

theyosh commented 5 years ago

Else just add the full HLS url as source for the webcam. Other settings like resolution will be ignored

Swiftnesses commented 5 years ago

No luck with HLS, even tried this test stream:

http://www.streambox.fr/playlists/test_001/stream.m3u8

The error is HLS:4

Edit: restarted and it's working, super!

Swiftnesses commented 5 years ago

It seems to stop after some time with errors like:

2018-12-17 19:50:47,451 - WARNING - terrariumEngine - Webcam update(s) took to much time. Needed 38.20912 seconds which is 8.20912 more then the limit 30

The link above is a good test...

Edit: Holy s*** the archive has taken 32GB, couldn't even restart the app, connected via SSH and wiped the webcam folders on both my stable and dev release!

Swiftnesses commented 5 years ago

Streaming seems to fill the SD card ultra fast, even with archive etc off the webcam folder fills FAST...

Also seems to save about 8 seconds of the stream and then stop, retrying just plays the same clip over and over again...

Swiftnesses commented 5 years ago

I guess you're using clappr, I tried adding a RTSP link of one of my Ubiquiti cameras for fun hoping it also worked, locked out, luckily I wiped it from the settings.cfg and it allowed me back in :-D

theyosh commented 5 years ago

It is not made to stream multibitrate FULLHD TV channels. Use proper source like a webcam at 1Mpbs.

Without actually errors, I can't help... so development branch is at own risk...

theyosh commented 5 years ago

RTSP is NOT supported

Swiftnesses commented 5 years ago

Come on, who doesn't want to watch Full HD movies while watching our pets? 👍

Joking aside, it seems to be working okay, the only issue is the flakey feed from the camera I put inside the duck coop, will need to rethink the placement.

theyosh commented 5 years ago

@Swiftnesses Is the new development version working well for you? If so, we are close to a new release.

Swiftnesses commented 5 years ago

Hey @theyosh... development branch seems to be working for me, setup and working fine (or at least as far as I can see!).

Swiftnesses commented 5 years ago

BTW, I'm using the websockets to update my smart home and trigger actions - it's now all fully automated!

Swiftnesses commented 5 years ago

As a note, it would be nice long term if you can add some webcam controls, I struggle a little with contrast during the night, manually adjusting this offers improvements but it would be good from the UI. I use DRC and adjust the white balance normally...

Swiftnesses commented 5 years ago

@theyosh the only bug I found is trying to save a RAW photo and view it gives me a 404.

ghost commented 5 years ago

BTW, I'm using the websockets to update my smart home and trigger actions - it's now all fully automated!

Would you be willing to explain to me how you set up web sockets? I am so lost.

theyosh commented 5 years ago

Euh, I would like to close this issue. So maybe you should exchange email addresses somehow? So you can discuss the websockets option?

theyosh commented 5 years ago

For now, I am closing this issue, as live streaming is now possible.