All correct in raspivid, but not what you want. Raw in raspivid means raw yuv420 images.
It's clear that the data in this picture is not I420, because the three "little" images are the same size; I420 has one plane of Y at full resolution, then two planes of U and V at half resolution (quarter as many pixels.) In fact, I420 at the resolution I use uses 115200 bytes per picture, which may be one reason why the splitter gets the buffer size wrong.
I am also not interested in Bayer pattern data, because I'm scaling down by a large factor, and would rather just let the hardware deal with that.
I am using -raw rgb. Here is the entire command line:
Code: Select all
raspivid -w 320 -h 240 -t 30000 -td 1000,1000 --raw raw -rf rgb -o foo
I then generate the PNG by simply reading the first 230400 bytes into RAM and calling stbi_write_png("output.png", 320, 240, 3, data, 0) from the fabulous "stb" single-header library. This function works fine for other images, and the image it shows on disk is the same as the image I draw from RAM, so I trust that this is the correct representation.
When using the yuv format, I get data exactly in the format I would expect for the mode, and I can manually convert that to RGB. That is my work-around for now. However, that uses more CPU.
Why is the "-raw RGB" output data from raspivid, and thus from the video splitter, wrong? Can it be fixed?
What I really need is:
- camera capture at 320x240 or another similar small resolution (640x480 is probably pushing it) at 60 Hz
- hardware binning
- hardware encoding to H.264 using opaque buffers (no round-trip to CPU memory)
- separate stream of RGB data in the same resolution at the same frame rate going to CPU memory
I'm currently using the same code as raspivid (and, in fact, using un-modified raspivid for verifying this bug.)
Could some other mechanism be used? For example, can the "still" port be pressed into 60 Hz service with RGB format, while the video capture port is still I420?
Perhaps a thing I could do would be to add a "resizer" on top of the "splitter" (or on top of the "preview"?) that converts to RGB, and keep the splitter "tap" port in I420 mode?