transcode-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Original]

Re: [transcode-users] Recording from v4l2?


To: transcode Users Mailing List <transcode-users@xxxxxxxxx>
Subject: Re: [transcode-users] Recording from v4l2?
From: Erik Slagter <erik@xxxxxxxxxxxxx>
Date: Thu, 23 Dec 2004 12:04:37 +0100
Delivered-to: itdp@localhost
In-reply-to: <41C9B342.3010507@voicenet.com>
References: <20041220204843.GA10898@funk.gsky.dom><41C74E78.3090302@voicenet.com> <20041220234758.GA16821@funk.gsky.dom><41C7FC63.1060903@voicenet.com><1103628319.3552.20.camel@localhost.localdomain><41C818AA.9090100@voicenet.com><1103633229.3552.28.camel@localhost.localdomain><41C81E8F.2090804@voicenet.com><1103635883.3552.31.camel@localhost.localdomain><41C85A25.3020604@voicenet.com> <20041221234359.GB13306@funk.gsky.dom><41C8C15A.2020408@voicenet.com><1103713114.3297.14.camel@localhost.localdomain><41C96802.2010500@voicenet.com><1103719528.3297.48.camel@localhost.localdomain><41C97664.3000000@voicenet.com><1103723744.3297.61.camel@localhost.localdomain><41C9B342.3010507@voicenet.com>

On Wed, 2004-12-22 at 12:47 -0500, Adam K Kirchhoff wrote:
> I do have some experience with C, though it's been a number of years 
> since I took those classes in college.  I actually have a little bit of 
> free time coming up, so I'll take a stab at it and see what I can come 
> up with.

Something like this (not tested):

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <linux/types.h>
#include <linux/videodev2.h>

int main(char ** argv, int argc)
{
        struct v4l2_fmtdesc fmt;
        int fd, ix;

        
        if((fd = open("/dev/video0", O_RDWR, 0)) < 0)
        {
                fprintf(stderr, "cannot open video device\n");
                close(fd);
                exit(1);
        }

        for(ix = 0; ix < 100; ix++)
        {
                memset(&fmt, 0, sizeof(fmt));
                fmt.index = ix;
                fmt.type = V4L2_BUF_TYPE_CAPTURE;

                if(ioctl(fd, VIDIOC_ENUM_FMT, &fmt))
                {
                        perror("VIDIOC_ENUM_FMT");
                        close(fd);
                        exit(2);
                }

                printf("%x %c%c%c%c %s\n", fmt.pixelformat, (fmt.pixelformat >> 
24) &
255, (fmt.pixelformat >> 16) & 255, (fmt.pixelformat >> 8) & 255,
fmt.pixelformat & 255, fmt.description);
        }

        close(fd);

        return(0);
}


[Prev in Thread] Current Thread [Next in Thread]