Hauppauge HD-PVR on Linux - AVS Forum | Home Theater Discussions And Reviews
Forum Jump: 
Reply
 
Thread Tools
post #1 of 36 Old 09-24-2008, 11:10 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I've had the Hauppage HD-PVR for about a week now and tested it in both Gentoo and Debian Sid so I thought I'd post about some of the neat things you can do with this device with Linux.

Following the directions that can found at MythTV compiling the drivers on both systems was straight forward. Neither the stock Debian kernel nor my custom Gentoo kernel had any problems when I loaded the driver with modprobe, and running...

Code:
cat /dev/video0 > video.ts
...did indeed create a file playable with mplayer.

I experimented with both 1080i and 720p output from my STB and did find that playback of 1080i was very slow and barely watchable as I expected from the warning from the mythtv page, but I was also disappointed to see that 720p playback wasn't very good either. Mplayer spit out warnings that my machine was too slow as it struggled to play the file.

I had experienced similar errors playing back h264 video that were resolved by outputting my audio over spdif and letting my receiver decode the audio so I transcoded the audio to ac3 and placed the .ts file in a matroska container with...

Code:
ffmpeg -i video.ts -vcodec copy -acodec ac3 -ab 128k -f matroska video.mkv
...and was rewarded with perfect playback!

Cool, I can now record my favorite programs. But what about watching live tv? If ffmpeg can transcode a .ts file and the HD-PVR outputs a .ts file shouldn't ffmpeg be able to transcode the output of the HD-PVR on the fly? I decided to give it a try and opened another xterm.

In the first xterm I ran...

Code:
ffmpeg -i /dev/video0 -vcodec copy -acodec ac3 -ab 128k -f matroska video.mkv
...in the second...

Code:
mplayer video.ts
...and it worked! Perfect "nearly live" HDTV! Okay, but how to get "really live" TV? The answer, of course, was obvious since I already had the optical out from my STB hooked up to my receiver. Let mplayer decode the video and the receiver handle the audio.

Code:
mplayer -ac null /dev/video0
B-)

Time is what keeps everything from happening all at once.
EzInKy is offline  
Sponsored Links
Advertisement
 
post #2 of 36 Old 09-25-2008, 08:32 AM
AVS Forum Special Member
 
Troubleshooter's Avatar
 
Join Date: Aug 2001
Location: Southern Cowhampshire
Posts: 1,670
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Cool stuff..thanks for the tips!
Troubleshooter is offline  
post #3 of 36 Old 09-29-2008, 01:23 PM
Senior Member
 
djb61230's Avatar
 
Join Date: Dec 2004
Location: Whitesboro, NY
Posts: 469
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 9 Post(s)
Liked: 24
So what CPU do you have? I've played a few example files people have posted and had the same errors you did. I'll try your tips tonight at home but was still curious what CPU you had.

Thanks in advance.
djb61230 is offline  
 
post #4 of 36 Old 09-29-2008, 04:00 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by djb61230 View Post

So what CPU do you have? I've played a few example files people have posted and had the same errors you did. I'll try your tips tonight at home but was still curious what CPU you had.

I have an AMD 5400+ (2800mhz) in my htpc box with 4gb of ram and a Radeon X800 XT for video.

Quote:


Thanks in advance.

You're welcome B-). I'll be giving the new 5.1 support a try tonight and will be reporting back a little later.

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #5 of 36 Old 09-30-2008, 05:13 AM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Okay, I've done some testing of the 5.1 enabling firmware. The good news is that it works. The bad news is that it doesn't "just work", at least not yet.

After installing the new firmware, which of course required a boot into Windows to install, the hdpvr refused to load due to the wrong firmware version. Commenting out the firmware check in the driver code provided a temporary fix.

EDIT: The firmware version check is fixed in the latest driver available at mythtv.org B-)

I tested the driver with...

Code:
cat /dev/video0 > video.ts
...and as earlier obtained a playable .ts file, but there was no sound even though...

Code:
ffmpeg -i video.ts
...reported that there was 384kbs 5.1 ac3 audio in the file.

After taking another look at the driver source I noticed that there were other module options other than those presented on the mythtv site, so I reloaded the module with...

