LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: realtang

大家一起来讨论video for linux的编程。

[复制链接]
发表于 2004-6-23 09:40:05 | 显示全部楼层
對不起,這我不曉得. 不過在SDL下是不見議使用rgb24的(因它最慢),最好使用rgb16,不然就使用rgb32.
 楼主| 发表于 2004-6-30 13:24:33 | 显示全部楼层
再补发一下我写的framebuffer下,overlay显示的v4l2程序。

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <sys/ioctl.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. #include <linux/types.h>
  7. #include <unistd.h>
  8. #include <stdlib.h>
  9. #include <sys/mman.h>
  10. #include <sys/poll.h>

  11. #include <linux/videodev.h>

  12. #define FILENAME "/dev/video"

  13. #define IOCTL(fd, req, addr )   ((-1==ioctl(fd,req,addr))?(perror(#req),exit(EXI
  14. T_FAILURE)):0)

  15. int main(void)
  16.   {
  17.     int fd;
  18.     struct v4l2_input input;
  19.     struct v4l2_standard standard;
  20.     struct v4l2_format  format;
  21.     struct v4l2_framebuffer fb;
  22.     v4l2_std_id std;
  23.     int index;
  24.     int one=1,zero=0;
  25.     fd=open(FILENAME,O_RDWR);
  26.     //set the input to Composite1
  27.     index = 1;
  28.     IOCTL(fd,VIDIOC_S_INPUT,&index);
  29.    //query video standard
  30.     IOCTL(fd,VIDIOC_G_STD,&std);
  31.     standard.index = 0;
  32.     while (0 == ioctl(fd,VIDIOC_ENUMSTD,&standard))
  33.        {   if (standard.id & std)
  34.             printf("the current video standard :%s\n",standard.name);
  35.             standard.index++;
  36.        }
  37.   //set up overlay param and start overlay
  38.        format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
  39.        IOCTL(fd,VIDIOC_G_FMT,&format);
  40.        format.fmt.win.w.width = 768 ;
  41.        format.fmt.win.w.height = 576 ;
  42.        format.fmt.win.w.top = 70;
  43.        format.fmt.win.w.left = 50;
  44.        format.fmt.win.field = V4L2_FIELD_INTERLACED;
  45.        IOCTL(fd,VIDIOC_S_FMT,&format);
  46.        IOCTL(fd,VIDIOC_G_FBUF,&fb);
  47.        printf("before set the fb, the pixelformat is 0x%x\n ",fb.fmt.pixelformat
  48. );
  49.        fb.flags = V4L2_FBUF_FLAG_PRIMARY;
  50.        fb.fmt.width = 1024;
  51.        fb.fmt.height = 768;
  52.        fb.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
  53.        fb.fmt.bytesperline = 4096;
  54.        fb.fmt.sizeimage = 768*4096;
  55.        fb.fmt.field = V4L2_FIELD_INTERLACED;
  56.        fb.fmt.colorspace =  V4L2_COLORSPACE_SRGB;
  57.        IOCTL(fd,VIDIOC_S_FBUF,&fb);
  58.        IOCTL(fd,VIDIOC_OVERLAY,&one);
  59.        while(getchar()=='q')          {
  60.              IOCTL(fd,VIDIOC_OVERLAY,&zero);
  61.              close(fd);
  62.        }

  63.        return(0);
  64. }
复制代码

请热爱linux下多媒体编程的朋友多提建议。
发表于 2004-8-2 14:16:08 | 显示全部楼层
请问二位:
1:用v4l2编写多媒体,在/linux/videodev2.h 和videodev.h中那个数据结构常常用?在videodev2.h中定义了如:struct v4l2_xxxx{}
在videodev.h中定义了如:struct video_xxx{}
2:用GTK, SDL库是编写多媒体的gui界面的吧?
3:ITOCTL()的重要作用
发表于 2004-8-2 21:06:25 | 显示全部楼层
顶!欢迎有志向于linux下多媒体的爱好的兄弟讨论!
发表于 2004-8-2 23:53:40 | 显示全部楼层
我一直对SDL感兴趣,但只写过一些游戏。视频不太懂,关注中。
 楼主| 发表于 2004-8-3 16:46:26 | 显示全部楼层
videodev.h在2。6的内核头文件中会包括进videodev2.h,所以没必要担心要使用后者,只要include前者就可以支持v4l2了。
gtkfb和sdl都是以linux内核所提供的framebuffer为基础为了编程方便所提供的编程库。
sdl这样说:Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer。
ioctl()本质是系统调用,内核通过此函数来实现设备驱动程序所提供的read,write,select,poll,mmap等功能。
发表于 2004-8-4 08:57:25 | 显示全部楼层
1:楼主还没告诉我那几个数据结构常用:
struct v4l2_input input;
    struct v4l2_standard standard;
    struct v4l2_format  format;
    struct v4l2_framebuffer fb;
    v4l2_std_id std;
这几个吗?
2:帧缓存队列如何理解?
 楼主| 发表于 2004-8-4 12:11:47 | 显示全部楼层
除了你说的,还有
struct v4l2_capability
struct v4l2_format
struct v4l2_requestbuffers
struct v4l2_buffer 等
你说的是指framebuffer的,还是bttv驱动程序的?
发表于 2004-8-5 12:52:30 | 显示全部楼层
1:我并不理解framebufer和bttv有何区别或者是saa7134的驱动,我认为framebuffer是个帧缓冲设备/dev/fb0,fb1 ......他和帧缓冲队列何什么关系吗?
2:帧缓存队列的作用?,扑获的电视图像信号和象素关系?
3:好像要用到一个YUY或者叫什么加速的设备吧?
4:实现PIP(画中画)功能,除了软件的要求还要额外的硬件要求吗?
发表于 2004-8-6 08:47:01 | 显示全部楼层
现在一切就绪,只欠东方!那我该如何入手呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表