buffer v4l2src for 30 seconds

Nicolas Dufresne nicolas at ndufresne.ca
Tue Dec 6 14:59:26 UTC 2016


The problems are various.

a) V4L2 API limits to 32 the number of allocated mmap/dmabuf buffers
b) The queue does not know how to translate time to number of buffers
c) The queue does not implement the allocation query at all

Depending on the driver you are using, you have different workaround
though.

**USERPTR**

If your driver supports USERPTR, you may follow the method proposed by
Dimitrios. This is currently only supported by UVC driver. For this
specific pipeline, the driver must be using vmalloc memory or a IOMMU
that allow allocation that are not aligned to a physical page.


**MMAP**

All drivers should support mmap these days. RW is in fact emulated on
top of it through libv4l2 since driver no longer support this mode.
Right now, the only way to prevent this miss-negotiation, is to ensure
that v4l2src thinks the allocation query failed. There is one element
known to make this query failed, it's called 'tee'. So add a tee (with
a single branch)  after v4l2src will tell the src that the number of
required buffer is unknown. As a side effect, 4 buffers will be
allocated, and when the pool get low, buffer will be copied. Copies is
the only way to fulfill your requirement in that mode. So the generic
method would be:

gst-launch-1.0 v4l2src ! tee \
  ! queue min-threshold-time=30000000000 \
          max-size-time=0 max-size-buffers=0 max-size-bytes=0 \
  ! videoconvert ! ximagesink

**FUTURE**

As you may notice, there is a missing feature in the queues. When
configured in number of buffers, it should be able to interact with the
allocation query and ensure enough buffers is allocated. When that get
implemented (patch welcome), an application could compute the number of
buffers from the selected rate. V4l2src will then be able to adapt. It
is not clear to be if the convert query could be used or not,
GST_FORMAT_BUFFERS is not widely implemented.

regards,
Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20161206/11e6d6d0/attachment.sig>


More information about the gstreamer-devel mailing list