Code:
modprobe hdpvr default_audio_input=2
...and was rewarded with a file that played both audio and video in perfect sync when I again read from the device.

There are some problems, however. Both ffmpeg and mplayer freeze after just a few minutes when reading directly from the device, and I haven't been able to record anything longer than 30 minutes or so with cat. The HDPVR just goes dark in all those cases. Still, I think this is showing real progress and am looking forward to more updates from Hauppauge. And I will of course keep playing with mine B-)

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #6 of 36 Old 10-01-2008, 05:28 AM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
After numerous attempts I finally recorded a whole movie with 5.1. I used...

Code:
ffmpeg -i /dev/video0 -vcodec copy -sameq -acodec copy -f matroska video.mkv
...and it successfully made it through the whole film. Subsequent results have been sporadic, and I suspect that the disconnect issues may be usb bus related because programs seem to hang waiting for input. I tried testing with a simple C program that read from the video device a byte at a time and outputting to a file and never received an EOF when the HDPVR shut down.

Hope no one minds my thinking "out loud" here while trying to get things working in Linux B-)

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #7 of 36 Old 10-01-2008, 06:35 AM
AVS Forum Special Member
 
jimwhite's Avatar
 
Join Date: Sep 2001
Location: Saint Petersburg, FL USA
Posts: 5,366
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Keep thinking.....

Jim White
St. Petersburg, FL
jimwhite is offline  
post #8 of 36 Old 10-01-2008, 11:57 AM
Rgb
AVS Forum Special Member
 
Rgb's Avatar
 
Join Date: Apr 2000
Location: SE Michigan
Posts: 6,905
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 32 Post(s)
Liked: 23
Quote:
Originally Posted by EzInKy View Post

Hope no one minds my thinking "out loud" here while trying to get things working in Linux B-)

..that's the whole *point* of this forum

But seriously, this kind of thread reminds me of the "good ole days" of the main HTPC forum circa 1999-2002...
Rgb is offline  
post #9 of 36 Old 10-01-2008, 11:06 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Thanks jimwhite and rgb. Though I've managed two more uninterrupted full movie recordings I'm still plagued by sporadic freezes.

I tested my usb theory by disconnecting my wireless keyboard dongle and controlling my htpc with ssh, but the glitches continue. I have no other usb devices connected to that machine at present so I've been investigating other possible causes.

One action that is fairly consistent in causing the HD-PVR is channel changing. And I've also noted that with 2 channel broadcasts it still outputs aac even though I set the box to use ac3 for all recordings after I installed the firmware in windows.

According to the mythtv page the audio_encode variable is non-adjustable, but this may not be true anymore. I saw an audio_encode option in the driver source that uses a v4l constant so I plan on exploring the code a little more.

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #10 of 36 Old 10-02-2008, 09:56 AM
 
mythmaster's Avatar
 
Join Date: Mar 2008
Location: 255.255.255.255
Posts: 2,131
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Thanks for keeping us posted on this, EzInKy. I know I'm not alone in wanting to know the progress in stability for this particular device in linux.

I'll be moving in a few months and, sadly, expect that I won't be able to use firewire with my next cable provider (it will be missed ), so I'm hoping to use the HD-PVR with directv (in linux, of course).

The mythtv wiki page on this seems to be lacking in feedback, so, again, I'm grateful for your progress report here.
mythmaster is offline  
post #11 of 36 Old 10-12-2008, 03:07 PM
 
mythmaster's Avatar
 
Join Date: Mar 2008
Location: 255.255.255.255
Posts: 2,131
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
This is still relevant to my interests. Anything new?
mythmaster is offline  
post #12 of 36 Old 10-13-2008, 05:56 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by mythmaster View Post

This is still relevant to my interests. Anything new?

Sorry I haven't posted an update. After looking at the driver code I realized how rusty my 'C' was and have been doing a lot of brushing up. I used to write small programs years ago but it was mostly all DOS based and nothing but a hobby, so I was pretty much blown away and have been doing a lot of reading.

Anyway, after increasing a few timeout variables and having the driver default to SPDIF input and AC3 encoding at startup things are going better. Before I made those changes setting with the v4l2 tool had pretty inconsistent results.

