Hi, dokyun
Thanks for your reply!
I called VIDIOC_QBUF and VIDIOC_DQBUF ioctl. and I found the problem is the timestamp. in the v4l2.c, it needs the timestamp when the frame are captured. the source code is something like the
following. When I erase the *ts = buf.timestamp.tv_sec * int64_t_C(1000000) + buf.timestamp.tv_usec; It can capture the frame ,but it captured very fast, and I found the
buf.timestamp.tv_sec and buf.timestamp.tv_usec's value is zero. can you tell me what's the effect of the buf.timestamp.tv_sec and buf.timestamp.tv_usec! thanks a lot!
static int mmap_read_frame(struct
video_data *s, void *frame, int64_t *ts)
{
struct v4l2_buffer buf;
int res;
memset(&buf, 0, sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
/* FIXME: Some special treatment might be needed in case of loss of signal... */
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 &&
((errno == EAGAIN) || (errno == EINTR)));
if (res < 0) {
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
return -1;
}
assert (buf.index < s->buffers);
assert(buf.bytesused == s->frame_size);
/* Image is at s->buff_start[buf.index] */
memcpy(frame, s->buf_start[buf.index], buf.bytesused);
*ts = buf.timestamp.tv_sec * int64_t_C(1000000) + buf.timestamp.tv_usec;
res = ioctl (s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
return -1;
}
return s->buf_len[ buf.index];
{
struct v4l2_buffer buf;
int res;
memset(&buf, 0, sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
/* FIXME: Some special treatment might be needed in case of loss of signal... */
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 &&
((errno == EAGAIN) || (errno == EINTR)));
if (res < 0) {
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
return -1;
}
assert (buf.index < s->buffers);
assert(buf.bytesused == s->frame_size);
/* Image is at s->buff_start[buf.index] */
memcpy(frame, s->buf_start[buf.index], buf.bytesused);
*ts = buf.timestamp.tv_sec * int64_t_C(1000000) + buf.timestamp.tv_usec;
res = ioctl (s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
return -1;
}
return s->buf_len[ buf.index];
}
_______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
