////
  unsigned int i;
  enum v4l2_buf_type type;
  for(i = 0; i < 4; i++){
    struct v4l2_buffer buf;
    buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    buf.memory = V4L2_MEMORY_MMAP;
    buf.index = i;
    ioctl(fd,VIDIOC_QBUF,&buf);
  }
  type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  ioctl(fd,VIDIOC_STREAMON,&type);
  ////
  struct v4l2_buffer buf;
  buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  buf.memory = V4L2_MEMORY_MMAP;
  ioctl(fd,VIDIOC_DQBUF,&buf);
  char path[20];
  snprintf(path,sizeof(path),"./yuyv%d",buf.index);
  int fdyuyv = open(path,O_WRONLY|O_CREAT,00700);
  printf("TK--------->>>>fdyuyv is %d ",fdyuyv);
  int resultyuyv = write(fdyuyv,buffers[buf.index].start,1280*720*2);
  printf("TK--------->>>resultyuyv is %d ",resultyuyv);
  close(fdyuyv);
  ////
  close(fd);
  return 0;
}

  二、编译运行

  gcc test.c -o rest

  ./test

  三、结果

  在本目录下生成yuyv0这样一个文件,是jpeg编码后的文件。