The biggest problems, though, are still with the freezes. These occur nearly always with a channel change, but also occasionally when the audio signal changes as noted by the decoding indicator on my receiver. The HDPVR just goes "dark" when they occur, but will restart recording when the device is read from again.

The problem might be able to be taken care of in user space by providing adequate buffering and polling the device until data becomes available again, or perhaps even just closing and reopening the connection to give it time to adjust to the new signal.

That is the route I'm investigating now having armed myself with "Linux Programming Unleashed", "Advanced Linux Programming", and reading man page after man page.

EDIT:

Just wanted to add, the HDPVR is working well enough that I've been able to record a couple of more movies for timeshifted viewing later.

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #13 of 36 Old 10-13-2008, 07:02 PM
 
mythmaster's Avatar
 
Join Date: Mar 2008
Location: 255.255.255.255
Posts: 2,131
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Thanks, EzInKy. The force is strong in you!
mythmaster is offline  
post #14 of 36 Old 10-13-2008, 09:38 PM
AVS Forum Special Member
 
MichaelZ's Avatar
 
Join Date: Sep 2000
Posts: 2,024
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 52 Post(s)
Liked: 20
I got one of these in August (a really good deal) and I've yet to even hook it up! Mostly due to me dinking with my Popcorn Hour + Mythtv setup and also really nothing I even want to record I was going to use it as as-needed connection to my WinXP laptop and download whatever shows I wanted to archive from my DVR but I must be getting lazy
MichaelZ is offline  
post #15 of 36 Old 10-14-2008, 01:02 PM
AVS Forum Special Member
 
mastiff34's Avatar
 
Join Date: Jun 2004
Posts: 1,175
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
How is the popcorn hour?

Loganed on 4/8/2008

List to be completed
Install blinds - DONE
Finish plumbing my bathroom - WIP
Build EQ Shelves - WIP
Program insteon - DONE
My Build Thread
mastiff34 is offline  
post #16 of 36 Old 10-16-2008, 08:57 PM
Newbie
 
charlie_D's Avatar
 
Join Date: Oct 2008
Posts: 2
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Thought I'd toss in here; I'm running one of these as well. I'm wondering if you get any of the same issues I've had. When I have the HD-PVR plugged in and turned on, the system hangs on reboot. The code it spits out is a failure to initialize USB devices. If I have it off, it boots fine. If I connect it afterwards, it shows up fine and I can use it.

otherwise it's an interesting product, I hope it becomes a little more stable Hopefully we'll get IR support soon... otherwise the dinovo mini is starting to look tempting '

Charlie
charlie_D is offline  
post #17 of 36 Old 10-17-2008, 12:00 AM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by charlie_D View Post

Thought I'd toss in here; I'm running one of these as well. I'm wondering if you get any of the same issues I've had. When I have the HD-PVR plugged in and turned on, the system hangs on reboot. The code it spits out is a failure to initialize USB devices. If I have it off, it boots fine. If I connect it afterwards, it shows up fine and I can use it.

otherwise it's an interesting product, I hope it becomes a little more stable Hopefully we'll get IR support soon... otherwise the dinovo mini is starting to look tempting '

Charlie

I had the hang at boot issue happen just once and thought it was from one of the modifications I had made to the code. Since the driver works when probed after the machine is booted it could be a load order issue. As for IR support, yes that would be nice, but I would prefer firmware flashing support first.

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #18 of 36 Old 10-17-2008, 01:33 AM
Newbie
 
charlie_D's Avatar
 
Join Date: Oct 2008
Posts: 2
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
My mistake there, I wasn't too clear with what I meant. The failure is partway through bios initialization. It sounds like your lock up happened while booting the OS?

Answers my question, anyway It seems odd, since otherwise the device works as it should.
charlie_D is offline  
post #19 of 36 Old 10-17-2008, 07:35 AM
AVS Forum Special Member
 
MichaelZ's Avatar
 
Join Date: Sep 2000
Posts: 2,024
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 52 Post(s)
Liked: 20
Quote:
Originally Posted by mastiff34 View Post

How is the popcorn hour?


