rollyng
Posts: 54
Joined: Sat Dec 10, 2016 4:08 pm
Location: Hong Kong SAR

libcamera-raw fails with 4K resolution

Wed Jun 16, 2021 9:38 am

Dear all,

I used to run raspiraw to capture 4K raw data with the HQCam on a Pi4B 8GB. Recently, I would like to try libcamera-raw and found that it fails with the similar configuration. Here is the output:

Code: Select all

./libcamera-raw -t 100 --width=4056 --height=3040 --shutter=100 --segment 1 -o /mnt/ramdisk/4k_%03d.raw
WARNING: consider inline headers with 'pause'/split/segment/circular
[0:21:32.873722322] [2637]  INFO Camera camera_manager.cpp:294 libcamera v0.0.0+2681-1fea2730
[0:21:32.914644083] [2640]  WARN CameraSensor camera_sensor.cpp:196 'imx477 10-001a': Recommended V4L2 control 0x009a0922 not supported
[0:21:32.914910826] [2640]  WARN CameraSensor camera_sensor.cpp:248 'imx477 10-001a': The sensor kernel driver needs to be fixed
[0:21:32.914965178] [2640]  WARN CameraSensor camera_sensor.cpp:250 'imx477 10-001a': See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
[0:21:32.921414343] [2640]  WARN CameraSensorProperties camera_sensor_properties.cpp:100 No static properties available for 'imx477'
[0:21:32.921544843] [2640]  WARN CameraSensorProperties camera_sensor_properties.cpp:102 Please consider updating the camera sensor properties database
[0:21:32.921622548] [2640]  WARN CameraSensor camera_sensor.cpp:402 'imx477 10-001a': Failed to retrieve the camera location
[0:21:33.108766666] [2637]  WARN V4L2 v4l2_pixelformat.cpp:180 Unsupported V4L2 pixel format XB24
[0:21:33.109448984] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:21:33.109595782] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:21:33.109658800] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:21:33.109715134] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:21:33.109778264] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:21:33.109840838] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:21:33.109897783] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:21:33.109951302] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:21:33.110839603] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:21:33.111143938] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:21:33.111205698] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:21:33.111263069] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:21:33.111325180] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:21:33.111387736] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:21:33.111441273] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:21:33.111495255] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:21:33.112758780] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:21:33.112884985] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:21:33.112946004] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:21:33.113002615] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:21:33.113065375] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:21:33.113127394] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:21:33.113184449] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:21:33.113238450] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:21:33.113825064] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:21:33.113923750] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:21:33.113981491] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:21:33.114036306] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:21:33.114096695] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:21:33.114168492] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:21:33.114221696] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:21:33.114275289] [2637]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:21:33.114640494] [2637]  INFO Camera camera.cpp:905 configuring streams: (0) 4056x3040-YUV420 (1) 4056x3040-SBGGR12_CSI2P
[0:21:33.115297924] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:21:33.115417776] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:21:33.115475703] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:21:33.115530573] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:21:33.115590037] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:21:33.115651556] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:21:33.115705389] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:21:33.115758889] [2640]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:21:33.116102502] [2640]  INFO RPI raspberrypi.cpp:618 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected mode: 4056x3040-pRCC
[0:21:33.256361456] [2640] ERROR V4L2 v4l2_videodevice.cpp:1133 /dev/video0[12:cap]: Not enough buffers provided by V4L2VideoDevice
ERROR: *** failed to allocate capture buffers ***
I have tested 2K resolution which produce 22 raw files,

Code: Select all

./libcamera-raw -t 100 --width=2028 --height=1520 --shutter=100 --segment 1 -o /mnt/ramdisk/2k_%03d.raw
The output i,

Code: Select all

