91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

在LinuxPC下使用UVC攝像頭采集視頻,并用X264壓縮成H264格式。這個只是一個初級的程序,只是實現了功能

資源截圖

代碼片段和文件信息

/*?include?head_files*/
#include?
#include?
#include?
#include?
#include?
#include????//low_level?i/o
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?

#include???//for?videodev2.h

#include?

#include?“capture.h“

//****************changed?by?zzy***************************
#include?“h264encoder.h“
//*********************************************************

struct?buffer{
void?*??start;
size_t??length;
};


static?char?*????????video_name?????=?“/dev/video0“;
static?int???????????video_fd???????=?-1;
struct?buffer?*??????buffers??????=?NULL;
static?unsigned?int??n_buffers????=?0;
static?unsigned?int?number?=?0;

//*************************changed?by?zzy*****************
Encoder?en;
uint8_t?*h264_buf?=?NULL;
//***********************add?by?zzy***********************
int?count_flag?=?1;
int?file_fd;
int?h264_fd;

void?process_video_image(const?void?*?punsigned?int?size)
{


int?write_size;
int?h264_length?=?0;



h264_buf?=?(uint8_t?*)?malloc(sizeof(uint8_t)?*?320?*?240?*?3);?//?設置緩沖區

//**********************changed?by?zzy***************************
//**********************進行H264編碼yuv的大小為320*240*2************************
//encode_frame(p320*240*2);
h264_length?=?compress_frame(&en?-1?(uint8_t?*)p??h264_buf);
//**********************changed?by?zzy****************************
//**********************寫yuv文件*********************************
write_size=write(file_fdpsize);
printf(“write_size?=?%d\n“write_size);
//**********************寫h264文件*********************************
if?(h264_length?>?0)?{
write_size=write(h264_fdh264_bufh264_length);
printf(“write_size?=?%d\n“write_size);


}
free(h264_buf);

}

int?read_video_frame?(void)
{
struct?v4l2_buffer?buf;
unsigned?int?size;

CLEAR(buf);

buf.type?=?V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory?=?V4L2_MEMORY_MMAP;
size?=?buffers[buf.index].length;
//********************change?by?zzy**********************************
printf(“buffers.length=%dcount_flag?=?%d\n“buffers[buf.index].lengthcount_flag);
count_flag++;
if?(-1?==?ioctl(video_fdVIDIOC_DQBUF&buf))
{
perror(“VIDIOC_DQBUF:“);
exit(EXIT_FAILURE);
return?0;
}

assert?(buf.index? process_video_image?(buffers[buf.index].startsize);

if?(-1?==?ioctl(video_fdVIDIOC_QBUF&buf))
{
perror(“VIDIOC_QBUF:“);
exit(EXIT_FAILURE);
}

return?1;
}?

void?read_video_loop(void)
{
unsigned?int?count?;
//****************************change?by?zzy*******************************
//count?=?20;
??count?=?20;
while(count--?>?0)
{
for?(;;)
{
fd_set?fds;
struct?timeval?tv;
int?r;

FD_ZERO(&fds);
FD_SET(video_fd&fds);

//timeout?=?2sec
tv.tv_sec?=?5;
tv.tv_usec?=?0;

r?=?select(video_fd+1&fdsNULLNULL&tv);

if?(-1?==?r)
{

評論

共有 條評論