I like it a lot, so much so that I've got three of them now plus a TVix 4100 that I use when I travel. I was using UPnP from my Myth server but now I use mythrename.pl (with --link option) and it creates symbolic links from my Myth recording to my main video folder (where the other sym links are stored) so everything is unified from one video folder! I am currently modifying llink as my uPnP media server (which is hosted on the Myth server) and it works really well. I have the mythrename.pl ran nightly from my cron.daily folder and it keeps everything updated. So, I now have one video folder that contains my TV shows, Movies, DVD isos, etc.
Also looking to use Playon that allow Netflixs, Hulu.com, etc. to be streamed to the PCH box as well. Very sweet!
My wife and kids love it! Now I just need more disk space
I like the myth frontends but they were rather large boxes and a pain to keep up with esp. after any upgrades whcih always seemed to break something
MichaelZ is offline  
post #20 of 36 Old 10-17-2008, 05:38 PM
AVS Forum Special Member
 
waterhead's Avatar
 
Join Date: May 2007
Posts: 1,304
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 17 Post(s)
Liked: 12
Quote:
Originally Posted by MichaelZ View Post

I like the myth frontends but they were rather large boxes and a pain to keep up with esp. after any upgrades whcih always seemed to break something

The popular consensus is to never update a MythTV box once you have it running nicely.
waterhead is offline  
post #21 of 36 Old 10-17-2008, 10:45 PM
AVS Forum Special Member
 
newlinux's Avatar
 
Join Date: Oct 2006
Location: Parts unknown
Posts: 1,592
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 27 Post(s)
Liked: 17
Quote:
Originally Posted by waterhead View Post

The popular consensus is to never update a MythTV box once you have it running nicely.

amen!
newlinux is offline  
post #22 of 36 Old 10-18-2008, 07:24 AM
Member
 
eyager's Avatar
 
Join Date: Dec 2006
Posts: 162
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by EzInKy View Post

There are some problems, however. Both ffmpeg and mplayer freeze after just a few minutes when reading directly from the device, and I haven't been able to record anything longer than 30 minutes or so with cat. The HDPVR just goes dark in all those cases. Still, I think this is showing real progress and am looking forward to more updates from Hauppauge. And I will of course keep playing with mine B-)

Don't use cat! Cat will fail and exit if the video device reports a buffer overrun or any other IO error. DD is your friend.

Code:
dd if=/dev/video0 of=recording.ts conv=noerror ibs=1024
The conv=noerror tells dd to ignore read errors. I don't own an HD-PVR so the value for ibs (input block size) may have to experimented with.

Since you have an ATI graphics card you need to make sure the XVideo overlay is functional and mplayer is using it. ATI has disabled it by default with many cards. You have choose between XVideo support or OpenGL because you have to disable OpenGL to get XVideo. If you use OpenGL, mplayer has to do a color space conversion and software based brightness/contrast/hue/saturation controls which slows it down, especially with HD.
eyager is offline  
post #23 of 36 Old 10-18-2008, 09:19 AM
AVS Forum Special Member
 
Join Date: Sep 2004
Location: In the ATL
Posts: 5,150
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 2 Post(s)
Liked: 645
Quote:
Originally Posted by newlinux View Post

amen!

Ditto. Given the amount of time I invested to get mine tweaked the way I wanted it in summer '07, I ain't touching what ain't broke.
slowbiscuit is offline  
post #24 of 36 Old 10-19-2008, 08:39 AM
AVS Forum Special Member
 
MichaelZ's Avatar
 
Join Date: Sep 2000
Posts: 2,024
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 52 Post(s)
Liked: 20
Quote:
Originally Posted by waterhead View Post

The popular consensus is to never update a MythTV box once you have it running nicely.

You are correct but I was using 20.2 and my mythserver was still running on 6.06 LTS ubuntu and I needed to upgrade my mythserver since is also running older postfix, samba, mysql, etc programs not to mention a bunch of other hacks and a rather old kernel. Soooo, I bit the bullet and started the upgrade process, that turned out to be a pain but I had it all working nicely (after a couple of days of work). Along comes the PCH box and I see where it can replace my frontends, much like the media extenders for Sage and make my life easier (not to mention WAF) and so far it has.
Plus the added bonus of redeploying the myth frontend boxes, that are quite fast, to replace some older slower equipment. All is good .
MichaelZ is offline  
post #25 of 36 Old 10-19-2008, 04:13 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by eyager View Post

