pendente
Posts: 5
Joined: Sat Aug 17, 2019 2:06 am

Re: RPi Cam Web Interface

Sat Oct 12, 2019 11:57 pm

ras07 wrote:
Fri Oct 11, 2019 5:36 am
pendente wrote:
Thu Oct 10, 2019 12:06 pm
ras07 wrote:
Thu Oct 10, 2019 1:03 am
I'd recommend starting off with shell scripts rather than Python. If you are using the built-in motion capture system, you can then use the end_box macro (in the System settings) to do whatever post-processing you want. See https://elinux.org/RPi-Cam-Web-Interface#Job_Macros for more details.
Thank you for the answer.

What i'm trying do is:
I want to send a telegrama command /film that execute this script to make a small filme, copy the file to a new and regular name that i can in the next phase send it to me.r
You should be able to do that in one line in macros/end_box.sh:

Code: Select all

cp $1 /var/www/html/video.mp4
Thanks a lot! It did help and it works!

By the way about the Pipe, when i sendo the command ca 1, next i should put the time in seconds bit i didn't still get it to work.

Should be something like

Code: Select all

ca 1 t 15
?

Or

Code: Select all

ca 1 15
?

hknight
Posts: 7
Joined: Sun Jun 23, 2019 5:01 pm

RPi Cam Web Interface: Embedding the preview mjpeg stream in HTML page

Sun Oct 13, 2019 8:25 am

