-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOW-TO] high resolution streaming with raspberry pi 4B + arducam 64MP (imx477) #1181
Comments
Hi, I think I've already answered this question on the forum. My advice was to avoid the "lores" image because you have to have a "main" image, so you may as well just use that. Also reduce the Although If it still isn't working, please post a short but self-contained code snippet - configuring and starting the recording should be less than a dozen lines, I would think. |
Hi, thanks for reply! I still haven't solved the problem. I wasn't able to make main stream work with MJPEG encoder. here is a code snipped: from picamera2 import Picamera2 class StreamingOutput(io.BufferedIOBase): camera = Picamera2() streamOut = StreamingOutput() camera.start() |
Hi, you don't say in what way it doesn't work. I would start with the absolute simplest example possible, such as
Does that recording anything? If not, in what way does it fail? |
Just tried and this is the output. [1:17:07.323424285] [1312] INFO Camera camera_manager.cpp:325 libcamera v0.3.2+124-e0a2304e-dirty (2024-12-09T06:48:46GMT) the file test.mjpeg is saved but is empty |
I wonder if the image size is too large for the hardware MJPEG encoder on the Pi 4. Can you try size (1280, 720) instead? |
Unfortunately you are right! Up to 2312x1736 I'm not getting the error. A resolution of 3840x2160 seams to be too large. |
rpicam-vid (aka. libcamera-vid) doesn't use the h/w MJPEG encoder, it does software encode. In theory, you can force the use of software encode in Python as well. Replace |
yes I can confirm and it's the reason I was trying to use the MJPEGencoder with resolution of 3840x2160: using jpegencoder with RGB888 format reduces a lot the performance and is not possible to use YUV420 format. |
I suppose it all depends on exactly what you want to do. Is there something missing from rpicam-vid that you need? Slightly longer term, I have submitted patches upstream to allow software JPEG encode of YUV420, which will allow the Python performance to improve to be much closer to rpicam-vid, but it may take some time to get that accepted. |
the only missed think from rpicam-vid is that is less easy to be integrated with my python workflow and alsp, when camera is closed, resources are not always correctly released resulting in errors when you try to start a new streaming or take a still acquisition. I hope these updates will be accepted soon! thank you for your help... |
I can't think of any reason for that. Obviously you have to run rpicam-vid as a separate process, so there might be timing issues when shutting it down, remembering that only one process can use the camera at a time. As always, if you can make a (short, simple!) test case then we can look at it.
Me too!! |
Hi,
I'm working on a raspberry pi 4B and I'm trying to perform a video streaming with a resolution equal to 3840x2160
My goal is basically to reach the same performance of the following libcamera command:
libcamera-vid --codec mjpeg --flush 1 -n -t 0 -k --inline --listen --quality 85 --width 3840 --height 2160 --framerate 20
but I need to do it through picamera2.
To reach this goal, ideally I need to have just the "lores" stream but I'm not able to find a way to deactivate the "main" stream.
Indeed, keeping active both streams is not possible if we need an high resolution because of memory issues due to the fact that if "lores" stream resolution is set to 3840x2160, "main" stream resolution must be higher or the following error will be raised:
" File "/usr/local/lib/python3.11/dist-packages/picamera2/picamera2.py", line 830, in check_camera_config
raise RuntimeError("lores stream dimensions may not exceed main stream")
RuntimeError: lores stream dimensions may not exceed main stream "
I already set cma memory to 512 in the config.txt but memory is still not enough.
I hope someone have some suggestion to deactivate "main" stream and keep just "lores" which seams to be faster.
(to delete main stream, It seams not enough to define just "lores" stream in the configuration like in the following command: create_video_configuration(lores={"size": (3840, 2160), "format": "YUV420"}, encode="lores"))
I also tried to define main stream with same configuration of the example above:
however, the use of "yuv420" format and MJPEGencoder on "main" stream raises the following error:
File "/usr/local/lib/python3.11/dist-packages/picamera2/encoders/v4l2_encoder.py", line 149, in _start
fcntl.ioctl(self.vd, VIDIOC_STREAMON, typev)
ProcessLookupError: [Errno 3] No such process
If you have any suggestion let me know.
thank you in advance for your help.
The text was updated successfully, but these errors were encountered: