Hi Yurij, I tried your sample program. The output is as follows. Memory map buffer: size: 17039360 frames: 8 Memory mapped to 0xffffffff Error: Grabber chip can't sync How to rectify the error? In my case the tv norm is PAL. I have some doubts in source code. map = mmap(0, mywidth * myheight * 2 + 4096, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0); Why the "4096" in mmap ? char *ppm_hdr = "P6\n# CREATOR: anonimous :-) (RGB565)\n640 480\n255\n"; what is this "ppm_hdr" and why it is initialised as above ? The output of "v4linfo" is as follows for your perception. ### video4linux device info [/dev/video0] ### general info VIDIOCGCAP name : "BT878(Prolink PixelView PlayT)" type : 0xab [CAPTURE,TUNER,OVERLAY,CLIPPING,SCALES] channels : 3 audios : 1 maxwidth : 924 maxheight : 576 minwidth : 48 minheight : 32 VIDIOC_QUERYCAP driver : "bttv" card : "BT878(Prolink PixelView PlayT)" bus_info : "PCI:01:05.0" version : 0.9.11 capabilities : 0x5010015 [VIDEO_CAPTURE,VIDEO_OVERLAY,VBI_CAPTURE,TUNER,READWRITE,STREAMING] picture VIDIOCGPICT brightness : 50400 hue : 31456 colour : 30801 contrast : 26214 whiteness : 0 depth : 24 palette : RGB24 buffer VIDIOCGFBUF base : 0xe8000000 height : 600 width : 800 depth : 32 bytesperline : 4096 window VIDIOCGWIN x : 0 y : 0 width : 320 height : 240 chromakey : 0 flags : 0 channels VIDIOCGCHAN(0) channel : 0 name : "Television" tuners : 1 flags : 0x3 [TUNER,AUDIO] type : TV norm : 0 VIDIOCGCHAN(1) channel : 1 name : "Composite1" tuners : 0 flags : 0x2 [AUDIO] type : CAMERA norm : 0 VIDIOCGCHAN(2) channel : 2 name : "S-Video" tuners : 0 flags : 0x2 [AUDIO] type : CAMERA norm : 0 tuner VIDIOCGTUNER tuner : 0 name : "Television" rangelow : 0 rangehigh : 2147483647 flags : 0x7 [PAL,NTSC,SECAM] mode : PAL signal : 65535 audio VIDIOCGAUDIO audio : 0 volume : 0 bass : 0 treble : 0 Thanks in advance. With Regards, S.Suriya Mohan. On Wed, 01 Oct 2003 Yurij Sysoev wrote : >Hi, > >there is a really brain-dead one :-) > >8<------------------------ begin --------------------------------------------------- >/* > v4l single frame grabber sample >*/ > >#include <stdlib.h> >#include <stdio.h> >#include <fcntl.h> >#include <sys/ioctl.h> >#include <sys/mman.h> >#include <sys/stat.h> >#include <errno.h> > >#include <linux/videodev.h> > >const int mywidth = 640; // !!!!!!! >const int myheight = 480; // NTSC-J - pls, put your here > >static struct video_capability capability; > >static int fd = -1; > >static int ret_bytes,vfd; > >static char *map = NULL; >static char *dest_buf=NULL; >static char src_buf[691200]; > > >static struct video_mbuf gb_buffers; >static struct video_mmap my_buf; > >int main(void) >{ > int mymode; > int no_bytes,i; > char my_video_dev[100] = "/dev/video0"; > // Open video device > > if (-1 == (fd = open(my_video_dev, O_RDWR))) > { > printf("Error opening device: %s\n", my_video_dev); > goto err; > } > // Get video device captions > > if (-1 == ioctl(fd,VIDIOCGCAP,&capability)) > { > printf("Error: ioctl(fd,VIDIOCGCAP,&capability)\n"); > goto err; > } > fcntl(fd,F_SETFD,FD_CLOEXEC); > // Get number and size of the internal buffers > > if (-1 == ioctl(fd, VIDIOCGMBUF, &gb_buffers)) > { > printf("Error: Error getting buffers, I think\n"); > goto err; > } > > printf("Memory map buffer:\nsize: %d\nframes: %d\n\n", > gb_buffers.size, > gb_buffers.frames); > // Mapping internal driver's buffers to the user space > > map = mmap(0, mywidth * myheight * 2 + 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); > if (map == NULL) > { > printf("Error: mmap returned NULL\n"); > goto err; > } > printf("Memory mapped to 0x%08x\n", map); > // set capture dimensions and format > > my_buf.width = mywidth; > my_buf.height = myheight; > my_buf.format = VIDEO_PALETTE_RGB565; > > my_buf.frame = 0; > // start capture > > if (-1 == ioctl(fd, VIDIOCMCAPTURE, &my_buf)) > { > printf("Error: Grabber chip can't sync\n"); > goto err; > } > // wait for end of the frame capturing > if (-1 == ioctl(fd, VIDIOCSYNC, &my_buf.frame)) > { > printf("Error on sync!\n"); > goto err; > } > memcpy(src_buf, map, mywidth * myheight * 2); > > { > int i, j, k; > char r, g, b; > unsigned short *ptr = (unsigned short *)src_buf; > unsigned short word; > char *ppm_hdr = "P6\n# CREATOR: anonimous :-) (RGB565)\n640 480\n255\n"; > int vfd = open("video-data.ppm",O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); > k = 0; > write(vfd, ppm_hdr, strlen(ppm_hdr)); > for(i = 0; i < myheight; i++) > for(j = 0; j < mywidth; j++) > { > word = ptr[k]; > r = (word >> 8) & 0xf8; > g = (word >> 3) & 0xfc; > b = (word << 3) & 0xf8; > write(vfd, &r, 1); > write(vfd, &g, 1); > write(vfd, &b, 1); > k++; > } > close(vfd); > } > > munmap(map, mywidth * myheight * 2 + 4096); > > printf("Press enter to quit\n"); > getchar(); > return 0; > >err: > return -1; >} > >8<---------------------------- end ------------------------------------------------------------------------------------ > >Mauricio Henriquez wrote: > >>Hi: >> My name is Mauricio and I write you from Chili. >> I have a Phoebe TV-Master+FM working fine with my redhat 8 system, I like to do some basic test and I need some basic "C" or "C++" example code about how to set and capture a image from the capture card and saved in some image format in my hard drive. If any of you have some basic sample code I very appriciate. >> For advance thanks. >> Mauricio Henriquez >> > > > > >-- >video4linux-list mailing list >Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe >https://www.redhat.com/mailman/listinfo/video4linux-list There is no substitution for hard work. Information is wealth.