How to reach 120 fps with libcamera RPI4

Hi all,
I am using OV9281 with libcamera module on RPI4. What are the settings to reach 120fps (maximum according to OV9281 data sheet) now 30fps is the maximum I can get.

Thanks:)

You can specify via command line arguments:
libcamera-still -t 0 --framerate 120, it should be noted that the preview frame rate cannot reach 120fps.

Thanks for your reply Wang,

Yes with the preview window the max fps it says on the screen is close to 40fps.
With no preview window, how can I confirm that I’m at 120fps? Do I need an external program or can I do it through terminal?

Also, how can I save those images without causing frame rate delays? Do I have to create a program where I save frames to memory, wait 1 second, then save to a file?

EDIT:
Using libcamera-still -t 1000 --framerate 120 -n -v I got that the last Wiefinder frame is 114
Is this the correct way to measure that the FPS are right?

Best regards

Yes, this is the correct way.

Yes, your thinking is correct, writing to SD Card will slow down the overall speed, so you need to cache the frames first.

If you’re not processing the data on the raspberry pi, you can send it over the network, I’ve tested using mjpg to encode 720p and use gstreamer to push the video stream to other machines for processing.

Hello, thank you for your time.

I was testing 1280x800 at 120fps. In the OV9281 documentation it says that the max fps at 1280x800 is 60fps.

If I do: libcamera-still -t 1000 --framerate 120 --width 1280 --height 800 -n -v
The last frame Viewfinder is 114, but the console shows: The chosen Viewfinder size chosen is 640x400. Is this because it is forcing the resolution to hit 120fps?

Best regards

Viewfinder is the displayed resolution, not the original resolution (the ISP scales and crops the original resolution) it can be set.
You can check the log for similar information to confirm the original resolution:

[0:45:58.514784384] [13441] INFO RPI raspberrypi.cpp:624 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected mode: 2328x1748-pRAA

You can also specify the resolution of viewfinder in the command:

libcamera-still -t 0 --viewfinder-width 1280 --viewfinder-height 800

Checking the log with this command:

libcamera-still -t 1000 --framerate 1200 --width 1280 --height 800 -n -v

[0:49:21.797364107] [10111] INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/ov9281@60 - Selected sensor format: 640x400-Y10_1X10 - Selected unicam format: 640x400-Y10P

Specify the viewfinder resolution:

libcamera-still -t 1000 --framerate 1200 --width 1280 --height 800 --viewfinder-width 1280 --viewfinder-height 800 -n -v

[0:50:49.959938557] [10673] INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/ov9281@60 - Selected sensor format: 1280x800-Y10_1X10 - Selected unicam format: 1280x800-Y10P

Also, if I save an image, the resolution of the image is correct in both cases (1280x800), so it works for my solution.

Thank you

Glad to hear it worked for you :grinning:

Hi Wong,

I’m currently testing out the OV9281 for the first time as well and was wondering if you can expand on your response about caching the frames:

Yes, your thinking is correct, writing to SD Card will slow down the overall speed, so you need to cache the frames first.

If you’re not processing the data on the raspberry pi, you can send it over the network, I’ve tested using mjpg to encode 720p and use gstreamer to push the video stream to other machines for processing.

I’m interesting in using libcamera-raw as opposed to libcamera-still, and when I save the frames to a *.raw file the framerate drops from 114 to ~68 when I use the following on the command line:

libcamera-raw -t -1000 --framerate 120 --width 1280 --height 800 ---n -v -o test.raw

Is one able to cache the frames using an additional flag? I’ve been looking through the rpi camera documentation (Raspberry Pi Documentation - Camera) and haven’t found much success yet in capturing a higher frame-rate with the full resolution.

Thanks in advance!
John

EDIT:
Something I should note is that I’ve tried the --circular approach and it works in bringing up the frame-rate, but my application requires quick-starting the recording upon a trigger. Maybe there is a way to create the buffer/chache (if those can be used interchangeably) separately, prior to executing the command?

EDIT 2:
Additionally, --circular seems to disable the --segmented 1 option, thereby not separating the frames upon saving them. Is it possible to somehow output close to 120 fps to the SD card (for individual frame processing) as new frames are being captured? Or do you think I would need to write my own libcamera application for this? I am starting to think the latter may be the case…

If you don’t want to modify the application, you can store the frame data in ramdisk.

1 Like

@pabloquintans
Hi Pablo, I Recently got an IMX462 and I’m also having issues with frame drops, did you succeed in getting rid of them by caching the files, and if so, could you explain to me how you were able to do that? Thank you

Hello @EoghanGlosterDPEA, as @wong’s said it is important to note that achieving 120fps with a preview display is not possible. It is challenging to attain such high frame rates while simultaneously displaying a preview.

Additionally, if you intend to save frames, it is advisable to store them in RAM memory rather than attempting real-time saving.

Hi @wong and @pabloquintans , I have a raspberry pi zero and a camera module 3 . When I tried using the above command, I get about 13-14 viewfinder frames which is pretty low and I do not know why. I am looking to achieve about 90 frames per second here. I understand the rpi zero is curtailed by its ram but is there anything I can do to achieve about 90 fps here? Thanks