Hi Forum,
I am trying to embedd the mjpeg stream from the live preview in a webpage hosted locally on a raspberry-pi (call it pi#1). The RPCWI software is running on a separate pi (call it pi#2). I also have UV4L running on a third pi (call it pi#3). The HTML code I tried was as follows...

Code: Select all

<img style="-webkit-user-select: none;" src="http://192.168.1.190:8081/cam_pic_new.php">
This shows the embedded video from pi#2 live streaming in the webpage hosted by pi#1 over my LAN to multiple devices
However, if I try....

Code: Select all

	<img style="-webkit-user-select: none;" src="http://rydepier.com:8081/cam_pic_new.php">
so that I can see the stream on devices outside my LAN no video is displayed.

This works for a stream from pi#3 running UV4L.....

Code: Select all

<img style="-webkit-user-select: none;" src="http://rydepier.com:8080/stream/mjpeg">
I have opened port 8081 for pi#2 running RPCWI and configured RPCWI to use this. This is functioning correctly, hence I can see the stream locally.
Both pi#1 and pi#2 are running Apache2
The domain name for my webpages is 'rydepier.com' and pi#1 is running HTTPS securely.

I am a senior tinkerer with this but trying to learn so please forgive any simple mistakes I have made.
Any advice on this set-up is greatly appreciated.
Heath.

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Mon Oct 14, 2019 12:23 am

pendente wrote:
Sat Oct 12, 2019 11:57 pm
ras07 wrote:
Fri Oct 11, 2019 5:36 am
pendente wrote:
Thu Oct 10, 2019 12:06 pm

Thanks a lot! It did help and it works!

By the way about the Pipe, when i sendo the command ca 1, next i should put the time in seconds bit i didn't still get it to work.

Should be something like

Code: Select all

ca 1 t 15
?

Or

Code: Select all

ca 1 15
?
The second. (It doesn't need the t character.) If you leave that value out (i.e. if you just issue ca 1) the capture will run indefinitely until you explicitly turn if off with ca 0 (or with the web UI).

btw, there seems to be a bug when if you have the Video Split parameter set to a non-zero value and manually execute the capture command with a time increment (e.g., ca 1 15). It captures the 15 seconds, but then it restarts the capture and runs forever until you manually stop it. So for now, make sure Video Split is set to zero.

One more thing: I've found it more reliable to write to FIFO11 rather than FIFO. FIFO is the queue the system uses, so if you happen to write to it exactly when the scheduler is issuing a command, it can get confused. (FIFO11 does the same thing as FIFO, but is specifically for user commands so it doesn't conflict with system commands.) (Don't write to FIFO1 - this is read by the scheduler.)

Lastly, I've manually added enforce_lf 1 to my uconfig file. This keeps the system from trying to process a partial FIFO command. This solved a lot of timing issues for me, particularly when using a Pi Zero. (It does mean that you MUST add a linefeed to any FIFO command.)

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface: Embedding the preview mjpeg stream in HTML page

Mon Oct 14, 2019 3:03 am

hknight wrote:
Sun Oct 13, 2019 8:25 am
Hi Forum,
I am trying to embedd the mjpeg stream from the live preview in a webpage hosted locally on a raspberry-pi (call it pi#1). The RPCWI software is running on a separate pi (call it pi#2).
...
However, if I try....

Code: Select all

	<img style="-webkit-user-select: none;" src="http://rydepier.com:8081/cam_pic_new.php">
so that I can see the stream on devices outside my LAN no video is displayed.
...
I have opened port 8081 for pi#2 running RPCWI and configured RPCWI to use this. This is functioning correctly, hence I can see the stream locally.
I just tried this on my system and it worked ... perhaps you have something misconfigured with your router's forwarding of port 8081?

Let me caution you to be careful with exposing RPiCWI to the internet! It's really not designed to be secure (you can add a username and password but that defeats the purpose of displaying the live preview page on an external web site). With a port exposed externally it would be pretty trivial for an attacker to make RPiWCI execute arbitrary commands and thus completely take over your Pi (and thereby establish a beachhead behind your firewall, from which to attack all your other computers/devices).

There is a simple live-preview only page that you can use for this (see https://elinux.org/RPi-Cam-Web-Interfac ... _only_page), but you then need to reconfigure Apache to allow only this page externally (and then harden your Apache install). I can write that up if desired.

The other factor is that it can use a LOT of bandwidth. It will likely bog down if more than a couple users are viewing the preview at the same time, and if your Internet provider has a data cap, you can blow through that in a hurry.

If you get things worked out with your router and still want to make the stream accessible externally, I'll write up how to do it in a safe(r) fashion.

antimatter
Posts: 1
Joined: Mon Oct 14, 2019 12:52 pm

Re: RPi Cam Web Interface

Mon Oct 14, 2019 12:58 pm

Hi,

I would like to autostart video recording at boot (without motion detection). Is there a setting to enable recording at boot?

Thanks.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface ISO--setting

Mon Oct 14, 2019 2:38 pm

Hello...... in my project, the ISO value must change during the day and night to avoid glare or darkness, despite an infrared lamp. So here's the sketch. But I don't know how and what to indicate the values in the empty fields, because like this, it doesn't work. Thank you for your help.

Image

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Mon Oct 14, 2019 7:21 pm

antimatter wrote:
Mon Oct 14, 2019 12:58 pm
I would like to autostart video recording at boot (without motion detection). Is there a setting to enable recording at boot?
Several ways to do this. You can go into Camera Settings and set Video Split to something reasonable (in general I'd recommend no more than 900 unless you lower the resolution and/or framerate). 900 will break your recordings up into 15-minute chunks. Then go into Edit Schedule Settings and make sure Daymode is set to All Day. In the scheduler, clear the boxes under Motion Start and Motion Stop, and set Period Start to ca 1. Click Save Settings and then reboot.
Annotation 2019-10-14 130801.png
Annotation 2019-10-14 130801.png (14.42 KiB) Viewed 357 times
Probably a better way is to use the AutoCapture feature (AutoCapture_Interval and Max_Capture settings in Edit Schedule Settings). I haven't played with this, but you should just be able to set AutoCapture_Interval to whatever you want (within reason, as above) and then set Max_Capture to a second or two less.

Regardless of how you enable this, it's going to generate many gigabytes of video per hour at full HD. If you don't have a plan for managing that much data you can lower the resolution and/or framerate (for many applications a framerate of 1 or 2 fps may be adequate), or you can see whether the timelapse feature works for your use case.

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface ISO--setting

Mon Oct 14, 2019 7:42 pm

CharlyDelta wrote:
Mon Oct 14, 2019 2:38 pm
Hello...... in my project, the ISO value must change during the day and night to avoid glare or darkness, despite an infrared lamp. So here's the sketch. But I don't know how and what to indicate the values in the empty fields, because like this, it doesn't work. Thank you for your help.
Can you describe more about what you want to do? Right now you have it set to change the ISO when motion starts, but not to do anything else (start capturing video, for instance). I doubt this is what you want, but I'm not sure exactly what you're trying to accomplish. Do you want to record video when motion is detected? Do you want to always have motion detection on, or on only during certain time periods?

EDIT: if you aren't using motion detection at all (i.e., you want to use the scheduler to change camera settings but then you have some other manual/external way of starting the video recording) you just need to move your ISO commands to the Period Start column and leave the Motion Start and Motion Stop columns empty. But if that's not your intent, please explain your use case a little further.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface

Mon Oct 14, 2019 8:45 pm

Thank you for your answer ras07.

The purpose of the project is not to capture videos but simply to monitor the henhouse. During the day, the image is saturated and at night, despite an infrared lamp, the image is too dark. So ISO must be low by day and high by night. Unless there is another way, such as changing the brightness? But even then, how to set it up....

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Mon Oct 14, 2019 9:41 pm

CharlyDelta wrote:
Mon Oct 14, 2019 8:45 pm
Thank you for your answer ras07.

The purpose of the project is not to capture videos but simply to monitor the henhouse. During the day, the image is saturated and at night, despite an infrared lamp, the image is too dark. So ISO must be low by day and high by night. Unless there is another way, such as changing the brightness? But even then, how to set it up....
So if you're never recording video at all, the solution above under EDIT should work for you (moving your settings to the Period Start column). That will change the ISO settings at the start of each schedule period.

You can also look at the Exposure Mode setting, although at least with my camera, that never seems to do that much. Maybe Brightness and Contrast as well.

hknight
Posts: 7
Joined: Sun Jun 23, 2019 5:01 pm

Re: RPi Cam Web Interface

Thu Oct 17, 2019 7:02 am

Hi Raz,
Thanks very much for responding.
Very interesting to read all the insight you have into the streaming side, as a typical newbie I would just have blundered into security issues.
With regards bandwith for streaming, when it was working I could get reliable stream of ~8fps and quality set to 30% on multiple platforms (windows, mac, android) at the same time over my LAN. This seems better than the Motion or UV4L alternatives. Am I going down completely the wrong road using thes types of software to embed a live video stream in a wordpress page? (The wordpress is being hosted locally on a Pi4).

One other thing that I like about RCWI is the auto picture level applied giving a really good image from a zero cam from day to night. Does the software have some base level image processing working before mjpeg conversion?

You mentioned that my port settings may be incorrect but I only have very limited options to control port forwarding
2019-10-17_07-13-49.jpg
2019-10-17_07-13-49.jpg (153.75 KiB) Viewed 191 times
So I am not really sure what can be changed.

Again apologies for asking newbie questions, and if there are suggestions for a better way to stream to the wordpress page, but preferably without going through a third party web service, I would be very greatful.
I will try bumbling around a bit more with the router (I fiddled with the firewall level and set it to lax) to see if I can get this to work.

I can see the min.php page (suggested in your link) on the LAN okay but cannot open this on the WAN.

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Thu Oct 17, 2019 5:36 pm

hknight wrote:
Thu Oct 17, 2019 7:02 am
With regards bandwith for streaming, when it was working I could get reliable stream of ~8fps and quality set to 30% on multiple platforms (windows, mac, android) at the same time over my LAN. This seems better than the Motion or UV4L alternatives. Am I going down completely the wrong road using thes types of software to embed a live video stream in a wordpress page?
I'm no expert on video, but I don't think what you're trying to do is unreasonable. I'd actually like to something similar myself. Ideally, I'd like to have a hi-res/hi-framerate stream for viewers within my LAN, and then convert that to a lower-res/lower-framerate stream that I push to the outside world. I haven't found a good way to do this yet (haven't tried very hard yet either though).
One other thing that I like about RCWI is the auto picture level applied giving a really good image from a zero cam from day to night. Does the software have some base level image processing working before mjpeg conversion?
I don't really know, honestly. I don't know much about what goes on on the back end.
You mentioned that my port settings may be incorrect but I only have very limited options to control port forwarding
Interesting; it looks like it should be working to me. Do you have ufw or some other firewall running on your Pi(s)? (By default it's not enabled on Raspian, so you wouldn't unless you added it yourself.)
Again apologies for asking newbie questions, and if there are suggestions for a better way to stream to the wordpress page, but preferably without going through a third party web service, I would be very greatful.
No worries! It's how we all learn. I may borrow some ideas from you for my own setup ;-)

What kind of router do you have?

ras

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface: Embedding the preview mjpeg stream in HTML page

Thu Oct 17, 2019 6:15 pm

hknight wrote:
Sun Oct 13, 2019 8:25 am

Code: Select all

<img style="-webkit-user-select: none;" src="http://192.168.1.190:8081/cam_pic_new.php">
This shows the embedded video from pi#2 live streaming in the webpage hosted by pi#1 over my LAN to multiple devices
However, if I try....

Code: Select all

	<img style="-webkit-user-select: none;" src="http://rydepier.com:8081/cam_pic_new.php">
so that I can see the stream on devices outside my LAN no video is displayed.
Aha. I took a look at your site myself, and I think you have a redirection problem going on in Apache. When I try to look at _http://rydepier.com:8081, it redirects to HTTPS. Since port 443 is forwarded to a different IP (.135) that's where it's ending up.

The reason it works behind your firewall is due to the way Apache handles HTTP headers and virtual hosts. When Apache sees a request for "http://192.168.1.190[...]" it redirects to "https://192.168.1.190", and everything's fine. But when the same Apache instance sees that the request came to "http://rydepier.com[...]" it's redirecting to "https://rydepier.com", which your router then sends to the wrong Pi.

Check your Apache config on your Pi Zero and see if you have either a Redirect statement or a RewriteRule statement that is forcing to HTTPS. If so, probably the easiest way to fix it is to use a different port for HTTPS on the Pi Zero (port 444, for example), change your Apache config accordingly, and then forward this port to the Zero with your router.

hknight
Posts: 7
Joined: Sun Jun 23, 2019 5:01 pm

Re: RPi Cam Web Interface

Sat Oct 19, 2019 12:59 am

Hi ras,
Check your Apache config on your Pi Zero and see if you have either a Redirect statement or a RewriteRule statement that is forcing to HTTPS. If so, probably the easiest way to fix it is to use a different port for HTTPS on the Pi Zero (port 444, for example), change your Apache config accordingly, and then forward this port to the Zero with your router.
Looks like I will need to do a bit of web learning to understand this then I can 'tinker under the hood' of the Apache set-up.
The reason it works behind your firewall is due to the way Apache handles HTTP headers and virtual hosts. When Apache sees a request for "http://192.168.1.190[...]" it redirects to "https://192.168.1.190", and everything's fine. But when the same Apache instance sees that the request came to "http://rydepier.com[...]" it's redirecting to "https://rydepier.com", which your router then sends to the wrong Pi.
Ooops, I forgot to mention there is a PoE switch powering the Pi with the camera attached (it is a Pi4 with the zero-cam cable adapter) and of course being a newbie I just plugged it in without understanding it could be bridged (I was told about this by my internet provider while reporting a problem on getting devices to connect to my LAN). So that may be causing the issue, I will check it's settings or remove it from the mix and power the Pis from reliable DC supplies.

Maybe this is a trivial suggestion fo your desire to have two stream qualities.... is it not possible to have the high quality stream fed into VLC to reduce it down and then re-stream it?
Thanks for your help ras.
Heath.

Csk983
Posts: 1
Joined: Sun Sep 06, 2015 10:15 am

Re: RPi Cam Web Interface - Configuration Options

Tue Oct 22, 2019 5:03 pm

Hi

I've just installed the latest version of Cam Web Interface on an RPi zero, which I've done many times before, on a clean install of Buster. After ./install.sh it appears that the settings in the Configuration Options file are not saving. any clues?

Return to “Camera board”