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

Users browsing this thread: 1 Guest(s)
Phyrne
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!
Phyrne
Long time nixers
Not sure if any one'll take any interest, but here's how the footage ends up once posted to YouTube :)
venam
Administrators
I don't know if it's normal or not, however I feel like my eyes are not used anymore to reading black on white. I can barely read what is written on your blog post without my eyes to blur or to loose concentration. Good thing I read it when you posted it (I mean before you bumped with the video) .
The video is neat, no blur to shift between sound and image.
I remember watching a video about how the guy of 'irongeek.com' do his conference videos. (It's not really on the same subject but at least it can be useful for someone). Here is the link: http://www.archive.org/download/Outerz0n...rz0ne2.avi
Phyrne
Long time nixers
Thanks for the kind words guys! :D I'm very happy with the outcome, I'm learning how to use Kdenlive now so I can get some nice editing thrown in :)

Haha, oh venam, I do apologise ;D
Phyrne
Long time nixers
I have yet another update! I've added some new features and changes to the script, so for anyone interested, go see my new blog post :)

I'm still very new to shell scripting, and in my naivety, have probably done a horrible job on the sorting feature, so if anyone has a much simpler way of doing this, please let me know!