我想通过c或python读取文件/dev/video0,并将传入的字节存储在另一个文件中。 这是我的c代码:
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main()
{
int fd,wfd;
fd=open("/dev/video0",O_RDONLY);
wfd=open("image",O_RDWR|O_CREAT|O_append,S_IRWXU);
if(fd==-1)
perror("open");
while(1)
{
char buffer[50];
int rd;
rd=read(fd,buffer,50);
write(wfd,buffer,rd);
}
return 0;
}
当我运行这段代码并在一段时间后终止程序时,除了生成一个文件名“image”之外,什么都没有发生,这是很常见的。在
这是我的python代码:
^{pr2}$这是我运行这个片段时的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 22] Invalid argument
我想知道如何使用纯c或python实现这一点密码。请没有外部库建议。在
没那么容易。在
关于我的评论,下面是一个在磁盘上显示视频流的示例(请参见documentation):
相关问题 更多 >
编程相关推荐