Tyson,

For fun, I wrote the following program.  

Compile it using: 

   gcc timed_copy.c -o timed_copy

Use it like this:  

   timed_copy <input device> <output file> <time in seconds>

You can try it out with /dev/urandom like this:  

   timed_copy /dev/urandom ~/output.dat 5

That gets you 5 seconds of pseudo random numbers.  Whee!

When you try this out on your PVR-150 you may want to increase
BUFFER_SIZE. 

Also to make this more reliable, I would have put the write call in one
thread and the read call in another thread, increased the buffer size to
1 MB or more, and passed buffers between the two threads.

In that way most of the program's time would be spent blocked on the
read() and write() reducing the chance of a buffer overrun from the
video device.

Enjoy.

--R


On Wed, 2007-02-28 at 23:31 -0500, Rob Ludwick wrote:
> Tyson,
> 
> There looks to be some useful information here:
> 
> http://www.cs.duke.edu/~reynolds/pvr150/
> 
> It's not completely straightforward and it looks a bit on the old side,
> but the information is mostly there..
> 
> Apparently at ivtvdriver.org there's a command to tune your card to 
> a channel called ivtv-tune.  There's another called ivtvctl.  They look
> useful
> 
> Also apparently you just need to know which /dev device and pull the
> video off of it like this:
> 
> cat /dev/video0 > /path/to/file.mpg
> 
> It's my understanding that the output of ivtv driver is an mpeg
> stream.  
> 
> --Rob
> 
> 
> On Wed, 2007-02-28 at 20:48 -0500, Tyson Maxwell wrote:
> > All,
> > 
> > I have a Hauppauge PVR-150 and I am looking for a simple framegrabber.
> >  Eventually I may try and build a MythTV box, but for now I looking
> > for something simple and command-line based.  Basically I just want to
> > issue a command to record a specific channel for a given duration.  If
> > anyone knows of a good tool that will do this, please let me know.
> > 
> > Thanks,
> > -Tyson
> > 
> > _______________________________________________
> > Fwlug mailing list
> > [email protected]
> > http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org
> 
> 
> _______________________________________________
> Fwlug mailing list
> [email protected]
> http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>


#define BUFFER_SIZE 512

int main(int argc, char **argv) {

	if  ( argc != 4 ) {
		fprintf(stderr, "%s:  <input> <output> <time in seconds>\n ", argv[0]);
	exit(1);
	}
	else 
	{
		int secs;
		char * buf; 
		secs = atoi(argv[3]);
		int fd1, fd2;
		struct timeval now, fin;
		if (!secs)
		{
			fprintf(stderr, "%s:  Can't process time \n",argv[0]);
			exit(1);
		}
		buf = malloc(BUFFER_SIZE);
		if (!buf)
		{
			fprintf(stderr, "%s: Can't malloc() %d bytes.\n",argv[0], BUFFER_SIZE); 
		exit(1);
		}

		fd1 = open(argv[1], O_RDONLY);
		if (!fd1)
		{
			fprintf(stderr, "%s: Can't open %s for reading.\n",argv[0], argv[1]);	
		exit(1);
		}

		fd2 = open(argv[2], O_WRONLY | O_CREAT );

		if (!fd2)
		{
			fprintf(stderr, "%s: Can't open %s for writing.\n",argv[0],argv[2]);
		exit(1);
		}
		
	
		// Everything is sane so start running

	        gettimeofday(&fin, NULL);
		fin.tv_sec += secs;
		gettimeofday(&now, NULL);
		while (timercmp(&now, &fin, <)) {
			int sz = read(fd1, buf, BUFFER_SIZE);
			if (sz < 0) {
				fprintf(stderr, "%s: Error reading %s.\n",argv[0], argv[1]);
				exit(1);
			} 
		 	sz = write(fd2, buf, BUFFER_SIZE);
			if (sz < 0 ) {

				fprintf(stderr, "%s: Error writing %s.\n",argv[0], argv[2]);
				exit(1);
			}				 	
			gettimeofday(&now,NULL);
		}
	}	
}

_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

Reply via email to