I think I've found a bug / regression. Alternatively I'm just stupid, and any clues would be welcome.
I'm writing a C application to consume video from libcamera. It is based on the "simple-cam" demo application found here:
https://git.libcamera.org/libcamera/sim ... le-cam.cpp
There is a point in source code where the application configures what kind of stream it wants to consume. The original demo code (comments dropped) looks like this:
Previously (in autumn 2023) I only altered the "width" and "height" arguments and got an NV12 / YUV420 stream from with StreamRole::Viewfinder. Now I upgraded my system to a new Raspbian, with it came a new "libcamera" version, and things no longer work as expected. I expect the output:
I get the output:
When I try to influence the output by setting the pixel format, I can only set the pixel format to...
...but I cannot set the pixel format to any YUV format listed here, for examle I cannot issue the command:
...because I get the error...
...and I cannot set other YUV-type formats either. I have tried NV42, NV12, NV21, YUV444 and out of curiosity, even MJPEG. I cannot even switch to a different RGB-like format, e.g. I cannot request ABGR8888 either. I have also tried referring to the pixel format variables (without using string arguments). Then I can request BGR888, but I still cannot request any of the YUV based formats or MJPEG.
Any clues would be welcome. Is the preview pixel format "set in stone"? Should I not use a preview stream if I want to change pixel formats? Should I use differnt hardware? I have tried the IMX219 (v2 original camera), various fish-eye OV5647 cameras, but I haven't yet exhausted my selection of cameras.

https://git.libcamera.org/libcamera/sim ... le-cam.cpp
There is a point in source code where the application configures what kind of stream it wants to consume. The original demo code (comments dropped) looks like this:
Code:
std::unique_ptr<CameraConfiguration> config = camera->generateConfiguration( { StreamRole::Viewfinder } );StreamConfiguration &streamConfig = config->at(0);std::cout << "Default viewfinder configuration is: " << streamConfig.toString() << std::endl;streamConfig.size.width = 0; //4096streamConfig.size.height = 0; //2560int ret = camera->configure(config.get());if (ret) {std::cout << "CONFIGURATION FAILED!" << std::endl;return EXIT_FAILURE;}
Code:
Default viewfinder configuration is: 800x600-NV12
Code:
Default viewfinder configuration is: 800x600-XRGB8888
Code:
streamConfig.pixelFormat = libcamera::PixelFormat::fromString("RGB888");
Code:
streamConfig.pixelFormat = libcamera::PixelFormat::fromString("YUV420");
Code:
ERROR Camera camera.cpp:1171 Can't configure camera with invalid configurationCONFIGURATION FAILED!
Code:
streamConfig.pixelFormat = formats::MJPEG; // failsstreamConfig.pixelFormat = formats::NV42; // failsstreamConfig.pixelFormat = formats::NV21; // failsstreamConfig.pixelFormat = formats::YUV420; // failsstreamConfig.pixelFormat = formats::YUV444; // failsstreamConfig.pixelFormat = formats::BGR888; // works!
Statistics: Posted by diastrikos — Sun May 05, 2024 10:27 am — Replies 2 — Views 50