v4l.c

来自「一个很好用的MPEG1/4的开源编码器的应用程序」· C语言 代码 · 共 65 行

C
65
字号
/*  *    input_v4l.c * *	Copyright (C) Vivien Chappelier - 2001 * *  This file is part of fame, a free MPEG encoder. *	 *  fame is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2, or (at your option) *  any later version. *    *  fame is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. *    *  You should have received a copy of the GNU General Public License *  along with GNU Make; see the file COPYING.  If not, write to *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  * */#include <stdio.h>#include <signal.h>#include "v4l.h"input_v4l_context_t *v4l_init(int width, int height){  input_v4l_context_t *v4l;  int channel = 0;  v4l = (input_v4l_context_t *) malloc(sizeof(input_v4l_context_t));  /* open device */  if (fg_open_device (&v4l->fg, video_device) != 0)    return(NULL);  /* set format */  fg_start_grab_image(&v4l->fg, width, height, FORMAT_YUV420P);  /* set TV source */  fg_set_mode(&v4l->fg, VIDEOMODE_AUTO);  /* enable audio */  fg_set_audio(&v4l->fg, 65535);  return(v4l);}void v4l_close(input_v4l_context_t *v4l) {  fg_stop_grab_image(&v4l->fg);  fg_set_audio(&v4l->fg, 0);  fg_close_device (&v4l->fg);  free(v4l);}int v4l_read(input_v4l_context_t *v4l, void *buffer, int size){  fg_get_next_image(&v4l->fg);  if(v4l->fg.current_image)    memcpy(buffer, v4l->fg.current_image, size);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?