Don't use cat! Cat will fail and exit if the video device reports a buffer overrun or any other IO error. DD is your friend.

Code:
dd if=/dev/video0 of=recording.ts conv=noerror ibs=1024
The conv=noerror tells dd to ignore read errors. I don't own an HD-PVR so the value for ibs (input block size) may have to experimented with.

Thank you for the advice. I've been working on my own implementation using the capture_example.c that comes with v4l2 as a guide. The driver seems to report EINTR and EAGAIN correctly, but reports no error when the "freeze" happens.

Quote:


Since you have an ATI graphics card you need to make sure the XVideo overlay is functional and mplayer is using it. ATI has disabled it by default with many cards. You have choose between XVideo support or OpenGL because you have to disable OpenGL to get XVideo. If you use OpenGL, mplayer has to do a color space conversion and software based brightness/contrast/hue/saturation controls which slows it down, especially with HD.

Again, thank you for your advice. I'm pretty familiar with ATI cards as they are all I ever use do to the closed source nature of nVidia. I really wish Intel would make a decent descrete card.

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #26 of 36 Old 10-22-2008, 10:53 AM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Well, my little adventure into the world of Linux programming has paid off. I can now survive channel and audio changes while recording. The method I am using is not very sophisticated but it does produce a a playable .ts file with mixed 6 and 2 channel audio that mplayer has no problems playing back.

Here is a snippet of the source:

PHP Code:
while(1){
\
tretval poll(fds2POLL_DELAY);
\
tif(== retval){
\
t\tfprintf(stderr"Lost signal, restarting device...\
"
);
\
t\tclose(devfd);
\
t\tif(-== (devfd open(ifnameO_RDWR O_NONBLOCK))){
\
t\t\tperror("Unable to reopen the device");
\
t\t\texit(EXIT_FAILURE);
\
t\t}else{
\
t\t\tfds[1].fd devfd;
\
t\t\tfds[1].events POLLIN;
\
t\t\tcontinue;
\
t\t
All it does is close and reopen the hdpvr if it has no data available for more than a tenth of a second. As I said, not very sophisticated, but it works B-)

Time is what keeps everything from happening all at once.
EzInKy is offline  
post #27 of 36 Old 10-22-2008, 01:49 PM
 
mythmaster's Avatar
 
Join Date: Mar 2008
Location: 255.255.255.255
Posts: 2,131
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Very nice, EzInKy!

Have you submitted your code to the driver developers? I'm sure they'd love to hear from you.
mythmaster is offline  
post #28 of 36 Old 11-03-2008, 03:53 PM
Newbie
 
billydoom's Avatar
 
Join Date: Nov 2008
Posts: 1
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
EzInKy, could you provide more context for that code snippet? I'm attempting the same
thing and it's just not "clicking". Being able to see the whole wrapping function would
be great... I as well tried starting with the capture_example.c but it sounds like you've
been more successful.
Any pointers are greatly appreciated.
wxd
billydoom is offline  
post #29 of 36 Old 11-09-2008, 04:02 PM - Thread Starter
Member
 
EzInKy's Avatar
 
Join Date: Apr 2006
Posts: 36
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by billydoom View Post

EzInKy, could you provide more context for that code snippet? I'm attempting the same
thing and it's just not "clicking". Being able to see the whole wrapping function would
be great... I as well tried starting with the capture_example.c but it sounds like you've
been more successful.
Any pointers are greatly appreciated.
wxd

Yes, please don't laugh. I'm sure it needs a lot of work. No warranties!

PHP Code:
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>

#define MEMBUF_SIZE 4096
#define POLL_DELAY 100

int main(int argcchar *argv[])
{
\
tint retval;
\
tint devfd;
\
tint outfd;
\
tchar ofname[32];
\
tchar *ifname;
\
tvoid *membuf;
\
tssize_t nbytes;
\
ttime_t curtime;
\
tstruct tm *fmttime;
\
tstruct pollfd fds[2];

\
t/** allocate memory buffer **/

\tif(NULL == (membuf malloc(MEMBUF_SIZE))){
\
t\tfprintf(stderr"Not enough memory\
"
);
\
t\texit(EXIT_FAILURE);
\
t}

\
t/** check for optional device argument **/

\tif(argc 1){
\
t\tifname argv[1];
\
t}else{
\
t\tifname "/dev/video0";
\
t}

\
t/** open the device **/

\tif(-== (devfd open(ifnameO_RDWR O_NONBLOCK))){
\
t\tperror("Unable to open device");
\
t\texit(EXIT_FAILURE);
\
t}

\
t/** set the output file name to time of creation **/

\ttime(&curtime);
\
tfmttime localtime(&curtime);
\
tstrftime(ofname32"%Y%m%d%H%M%S.ts"fmttime);

\
t/** open the output file **/

\tif(-== (outfd open(ofnameO_CREAT O_RDWRS_IRWXU S_IRWXG))){
\
t\tperror("Unable to open output file");
\
t\tclose(devfd);
\
t\texit(EXIT_FAILURE);
\
t}

\
t/** setup descriptors for event polling **/

\tfds[0].fd STDIN_FILENO;
\
tfds[0].events POLLIN;
\
tfds[1].fd devfd;
\
tfds[1].events POLLIN;

\
t/** start the recording loop **/

\twhile(1){
\
t\tretval poll(fds2POLL_DELAY);
\
t\tif(== retval){
\
t\t\tfprintf(stderr"Lost signal, restarting device...\
"
);
\
t\t\tclose(devfd);
\
t\t\tif(-== (devfd open(ifnameO_RDWR O_NONBLOCK))){
\
t\t\t\tperror("Unable to reopen the device");
\
t\t\t\texit(EXIT_FAILURE);
\
t\t\t}else{
\
t\t\t\tfds[1].fd devfd;
\
t\t\t\tfds[1].events POLLIN;
\
t\t\t\tcontinue;
\
t\t\t}
\
t\t}else if(-== retval){
\
t\t\tperror("Polling failed");
\
t\t\tbreak;
\
t\t}else if(fds[0].revents POLLIN){
\
t\t\tfprintf(stderr"User quit\
"
);
\
t\t\tbreak;
\
t\t}else if(fds[1].revents POLLIN){
\
t\t\tnbytes read(devfdmembufMEMBUF_SIZE);
\
t\t\tif(nbytes){
\
t\t\t\tswitch(errno){
\
t\t\t\t\tcase EINTR:
\
t\t\t\t\tcase EAGAIN:
\
t\t\t\t\t\tcontinue;
\
t\t\t\t\tdefault:
\
t\t\t\t\t\tperror("Unknown");
\
t\t\t\t\t\texit(EXIT_FAILURE);
\
t\t\t\t}
\
t\t\t}else if(MEMBUF_SIZE == nbytes){
\
t\t\t\twrite(outfdmembufMEMBUF_SIZE);
\
t\t\t\tcontinue;
\
t\t\t}else{
\
t\t\t\tperror("Short read");
\
t\t\t\texit(EXIT_FAILURE);
\
t\t\t}
\
t\t}else if(fds[1].revents POLLERR){
\
t\t\tperror("pollerr");
\
t\t\texit(EXIT_FAILURE);
\
t\t\tbreak;
\
t\t}
\
t}

\
t/** clean up **/

\tclose(devfd);
\
tclose(outfd);
\
tfree(membuf);
\
treturn retval;


Time is what keeps everything from happening all at once.
EzInKy is offline  
post #30 of 36 Old 12-03-2009, 10:42 AM
Senior Member
 
SeijiSensei's Avatar
 
Join Date: Sep 2007
Location: Metro Boston
Posts: 471
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I chose to bump this thread rather than start a new one because this is just about the only information available on the Internet concerning the HD PVR and Linux. (The page for this device on the MythTV wiki is now blank!)

So have the people here had more experience with this device? Is the driver support improved? The HD PVR really looks like the only affordable option for capturing component HD from a digital set-top box that I can find. I'm fed up with the tiny disk storage of the Moto 6216 that FiOS provides and would like to find a better option for archiving HD programming off the encrypted channels.

Has anyone tried using a device like this with Windows running in a VM? I have a Win7 installation running in a Virtualbox VM that I could use if the native Linux support is more dicey. (No anti-MS flames, please )
SeijiSensei is offline  
Sponsored Links
Advertisement
 
Reply HTPC - Linux Chat

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off