pi@raspberrypi:~/libcamera-apps/build $ ./libcamera-raw -t 100 --width=2028 --height=1520 --shutter=100 --segment 1 -o /mnt/ramdisk/2k_%03d.raw
WARNING: consider inline headers with 'pause'/split/segment/circular
[0:24:52.858803797] [2702]  INFO Camera camera_manager.cpp:294 libcamera v0.0.0+2681-1fea2730
[0:24:52.900338437] [2705]  WARN CameraSensor camera_sensor.cpp:196 'imx477 10-001a': Recommended V4L2 control 0x009a0922 not supported
[0:24:52.900615605] [2705]  WARN CameraSensor camera_sensor.cpp:248 'imx477 10-001a': The sensor kernel driver needs to be fixed
[0:24:52.900707199] [2705]  WARN CameraSensor camera_sensor.cpp:250 'imx477 10-001a': See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
[0:24:52.909133409] [2705]  WARN CameraSensorProperties camera_sensor_properties.cpp:100 No static properties available for 'imx477'
[0:24:52.909320465] [2705]  WARN CameraSensorProperties camera_sensor_properties.cpp:102 Please consider updating the camera sensor properties database
[0:24:52.909439670] [2705]  WARN CameraSensor camera_sensor.cpp:402 'imx477 10-001a': Failed to retrieve the camera location
[0:24:53.105686960] [2702]  WARN V4L2 v4l2_pixelformat.cpp:180 Unsupported V4L2 pixel format XB24
[0:24:53.106737058] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:24:53.106949429] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:24:53.107010763] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:24:53.107069726] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:24:53.107131412] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:24:53.107193190] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:24:53.107248616] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:24:53.107302894] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:24:53.107825508] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 11052.2 (best 11052.2)
[0:24:53.107917175] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 500 (best 500)
[0:24:53.107974120] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 7596 (best 500)
[0:24:53.108084324] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 8679.84 (best 500)
[0:24:53.108147176] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 10552.2 (best 500)
[0:24:53.108211084] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 0 (best 0)
[0:24:53.108265547] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 7096 (best 0)
[0:24:53.108319288] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 8179.84 (best 0)
[0:24:53.109029107] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 3956.22 (best 3956.22)
[0:24:53.109169978] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 1387 (best 1387)
[0:24:53.109227515] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 500 (best 500)
[0:24:53.109282237] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 1583.84 (best 500)
[0:24:53.109341997] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 3456.22 (best 500)
[0:24:53.109402627] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 887 (best 500)
[0:24:53.109456683] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 0 (best 0)
[0:24:53.109510035] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 1083.84 (best 0)
[0:24:53.110012667] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 3956.22 (best 3956.22)
[0:24:53.110085871] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 1387 (best 1387)
[0:24:53.110142131] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 500 (best 500)
[0:24:53.110196390] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 1583.84 (best 500)
[0:24:53.110254446] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 3456.22 (best 500)
[0:24:53.110313928] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 887 (best 500)
[0:24:53.110367817] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 0 (best 0)
[0:24:53.110420521] [2702]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 1083.84 (best 0)
[0:24:53.110742301] [2702]  INFO Camera camera.cpp:905 configuring streams: (0) 2028x1520-YUV420 (1) 2028x1520-SBGGR12_CSI2P
[0:24:53.111529508] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt RG10 Score: 3956.22 (best 3956.22)
[0:24:53.111635250] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt RG12 Score: 1387 (best 1387)
[0:24:53.111693176] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt RG12 Score: 500 (best 500)
[0:24:53.111747454] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt RG12 Score: 1583.84 (best 500)
[0:24:53.111804954] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 1332x990 fmt pRAA Score: 3456.22 (best 500)
[0:24:53.111864936] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 4056x3040 fmt pRCC Score: 887 (best 500)
[0:24:53.111918381] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1520 fmt pRCC Score: 0 (best 0)
[0:24:53.111970474] [2705]  INFO RPI raspberrypi.cpp:121 Mode: 2028x1080 fmt pRCC Score: 1083.84 (best 0)
[0:24:53.112347161] [2705]  INFO RPI raspberrypi.cpp:618 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected mode: 2028x1520-pRCC
[0:24:53.208045395] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: Sharpness = 1.000000
[0:24:53.208330008] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: Saturation = 1.000000
[0:24:53.208430990] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: Contrast = 1.000000
[0:24:53.208514620] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: Brightness = 0.000000
[0:24:53.208580009] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: AwbMode = 0
[0:24:53.208749102] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: FrameDurationLimits = [ 33333, 33333 ]
[0:24:53.209003400] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: NoiseReductionMode = 3
[0:24:53.209274364] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: ExposureTime = 100
[0:24:53.209423791] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: AeMeteringMode = 0
[0:24:53.209502014] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: AeExposureMode = 0
[0:24:53.209580255] [2708]  INFO IPARPI raspberrypi.cpp:611 Request ctrl: ExposureValue = 0.000000
[0:24:53.213086143] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Image
[0:24:53.213547331] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.213994315] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:24:53.724997469] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.725221322] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.725312323] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.725394601] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.725473768] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.725554879] [2705]  INFO RPISTREAM rpi_stream.cpp:122 No buffers available for Unicam Embedded
[0:24:53.756146648] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (6 left)
[0:24:53.787772886] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (5 left)
[0:24:53.822532676] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (4 left)
[0:24:53.853689096] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (3 left)
[0:24:53.885507668] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (2 left)
[0:24:53.923241270] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (1 left)
[0:24:53.951821158] [2705]  INFO RPI raspberrypi.cpp:1626 Dropping frame at the request of the IPA (0 left)
Raw stream: 2028x1520 stride 3072 format SBGGR12_CSI2P
Can anyone help to to solve the problem? Thank you!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11477
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: libcamera-raw fails with 4K resolution

