v4l打开video设备 ,执行VIDIOC_DQBUF,出现Resource temporarily unavailable 问题【转】

简介:

转自:http://blog.csdn.net/china_video_expert/article/details/7236856

如果你在执行VIDIOC_DQBUF突然提示以下错误:

error: VIDIOC_DQBUF: Resource temporarily unavailable

那么很可能是你使用非阻塞方式打开设备文件的造成的。

Resource temporarily unavailable是一种EAGAIN的错误。EAGAIN是较常见的一种错误(比如用在非阻塞操作中),从字面上来看,是提示再试一次。这个错误经常出现在当应用程序进行一些非阻塞(non-blocking)操作(对文件或socket)的时候。例如,以O_NONBLOCK的标志打开文件/socket/FIFO,如果你连续做read操作而没有数据可读。此时程序不会阻塞起来等待数据准备就绪返回,read函数会返回一个错误EAGAIN,提示你的应用程序现在没有数据可读请稍后再试。(其实这样的错误一改是可以会略才对,也只有用非阻塞方式打开文件时会出现此类错误)。

因此建议 V4L2编程中使用阻塞方式打开一个设备文件,除非你能保重开始采集数据时队列里的n块缓存已有数据存在。


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

1、建议 V4L2编程中使用阻塞方式打开一个设备文件,除非你能保重开始采集数据时队列里的n块缓存已有数据存在。

倘若使用非阻塞,则会出现BUGVIDIOC_DQBUF : temporarily unavailable

 

2、视频格式化测试成功代码//设置获取视频的格式

memset( &fmt, 0, sizeof(fmt));

fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;//视频数据流类型,永远都是V4L2_BUF_TYPE_VIDEO_CAPTURE

fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;//视频源的格式为JPEG或YUN4:2或RGB

fmt.fmt.pix.width = 600;//设置视频宽度

fmt.fmt.pix.height = 480;//设置视频高度

fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;//具体不知道干嘛的,貌似重要

if (ioctl(fd, VIDIOC_S_FMT, &fmt) < 0)//使配置生效

{

printf("set format failed\n");

return -1;

 

 

/* 待续 */

}




本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sky-heaven/p/7115048.html,如需转载请自行联系原作者


相关文章
|
7月前
|
iOS开发
IOS Pods Failed to connect to www.gstatic.com port 443: Operation timed out
IOS Pods Failed to connect to www.gstatic.com port 443: Operation timed out
36 0
|
6月前
|
Web App开发 缓存 网络协议
DNS_PROBE_FINISHED_BAD_CONFIG 错误分析
DNS_PROBE_FINISHED_BAD_CONFIG 错误分析
350 0
|
9月前
UE Operation File [ Read / Write ] DTOperateFile Plug-in Description
UE Operation File [ Read / Write ] DTOperateFile Plug-in Description
41 0
|
6月前
|
开发者
上传苹果版本时错误解决办法:No suitable application records were found. Verify your bundle identifier
上传苹果版本时错误解决办法:No suitable application records were found. Verify your bundle identifier
60 2
|
9月前
|
Windows
UE INI File Operation [ Read / Write ] Plug-in description
UE INI File Operation [ Read / Write ] Plug-in description
37 0
|
编解码 机器人 Android开发
Android10.0 OTA 错误解决办法(@/cache/recovery/block.map‘ failed)
Android10.0 OTA 错误解决办法(@/cache/recovery/block.map‘ failed)
451 0
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
WampServer 3 访问403 Forbidden You don't have permission to access this resource 解决
|
XML 安全 Android开发
Android P 第二个测试版本请求网络 CLEARTEXT communication to host not permitted by network
Android P 第二个测试版本请求网络 CLEARTEXT communication to host not permitted by network
160 0

热门文章

最新文章