v4l2: Drop the first frame after camera startup

A quite big number of UVC cameras - due to firmware or kernel driver
issues - have bad timestamps of the first frame, confusing clients
like pipewiresrc.
Drop the first frame, as this seems to be the most reliable workaround
for the time being.

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3910
This commit is contained in:
Robert Mader 2024-03-30 13:57:43 +01:00 committed by Wim Taymans
parent 88db0a9103
commit f9bac4889c

View file

@ -1369,6 +1369,11 @@ static int mmap_read(struct impl *this)
if (xioctl(dev->fd, VIDIOC_DQBUF, &buf) < 0)
return -errno;
/* Drop the first frame in order to work around common firmware
* timestamp issues */
if (buf.sequence == 0)
return 0;
pts = SPA_TIMEVAL_TO_NSEC(&buf.timestamp);
spa_log_trace(this->log, "v4l2 %p: have output %d", this, buf.index);