Wed Jun 16, 2021 10:59 am

Code: Select all

[0:21:33.256361456] [2640] ERROR V4L2 v4l2_videodevice.cpp:1133 /dev/video0[12:cap]: Not enough buffers provided by V4L2VideoDevice
V4L2 has a slightly weird API in that you ask it to allocate N buffers, but should it not be able to it keeps going and tells you that it allocated M (where M < N). If you need N buffers then the only thing to do is throw an error and quit, which is what libcamera-raw has done.

The default configuration for Pi4 is to have a 256MB CMA heap (which is where these allocations come from), but it is also shared with the display resources.
Edit /boot/config.txt (you'll need to use sudo), find the line "dtoverlay=vc4-fkms-v3d", and make it "dtoverlay=vc4-fkms-v3d,cma-384".
Do NOT increase gpu_mem when using libcamera as there is no point, and both the gpu_mem and CMA heaps have to fit in the bottom 1GB of RAM.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

rollyng
Posts: 54
Joined: Sat Dec 10, 2016 4:08 pm
Location: Hong Kong SAR

Re: libcamera-raw fails with 4K resolution

Wed Jun 16, 2021 4:26 pm

6by9 wrote:
Wed Jun 16, 2021 10:59 am

Code: Select all

[0:21:33.256361456] [2640] ERROR V4L2 v4l2_videodevice.cpp:1133 /dev/video0[12:cap]: Not enough buffers provided by V4L2VideoDevice
V4L2 has a slightly weird API in that you ask it to allocate N buffers, but should it not be able to it keeps going and tells you that it allocated M (where M < N). If you need N buffers then the only thing to do is throw an error and quit, which is what libcamera-raw has done.

The default configuration for Pi4 is to have a 256MB CMA heap (which is where these allocations come from), but it is also shared with the display resources.
Edit /boot/config.txt (you'll need to use sudo), find the line "dtoverlay=vc4-fkms-v3d", and make it "dtoverlay=vc4-fkms-v3d,cma-384".
Do NOT increase gpu_mem when using libcamera as there is no point, and both the gpu_mem and CMA heaps have to fit in the bottom 1GB of RAM.
Thanks very much for your prompt response. I have to change to cma-512 in order to work. To compare the speed of recording individual frame one by one, raspiraw records 6-7 fps on my SSD but with libcamera-raw it reaches 8-9 fps. A good improvement indeed. :D

Return to “Camera board”