signag / raspi-cam-srv

Web Server for Raspi Camera Access
MIT License
57 stars 6 forks source link

Few questions (noob) #18

Open signag opened 4 months ago

signag commented 4 months ago

Discussed in https://github.com/signag/raspi-cam-srv/discussions/17

Originally posted by **tatterz91** May 26, 2024 2. It doesn't let my view the Live stream when I press record. It says Video settings are incompatable with Live Stream configuration. Why? 3. Seems like half the time I press Stop Record, it throws up a Internal Server Error "either the server is overloaded or there is an error in the application." Why? I'm using the Pi 4 B 8gb No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye 11.9 the standard camera module 3 version="V2.6.1"
signag commented 4 months ago

There seems to be a race condition or timing issue between different background threads.

Probably due to the lower performance of Pi 4 and Pi Zero compared to Pi 5 this leads to an error when taking videos on these systems.

I need to make this more robust and thread-safe.
Sorry

sandyol55 commented 4 months ago

In case it is useful I am seeing a similar problem. Pi4 4Gb with a third party camera (imx462, using the imx290 overlay) Live stream, photo stream and video stream all set to the same mode 0 1280x720 resolution.

Pressing the video button while on the live stream screen results in this message in the terminal on the raspicamsrv machine.

[2024-05-28 14:16:43,215] ERROR in camera_pi: Thread 547198333312: Camera._videoThread - Exception: 'NoneType' object has no attribute 'get'

Other features seem Ok with this third party camera. raspicamsrv picks up its mode and parameters correctly.

signag commented 4 months ago

Exception: 'NoneType' object has no attribute 'get'

This should now be fixed with version V2.6.2. See Release Notes

I have tested on a

  • Pi 4 with Bookworm (debian_version 12.4)
  • Pi Zero 2 W with Bullseye (debian version 11.9)

@tatterz91, @sandyol55, could you please confirm that this works on your system? Thank you.

signag commented 4 months ago

2. It doesn't let my view the Live stream when I press record. It says Video settings are incompatable with Live Stream configuration. Why?

I have changed the default configuration for Pi models lower than 5. See Release Notes

For these default settings, the Live Stream should now be shown while a video is being recorded.

signag commented 4 months ago

3. Seems like half the time I press Stop Record, it throws up a Internal Server Error "either the server is overloaded or there is an error in the application." Why?

@tatterz91, does this error still occur with V2.6.2 on your system?

sandyol55 commented 4 months ago

Exception: 'NoneType' object has no attribute 'get'

This should now be fixed with version V2.6.2. See Release Notes

I have tested on a

  • Pi 4 with Bookworm (debian_version 12.4)
  • Pi Zero 2 W with Bullseye (debian version 11.9)

@tatterz91, @sandyol55, could you please confirm that this works on your system? Thank you.

Cloned a fresh 2.6.2 version and tested the manual video record button followed by a manual stop, and it now functions without error. Many thanks for the continued development of raspi-cam-srv. Just to note that this was a different configuration, using a Pi3A+ with V2 IMX219 camera for this test.

tatterz91 commented 4 months ago
  1. Seems like half the time I press Stop Record, it throws up a Internal Server Error "either the server is overloaded or there is an error in the application." Why?

@tatterz91, does this error still occur with V2.6.2 on your system?

The aforementioned issues seem to be addressed on my end, so thank you for your very quick support on the matter!

I do have a few more issues though: Stream Preview on the Live Config is stuck to YUV420 and any attempts at changing and applying the settings reverts it right back to YUV420. Is this normal behavior?

I'm still struggling to get it to record while having the live preview at the same time. There's a few times I've managed to do it but the framerate was poor. Is it possible to record 1080p 30fps while having a Live Preview? In my limited understanding, I thought YUV didn't give the best frame rates but I can't change it on Live Config.

Theres also an error I get occasionally that kills the Live Preview and I can't get it back without rebooting the service entirely but I haven't been able to consistently reproduce it. Happens when messing with live config settings.

Another recommendation is to add a "Default" button or "Recommended" settings because noobs like me can screw stuff up and not know what to do to fix it back :) (not sure how many buffers is ideal for the configs for instance)

signag commented 4 months ago

I do have a few more issues though: Stream Preview on the Live Config is stuck to YUV420 and any attempts at changing and applying the settings reverts it right back to YUV420. Is this normal behavior?

See Picamera2 Manual ch. 4.2, p. 17, #5.
Also raspiCamSrv Release Notes for version 2.1.1.

If you need another format for the live view, you would need to configure the "main" Stream and then choose the desired format.

In order to have the live view parallel to other use cases using the "main" Stream, you would need to make sure that these are configured in the same way.

For Pi5, also the "lores" stream can have other formats.

signag commented 4 months ago

I'm still struggling to get it to record while having the live preview at the same time. There's a few times I've managed to do it but the framerate was poor. Is it possible to record 1080p 30fps while having a Live Preview? In my limited understanding, I thought YUV didn't give the best frame rates but I can't change it on Live Config.

As far as I understand Picamera2, the frame rate is determined by the Sensor Mode and not by the stream format.
Of course, the stream format for all three streams (main, raw, lores) can be different at the same frame rate.

Certainly, you will find more about this in the Picamera2 and libcamera documentation.

So, in order to get a specific frame rate, you would need to force the camera into a specific Sensor Mode.
As far as I know, it is mainly the raw Stream Size which will be responsible for that.
(I had noted my understanding here)

On Bullseye systems, because of a missing data structure, I cannot show the current Sensor Mode in the Info dialog as I do for Bookworm.
(Your Pi 4 would also run Bookworm).

signag commented 4 months ago

Theres also an error I get occasionally that kills the Live Preview and I can't get it back without rebooting the service entirely but I haven't been able to consistently reproduce it. Happens when messing with live config settings.

I am aware of that.
What I have seen so far, this seems to be mainly due to limitations on the Pi 4 and lower systems.
On Pi 5, I did not see these errors.

Probably, some of them might vanish if you are running Bookworm on your Pi 4 rather than Bullseye.

On Pi Zeros, my experience with recent Bookworm distributions was not so good. So, I went back to Bullseye on these systems.

In the Picamera2 Manual there are several restrictions documented for Pi4 and earlier systems.
Not all of these are systematically implemented in raspiCamSrv.

Also, it seems that not all of the Picamera2 bugfixes are merged back to Bullseye.

My recommendation would be starting with the default configuration and then increasing resolution step by step.
Probably, keeping buffer sizes at low values might help.

signag commented 4 months ago

Another recommendation is to add a "Default" button or "Recommended" settings because noobs like me can screw stuff up and not know what to do to fix it back :) (not sure how many buffers is ideal for the configs for instance)

For extreme cases, there is a "Reset Server" in the Settings dialog which will reset everything to default.