Hello,
Preamble: Please accept apologies if this isn't an appropriate forum
for my topic. I'm not entirely sure where to ask.
I've got a program that streams MJPEG video out an HTTP connection from
a USB-connected camera.
On linux kernel 4.1.15, it works beautifully. On linux kernel 4.14.98,
it does...not.
Side note: Yes, I know these are old kernels. This is an embedded
application and I don't have the freedom of choice in this matter.
Moving on..
In developing this program, I made some utilities to exercise various
v4l2 interfaces; using those utilities, I found the most obvious
difference appears to be the info one gets from the VIDIO_QUERYBUF ioctl.
One of my little utilities spits out lots of data about the camera, then
grabs one frame. Here're the salient bits of that output:
On 4.1.15:
Current buffer format:
MJPG at 1920x1080 Progressive
Bytes per line: 0 Image size: 4147200 Colorspace: SRGB
Transfer function: DEFAULT
Quantization: DEFAULT YCbCr Encoding: DEFAULT
Notice: Asked for 1 buffers and got 1.
Notice: Buffer size 4147200 at offset 0x0
Releasing resources...
Asked for a frame and got 4151296 bytes (99%)
On 4.14.98:
Current buffer format:
MJPG at 1920x1080 Progressive
Bytes per line: 0 Image size: 4147200 Colorspace: SRGB
Transfer function: DEFAULT
Quantization: DEFAULT YCbCr Encoding: DEFAULT
Notice: Asked for 1 buffers and got 1.
Notice: Buffer size 4149360 not expected size of 4147200 bytes
Releasing resources...
Asked for a frame and got 4151296 bytes (99%)
The key difference is the size of the buffer size that gets reported on
4.14.98 is larger than the frame size.
My streaming code just shoves frame data out the HTTP connection,
inserting MJPEG boundaries between frames. It doesn't seem to matter
whether I send out the "bytesused" or "length" number of bytes; the
result is a stream that is full of garbage, sticky frames (where old
video frame reappear in the stream amidst new frames), and and
all-around bad time. Data gets into the buffer by way of the
VIDIOC_STREAMON ioctl.
So I'm inclined to suspect v4l2 in kernel 4.14.98 is doing something
that I don't understand (that it isn't doing in 4.1.15) when it streams
frames into buffers.
At this point, I'm not even sure what the correct questions are to ask.
I'd appreciate any sort of advice on this.
Many thanks,
-Brian