Closed jesternberg closed 2 weeks ago
Is it correct to have two versions of the service running on different ports to be able to use the multicam plugin? or is there a better solution.
Probably, for now you would need duplicate installations of raspi-cam-srv. A better solution would be, of course, to allow for an additional streaming endpoint for the second camera.
I could think of a page in raspiCamSrv showing live streams of both cameras simultaneously. Then, you could use both endpoints for streaming.
I am currently refactoring in order to support an uninterrupted live stream while taking pictures or videos.
This would also be a precondition for a snapshot endpoint.
This will take a little bit. Therefore, I do not currently know when I will get to new features.
since snapshots are not currently exported
The best solution would be to provide endpoints for snapshots for both cameras.
I'll put that on the list.
The endpoint for photo snapshots for the active camera is now available in V2.1 See Web Cam Settings
Endpoints for the second camera will follow later
Is it correct to have two versions of the service running on different ports to be able to use the multicam plugin? or is there a better solution.
With version V2.3.0 one server instance supports streaming for both cameras sumultaneously.
Problem viewing live stream if any changes are made on another screen. Live feed stops and can't be viewed unless program is stopped and restarted. On Terminal only message is "WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise." Any ideas why the live feed stops and can't be restarted? Also the service configuration change doesn't work after installation. Change shows user name, but closing an SSH session stops the feed. Using Rpi 4 with latest 64 Bookworm, official Camera module 3. Viewing on Macbook Pro using Firefox. Same problem on Safari and Chrome.
On Terminal only message is "WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise."
This is a warning which is not related to the issue that the live stream does not show.
This warning originates from the libcamera
library (one of the lowest levels in the stack used by Picamera2).
I also see it on some systems (Pi4, Pi Zero) but not on Pi5.
The warning shows up with instantiation of a camera object, even before the camera is configured or started.
In issue #102 for the libcamera project (https://github.com/raspberrypi/libcamera/issues/102) it is recommended to increase the log level for libcamera
to 3
In raspiCamSrv, this level is set to 2 by default (in __init__.py
, line 70).
If you do not want to see this warning, you can change the value from 2 to 3.
I prefer to leave it at 2 in order not to miss any warnings which might be relevant.
Problem viewing live stream if any changes are made on another screen.
Which changes did you make which caused the live stream to disappear?
Sometimes, a specific camera configuration (Sensor Mode, Stream Size or others) may lead to errors within Picamera2, for example in the decoder. Typically, there should be an exception thrown by the relevant program.
Did you see any error messages in addition to the warning which you have mentioned?
If you run raspiCamSrv as service, you would need to look into the journal.
I am working on a solution to make raspiCamSrv more robust against errors in these backgound processes.
Also the service configuration change doesn't work after installation.
Could you please specify what exactly you mean with 'service configuration change'?
Which of the Service Configuration procedures did you follow (with or without Audio Support)?
On the initial bootup, ipaddress:5000, live stream is shown, but only Photo, Raw, Video black control buttons. No Hide or Clr. At top right red stream icon is on. Take photo, nothing happens. Click on Raw or Video, same negative response. No errors thrown on Terminal. When browser refreshed, still no changes.
Stop running with Ctrl-C, then restart causes live stream to appear, with Hide and Clr controls, plus photo below and metadata. Red stream icon is on.
Move to Trigger settings to start motion detection, red movement icon is on, but any movement in front of camera is ignored. Can't take photo or video.
I'm using a 16Gb SSD card, is this too low and would a larger memory make a difference?
When I close a SSH session, the screen is lost with a can't connect message, so Raspicamsvr has closed down. I wanted to keep it running in the background without having to restart each time.
Added a few screenshots
live view config screenshot
I wanted to keep it running in the background without having to restart each time.
To keep the Flask server running independently from the SSH session, you need to configure it as service.
The description is under Service Configuration.
Did you have issues with this?
Thanks for the other info.
I could partly reproduce the issue with video taking and with motion detection.
Taking photo and raw photo worked.
However, I have a camera model 1 currently connected to the Pi4. Trying now with a model 3.
For independent running without audio, I followed the info to install as service. A check of this line sudo journalctl -e gave this response, appears to start then stop several times, before starting. I have rebooted. When the SSH session closes, so does Raspicamsrv and laptop browser shows no connection.
Please post the entire error description (flask)[3357]: ...
Do you need just this one line expanded, or the full 1000 lines!
Just two lines (flask)[xxxx] with the same number xxxx
I wonder if there is a permissions issue. Configuring service without audio shows these lines
nano ~/raspiCamSrv.service and sudo cp ~/raspiCamSrv.service /etc/systemd/system
In the first line it shows open a SSH session, but is this before moving to the repository and virtual environment?
I also deleted
I
If you don't mind, would you show the content of the service file:
cat /etc/systemd/system/raspiCamSrv.service
Here is mine (for user 'sn' which should be 'jules' in your case:
Here's what I get
Comparing mine to yours I can see
There are two more places where you need to replace <user>
with jules
I also couldn't expand the lines you asked for. Can't move right to see the text of the full line. Have repeated the process, but different higher line numbers appear, I'm guessing as it's a different session
Yes I can see the two errors now, but how to change them? Where are the two other locations found? Using a nano session as in your description, only one location is shown as needing changing.
Normally, when you have the file open in nano (remember to sudo when editing in /etc/systemd/system
), you just
Thanks for the help. Changed user name in the two extra places and I think that's done it! Closed SSH session and checked web browser which shows this
Now sudo journalctl -e gives this (last section as there are a lot of lines)
Is that what is expected....how does it compare with your response to sudo journalctl -e ?
You should see this:
In your screenshot, I do not see the service start.
Probably, you need to restart it:
sudo systemctl stop raspiCamSrv.service
sudo systemctl start raspiCamSrv.service
Here's what I can see on Terminal startup
The bottom line shows session opened, but it's not a smooth start, it stops and starts over first few seconds of startup, why not just one start?
here's my startup on Terminal
The bottom line just refers to your user session and not to the Flask server.
You need to look at the red error messages with [Flask]
They say that there is no file /home/jules/prg/raspi-cam-srv/.venv/bin/flask
This refers to the Flask executable.
You may check yourself:
cd ~/prg/raspi-cam-srv/.venv/bin
ls -al
If the output looks like
your setup is OK.
If you do not see flask
, you did not install Flask within the virtual environment as has been requested in step 9 of the RaspiCamSrv Installation.
You may check where Flask is installed:
Make sure that the virtual environment is deactivated. Then enter
which flask
You will see
Now, activate the virtual environment and repeat the which command:
If your output is still /usr/bin/flask
, then Flask is not installed where it should be.
Then you can repeat step 9 of the RaspiCamSrv Installation and everything should be fine.
here's my startup on Terminal
This does not tell you that you have started Flask from your virtual environment.
The system will find Flask also at /usr/bin
because this is in the Path.
The service script, however, expects that Flask is installed in your virtual environment.
after ls -al get this
seems to be missing 4 lines compared to yours. Followed the installation step by step.
fonttools pyftmerge pyftsubset ttx
are these missing lines responsible for my live view missing probs?
No
Please show again the content of the service file:
cat /etc/systemd/system/raspiCamSrv.service
The error message before also complained about the working directory.
Which flask responds correctly.
I'm still seeing
still seeing USER twice
Probably, you did not save the file or did not open with sudo:
sudo nano /etc/systemd/system/raspiCamSrv.service
Then make the changes
Then save with "^O" (<Ctrl + O>)
Hit
Then exit with "^X"
Then check again with
cat /etc/systemd/system/raspiCamSrv.service
In the meantime, I have committed some fixes which should cover most of the issues described earlier for Pi4 with Cam3.
The reason was that the encoder failed with higher resolutions.
Now, the resolutions for video are set to lower values for Pi4, similar as for Pi Zero.
To update:
cd ~/prg/raspi-cam-srv
git pull
Ok so redid the changes which had these results
after changes now I see
How do I change port 5000 which is now in use.....not sure why?
It seems that the raspiCamSrv service is now active. This will of course use port 5000.
Did you check with
sudo journalctl -e ?
Did you try to connect?
yes, it connects to port 5000 but i'd like it to be another port. Motion was running, but trying to stop it caused an error. The Stop button had no effect. 1000 lines of error code....here is the last part
The updated fixes seem to have changed something...the Hide and Clr buttons below the live window have returned, but onpressing Photo, no pic is taken.
The Hide and Ctrl buttons are only visible if a photo has been taken and shown in the lower area. See the user guide.
So, if you see it, you must have taken a photo.
If you want to use another port, you just change 5000 to the port you want to use in the service script or when you start the Flask server directly
Tried to change port 5000 which was apparently in use, not sure what else is using it.
So followed instructions, changing it to port 5001 in Flask and url address.
Which gave this on webpage
and a long error readout
I am using raspiCamSrv with RPI5 and 2 cameras. Is it correct to have two versions of the service running on different ports to be able to use the multicam plugin? or is there a better solution.
Also since snapshots are not currently exported you cannot configure the snapshot url in OP. I tried the following path, based on video_feed, but it is not quite right. Using mimetype='multipart/x-mixed-replace, I do see the snapshot directly in a browser. OP is expecting the mimetype to be image/jpeg but with that as the mimetype, both OP and browser do not error but image is not displayed. Any suggestions as to what is wrong?
diff --git a/raspiCamSrv/home.py b/raspiCamSrv/home.py index c0ccb85..f6cc62f 100644 --- a/raspiCamSrv/home.py +++ b/raspiCamSrv/home.py @@ -48,6 +48,23 @@ def video_feed(): return Response(gen(Camera()), mimetype='multipart/x-mixed-replace; boundary=frame')
+def gen2(camera):
logger.debug("In gen2")
l = len(frame)
logger.debug("Got frame of length %s", l)
+@bp.route("/snapshot") +# @login_required +def snapshot():
logger.debug("In snapshot")
mimetype='multipart/x-mixed-replace; boundary=frame')
@bp.route("/photos/")
@login_required
def displayImage(photo: str):