Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4909

Camera board • Re: FrameRate, FrameDurationLimits and Resolution HQCAM

$
0
0
Hello,

I'm building an interface for the raspberry pi hq cam with pyqt5 and picamera2.
I've made a menu with different settings including different resolutions (image ratio) and different framerates (24, 30, 60 and 120 fps) to record video in .h264 and .mp4.

Looking at the documentation, I confess I'm a little confused about the notion of framerate.
How do I configure it? Using

Code:

picam2.set_controls({"FrameRate": 30})
Or like this?

Code:

config = picam2.create_video_configuration(main, lores=lores, display='lores',controls={"FrameRate": 30}, transform=Transform(hflip=1, vflip=1))
You can do either.

If you set it as part of the configuration (your 2nd example), then whenever you reapply that configuration you will restore that framerate, even if you had changed it in the meantime.

The first from can be used after "configure()" but before "start()", in which case that framerate will be applied immediately when the camera starts, but will not be "associated" with the configuration in the way that we saw previously.

That first form can also be used after "start()", in which case it will take "a few frames" to take effect.
Or, as I've seen on some forums with FrameDurationsLimits

Code:

config = picam2.create_video_configuration(controls={"FrameDurationLimits": (33333, 33333)})
In this case, if 40000 corresponds to 25fps. What are the framedurationlimits for 24, 60 and 120 fps?
"FrameRate" is just a convenience for users so that they can enter framerates instead of frame times. 24fps = 1000000/24 = 41667 microseconds, so use 41667 for 24fps (and so on).
Is it possible to change the framerate when recording a .mp4 video with synchronized audio (usb microphone)? Or is it selected by default? And if it is chosen by default, what is its value?
Yes, you should be able to change the framerate on the fly while recording a video.
Another issue is framerate. I don't quite understand what maximum resolution is possible depending on the framerate chosen.
The maximum framerate depends on the camera driver, which in turn depends on the camera sensor, the CSI2 connection and so forth. The quickest way to find out the maximum framerate for each mode is to type

Code:

rpicam-hello --list-cameras
You can get the same information from "picam2.sensor_modes" (always ask for that field first before configuring the sensor, because it will reconfigure it repeatedly to find out all the information).
I have a rapsberry pi 5 8go, I record videos on an ssd. So harware isn't too much of a problem.
I'd like to record videos in 2028xheight (depending on the ratio chosen) with the best possible quality without loss of fps. But I read in the documentation that : The H264Encoder class implements an H.264 encoder using the Pi's in-built hardware, accessed through the V4L2 kernel
drivers, supporting up to 1080p30. The constructor accepts the following optional parameters:
Do I need to reduce the resolution to 1920 pixels?
At what framerate should I reduce the resolution?
The hardware encoder only exists on Pi 4s and earlier. On a Pi 5 the H264Encoder is aliased to the LibavH264Encoder, which uses software. So you should be able to go larger than 1920 if you want. Usually performance should be better than 1080p30, but it will depend on what else the CPU is doing. It's a straight trade-off between framerate and resolution here. More resolution, fewer frames and vice versa. You'll have to experiment for your own use cases.
In section 4.2.2.3. Raw streams and the Sensor Configuration
I read that for 120fps I can have a max resolution of (1332, 990)
For 50fps (2028, 1080).
So if I record in a 1.33 ratio, i.e. 2028x1524, I can't record in 50fps?
I think 2028x1524 is limited to 40fps (check "rpicam-hello --list-cameras"), so you absolutely can't get 50fps there. In practice, I don't think the software encoder would give you 40fps either, that's just too many pixels. rpicam-vid is a bit more efficient than Python because it avoids some Python-related overheads, but not massively so.

Statistics: Posted by therealdavidp — Tue Apr 02, 2024 1:15 pm



Viewing all articles
Browse latest Browse all 4909

Trending Articles