[Script] Hauppauge HD PVR capture script by Phyrne *Updated* - GNU/Linux

Users browsing this thread: 1 Guest(s)
Long time nixers
Just wrote up a new blog post and thought I'd share it here too :)

Keep in mind, this script is very specific to the equipment I'm using and my setup, however, it can easily be modified by anyone to suit their needs.

It'd be great to get some feedback or maybe even some suggestions on how to improve it, I'm still quite new to shell scripting (more elaborate than one-liners anyway)

I've played the Halo series for a number of years and, like many people out there, like to capture/record gameplay. After the release of Halo : Reach, I stopped playing. I really just don't like it one little bit, but, with all the news and excitement for Halo 4, I figured I'd get back on Halo 3 and start practising for its release.

Naturally, I'm going to be doing a lot of recording when I get my hands on Halo 4, and most probably uploading it to YouTube, so I wanted to set up my capture card with my current system. I have a Hauppauge HD PVR and fortunately, it actually has very good Linux support!

Now because I want capturing to be easy and painless, I decided to set up a script that will automate the whole experience for me, here's a break down of what my script does:

1. Check to see if my external hard drive is plugged in, if not, echo a message to the shell advising to plug the drive in and re-run the script, if it is... proceed to mount the drive.

2. Check to see if the hdpvr kernel module is loaded, if not; load it and continue.

3. Set the bitrate mode, the bitrate, the peak bitrate, brightness, contrast, hue, saturation and sharpness of the capture card's video source through the v4l control set.

4. Check to see if the capture card is plugged in (via USB) and active, if so; proceed to capture, if not; echo a message to advise that there is no signal being received, unmount the external drive and unload the hdpvr module.

5. Capture using ffmpeg; pull the video, pull the audio using AC3 encoding and compress them into a Matroska container.

6. Move the file from the /tmp directory to the external drive renaming it to the current date and time.

I figured I should probably explain a few things; first off this script is specific for my needs, so, if you're wanting to use it, by all means please feel free to modify anything you wish. I'm using an external drive to store captures as my system has limited storage space, once the captures have been moved over to the drive, I will then probably, at a later date, after editing and whatnot, plug the drive into my home server and keep the files on there (maybe just push them over sftp).

"Why not just record straight to the external drive?" I hear you ask, well, pushing video data at a high bitrate through USB doesn't exactly end up with the best quality, it hiccups a lot, so I'd rather simply write to my internal drive (SSD) and then export it over, nice and easy!

Other people who may be familiar with recording from the HD PVR in Linux might be wondering why I'm using ffmpeg. I see a lot of people using cat to pipe the input from the capture device into a .ts file. In my opinion, although this works, it's really not the best practice. I've found that the video quality is quite poor (a lot of motion blur), as much as I love cat for other means, it certainly doesn't keep up with ffmpeg, plus, as I mentioned, with ffmpeg you can compress your captures into a Matroska container, which means the overall filesize will be much smaller and amazing quality, not to mention a more compatible format.

So, if you're looking for something like this, here's my script. Just chmod +x to make it executable, then it's go time! I've assigned an alias in my .zshrc to it to make it even more simple :)

As always, feedback is appreciated!

Messages In This Thread
[Script] Hauppauge HD PVR capture script by Phyrne *Updated* - by Phyrne - 20-09-2012, 10:20 AM