Thursday, August 21, 2014

Raspberry Pi DVR - Software

In addition to the hardware for this project, I'll need software to make it all work.  For all intents and purposes, the only OS that runs on the Pi is Linux - which is fine by me.  I first learned Linux back in college only a few years after the OS was created.  Yes, my Linux "skills" are no where near my Windows "skills," but I know enough to be effective in the OS.

My ultimate goal is to create a DVR, so to make that happen I need TV recording software.  So far the only software I've found that supports this task is "tvheadend."  If I go with my stretch goal of a full-blown media center, then I'll need a software package to play videos and media content.  Here I have several options, but in truth there is really only one contender - XBMC (soon to be renamed "Kodi").

Linux is different than Windows in that you can get Linux from many different sources, each source being custom tailored for a different use.  Each of these different versions is called a "distro."  For the Raspberry Pi I have 5 different distros that I am considering.  One may work better than another with the hardware I have and the goals I'm trying to accomplish.  So my plan is to try all 5 distros and report back on each.  I'll blog about each distro in a separate page as I test with them.  But here's an overview of the 5 distros I'm going to try.

Raspbian
Raspbian (a.k.a. Wheezy) is pretty much the default OS for the Raspberry Pi.  If you're looking to use the Raspberry Pi as a general computer; web surfing, checking emails, word processing, programming, etc. then you'll most likely use Raspbian.  It has a friendly graphical user interface along with support for a lot of hardware and software packages.  My guess is all new Pi owners should at least start here, to get a feel for how the hardware and software works before moving onto more specialized options.

Raspbmc (soon to be renamed OSMC)
As stated above, XBMC is the preeminent media center application for the Pi.  Whereas you can install and run XBMC on Raspbian, with so many resources used by the OS it sounds like it will run sluggishly and/or have issues.  Enter Raspbmc - one of several distros dedicated to running XBMC on the Pi.  Raspbmc is built on top of Linux, but it is built specifically to run XBMC.  Anything in the OS that is not needed by XBMC has been removed.  What's more, the creators have taken the time to add drivers and support for hardware specifically used by media centers.  Hardware like TV tuners, remote controls, etc.  The trade off is these media center distros are not general purpose computers.  You cannot check email, surf the web, etc.  In fact, when you power up the Pi it boots directly into XBMC.

OpenElec
OpenElec is another dedicated media center distro for the Pi.  It sounds like OpenElec is Raspbmc taken even further.  Even more of the unused parts of the OS have been removed making OpenElec tiny and fast.  It sounds like OpenElec is even faster than Raspbmc, but at the cost of customization.  If OpenElec has support for your hardware then you're golden, but if not it sounds like your only option is to download the sources and recompile OpenElec yourself - not for the faint of heart.

Xbian
Xbian is the last of the dedicated media center distros I'm going to look at.  From what I've read, Xbian sounds like a cross between Raspbmc and OpenElec.  It's got the speed of OpenElec with the customization and flexibility of Raspbmc.

RetroPie
The last distro is completely different from the others in that it is not for media but is designed to play retro video games.  It's basically a collection of computer and video game emulators as well as free and open-source video games from the 70s, 80s, and 90s.  Assuming I connect the Pi to my TV (and not headless in the garage) this would be a fun distro to have on hand for playing "old-school" video games.


That's a summary of the 5 distros I plan to look at.  Not having tried the distros, only going by what I've read on the Internet, it sounds like OpenElec and Xbian are the most promising for my goal.  I think it all boils down to if these two distros have drivers for my hardware, and if not then I'll have to research how to add that support.

As I said, I plan to run all 5 distros and report back on my findings and impressions of each.

Monday, August 18, 2014

Raspberry Pi DVR - Hardware

To continue my chain of posts, after some research in the hardware necessary to turn a Raspberry Pi into a DVR I purchased the hardware.  Below is what I ordered:

Raspberry Pi model B+

Obviously the most important piece is the Raspberry Pi itself.  For this I went with the newly released model B+.  The model B+ has the exact same CPU, graphics core, RAM, and networking as previous models.  Where the model B+ really shines is the extra USB ports and improved power.  The improved power circuitry means I should be able to avoid using an external hub (pretty much required on all previous models) and also consumes less electricity so it costs less to run.

SD card

For the micro SD card I went with a 16GB Samsung EVO micro SD card.  I chose those card because it's rated as one of the fastest micro SD cards available, so that should help to speed up the Pi.

Power supply

In order to take advantage of the model B+'s improved power circuitry to power USB devices without a hub, you need a sufficiently powerful micro USB power adapter - specifically you want one that can deliver at least 2 amps of power.  I went with this adapter, it got great reviews and was relatively cheap.

TV tuner

Probably the hardest part about this project is the TV tuner.  You need a "stick" USB tuner to be able to receive TV signals.  But TV tuners and Linux don't seem to play well together.  There aren't many TV tuners on the market to begin with, and even fewer that work with Linux.  What's more, where you are in the world will dictate what type of tuner you need.  Most of the world uses DVB-T, but North America uses ATSC.  So shop for a tuner accordingly.  In the end, I went with the Haupauge 950Q.  New this item costs $70, but I purchased a used one on eBay for less than half that.  Before selecting your tuner you might want to read this list of TV tuners known to work in Linux, and this list of hardware known to work with the Raspberry Pi.

WiFi adapter

Although the Pi has built-in ethernet, I want to locate the Pi far from my router.  So I'll need a USB wireless adapter.  As with TV tuners, it's important to find one that works with Linux and/or the Pi.  Here's a list of hardware known to work with the Rapberry Pi.  I went with the Rosewill RNX-N180UBE.  I chose this model for several reasons.  First, the large antenna should provide a good signal from the garage.  Second, it was listed as working out of the box with the Raspberry Pi (less setup headache).  And finally, it's listed as an N300 adapter for greater speed.  However, I'm disappointed on this last one.  After receiving the adapter the manual clearly states the download stream is N300 but the upload speed is N150.  I thought I was mislead by Newegg/Rosewill, but after reading the product specs online closer it does say this.  So the fault is my own.  This is still the adapter I want. I just wish it were N300 both directions.

Heatsinks

From what I can tell, the Pi does not need heatsinks.  And it sounds like heatsinks will only lower the temperature by a couple of degrees.  That said, I did purchase a set of copper heatsinks.  In all my years of working on computers I've never experimented with overclocking nor heatsinking options.  So I'm going to experiment on the Pi with those.  And it's that the whole idea behind the Pi - to experiment, learn, and have fun?

Case
Technically the Pi doesn't need a case.  But it's a good idea, if for no other reason than to prevent shorts against metal.  I haven't purchased my case yet, but I like the look of this case.

HDMI cable
I do have several 6' HDMI cables, but I wanted something shorter.  So I purchase this 3 pack of 3' HDMI cables from amazon.

Keyboard, mouse, and monitor
Fortunately I have plenty of spare keyboards, mice, and monitors to choose from.  You will at least need a keyboard, mouse, and monitor for initial boot.  After that you can remotely connect to the Pi eliminating the need for these.  So you probably don't want to buy this hardware for a project, just borrow them from another use for a short while.

Raspberry Pi DVR

Many people have heard of the Raspberry Pi - it's a small low-power computer with a low price tag of $35 (or $25 for the lower model).  The whole idea behind this concept is it's a platform to learn, tweak, and experiment from.  Since they first went on sale 2 years ago I've wanted one, but I've needed a project or idea, something to do with it.  Recently I figure out what that idea is - I want to build a cheap low-power DVR for over the air (OTA) broadcast TV.  With this broad goal in mind I started my research.  Whereas projects with the Raspberry Pi are well documented on the Internet, my experience is any time you're dealing with Linux, unless your setup exactly matches a known working setup then you might run into issues which you need to work through.  Anyway, I wanted to do a series of posts on my blog about my progress towards this goal.  Hopefully if someone else is considering this project with a Raspberry Pi they will find these posts helpful.

First I wanted to elaborate more on my ultimate goal.  Since cutting the cord and dropping cable TV about 7 years ago, my only source of TV is OTA broadcast.  With an antenna I receive 9 channels, and whereas I don't watch much TV, there are a few programs that I enjoy.  The problem is timing, the shows are on at a time when I can't watch.  So I need a simple DVR to record the shows so I can watch them at my convenience.  This is typically called "time-shifting."

The most well-known time-shifting device is the TiVo.  The problem with a device like this is two-fold.  1) they are expensive, especially when you add in monthly fees; and 2) these devices usually require cable and/or satellite TV.  That said, there are a few commercial exceptions.  Channel Master makes a product called the DVR+ which is a DVR designed for OTA broadcast TV.  This device costs even more than a TiVo, but doesn't have monthly fees.  Another interesting product is the HDHomeRun.  This tiny box (with a street price of $100) can record TV shows and stream them to a network drive.  I already have a NAS (network attached storage) device in my house, so this is an enticing product.

In the end, I decided to go with the Raspberry Pi.  In effect I want to create my own version of these devices.  Even through the Raspberry Pi is only $35, this route is by no means cheaper.  When all is said and done, I estimate the hardware to cost about $150 including shipping and tax.  So it's definitely more cost-effective to go with the HDHomeRun.  But that is a single use device, whereas the Pi is a fully functional computer which means you can do more, and it will have more configuration options.  Plus using the Pi is just cool and more fun!  I'm more looking forward to the process of getting this to work than I am in using the end product.  I know that sounds weird, but as an engineer I've always enjoyed the work more than the end result.

Anyway, back to the goal of creating a time-shifting DVR.  My original plan was to mount the Pi with an antenna into an out of the way place like the garage.  The Pi would be headless (no keyboard, mouse, or monitor) so I would control it from another computer.  All the Pi would do is record TV shows of my choosing and save the output to my NAS box.  This was my original goal, but now I'm kicking around some additional ideas.  We have 3 TVs in our house, 2 of which are "smart TVs" but the main TV in the living room isn't.  So I thought if I put the Pi by that TV and connect it to the TV via HDMI, then that Pi could be multipurpose.  In addition to recording TV programs for all the TVs, it would also be a media server for that TV - allowing me to watch both my recorded TV shows as well as the wealth of free streaming content available on the Internet.  As an added bonus, I could use the Pi as an emulator and game station for playing retro video games on the big TV.

So my initial goal is as a headless DVR.  But once that is up and running I'll look at turning the Pi into a full-blown media center.

Tuesday, August 5, 2014

Intel graphics - still not up to par

There are basically 3 companies that control the computer graphics market; Intel, ATI (a.k.a AMD), and nvidia.  Total these 3 companies have something like 99% of the market, so you have to try very hard to find a computer with another chipset.

Intel owns the commanding share, greater than 50%.  But they don't own this much because their product is better, but because embedded graphics are cheap and most computer manufacturers go with that option.  It's long been know that Intel graphics are basically unplayable in 3D games.  You'll get such low frame rates that if you want to do any gaming you need ATI or nvidia.  Because of this, for more than a decade I've always spent the extra money for a dedicated graphics card.  That said, Intel has put forth some major effort into improving the graphical capabilities of their cards, probably due in large part to Windows Vista/7 and the aero glass effects.  This improvement combined with the fact that I don't have time to "game" at home on my computer has lead me to build several computers lately using the default Intel graphics.

Well I can say, Intel still has work to do here.  The problem isn't so much the graphics performance.  I was able to play some older games just fine.  No, the problem is graphical stability and glitches.  On one system, if the computer went into standby power mode, when coming out of power standby Windows had graphical glitches.  The text on many Windows was gone never to return, and the mouse would sometimes track slow or jump around.  On the second machine, it would experience random HARD reboots - typically during graphical applications such as watching a video.

In both of these cases, installation of an nvidia card cleared up the problems.  On the first machine I suspect the problem is driver related, but I have installed the latest and greatest version of the driver.  The second machine (hard reboot) is a hardware problem.  Either way, Intel still has work to catch up here.  I'm hopeful Intel will fix these problems and continue to close the gap in performance just because they hardware is so common.  I guess you could say they are the slowest person on the team, but the team can't finish until the slowest person crosses the line.  So we all benefit from a better performing Intel graphics.

Tuesday, July 29, 2014

Forgotten Windows Password

Recently at work a server lost contact with it's domain which invalidated all domain accounts on the machine.  So the only way to login was using a local account, of which there was only one - the local administrator.  The problem is, no one knew the password, it had been almost a decade since the local admin account had been last used.  So is there a way to recover from this type of problem?  Turns out the answer is yes - and it's so easy it's almost scary.

What you need is a program called OphCrack.  Windows stores users passwords as hashes, and OphCrack cracks the password by comparing the password hash against pre-generated hashes stored in what they call "rainbow tables."  OphCrack can be run in two different ways.  Probably the most common is from a "live CD."  Once you burn the CD you boot the computer from that CD, from there OphCrack does everything automatically - it finds the registry hives storing the password hashes, begins the cracking process, and displays the results.  The other way to run OphCrack is on your computer directly.  This is useful if you can login to one account but need to crack another account's password.  You can also load up the registry hives of a computer - I believe it requires the SYSTEM, SAM, and SECURITY registry hives.

The scary thing is how quickly and easily OphCrack can work its magic.  Using the default tables it was able to crack the password in 7 minutes and 2 seconds!

There are other methods to crack your password, or otherwise login to an account without knowing the password.  But OphCrack is the easiest and least invasive I've seen.


I wanted to be clear here, this is not a security flaw in Windows.  Similar software exists for Linux and Mac, so anyone computer can be hacked into.  It's taking advantage of your relatively weak password.  If you're paranoid about this type of thing, what can you do to prevent it?  Below are some tips that will help prevent this type of attack (if you're concerned about such things).

  1. Use disk encryption.  Windows, Linux, and Mac all have software that can encrypt the disk.
  2. Use long passwords and at least one symbol or extended character.  OphCrack works by having pre-calculated hashes for shorter passwords (up to about 10 characters) and using letters and numbers.  Since this covers 99% of the passwords people use, this works most of the time.  But if your password is longer and uses special characters (e.g. '^' and '&') the possible number of passwords increases exponentially and so does the time to crack.
  3. Do whatever you can to ensure physical security of the computer.  Once someone has physical access to your computer, there's almost no stopping them.  Even if you have a long password, they may not be able to crack your password but they can still access your files (unless you used disk encryption).  Of course, if your computer is a laptop, tablet, or phone and you lose it or it's stolen - well consider your data compromised.

OphCrack is a cool little program that helped us login to this server.  Tools like this are not merely "hacking" tools but they do have useful purposes.

Monday, July 21, 2014

What a real quality pair of headphones looks like

I see a lot of people these days walking around listening to their Beats Audio headphones.  Every time I see that I think "idiot - you fell for their marketing ploy and spent way too much money on sub-par headphones."  Now that's very judgmental for me to say that, especially since I've never actually listened to a pair of Beats.  But I have listened to true high-quality headphones, and I've read enough reviews (e.g. here and here) to know that Beats is popular strictly because of a great marketing engine.  They have created this illusion that their product is great and desirable and as such, anything with their name and logo can command top-dollar prices.

Several years ago I purchased a pair of Sennheiser HD 590 headphones.  I'm going to talk about these headphones.  Again, I've never listened to Beats so I can't do a direct comparison, but I suspect Beats has few, if any, of the the following features.  I guess you could think of the following as a way to design the best headphones, the feature to include that give you a truly great product.


The first thing you notice with a pair of headphones like this is how comfortable they are.  The strap across the top of the head is fully padded, but most importantly the ear pieces very softly padded.  They are also large and fit around the ear instead of lying flat on the ear.  This makes them very comfortable for long periods of time.  Another great feature of these headphones is they are an "open" design.  An open headphone is one that allows both air and noise to pass through the headphones.  While wearing these headphones you can still hear the world around you as clearly as without the headphones.  This has one major benefit when it comes to comfort.  A typical "closed" headphone tries to isolate you from the sound world around you.  To do this, the ear cup must be pressed against your skull to try and block a lot of noise.  Since the open design is not trying to isolate you, the ear cups do not need to squeeze onto your head.  The end result is a VERY comfortable headphones.  You can listen to these for hours and never feel like you need to remove them to give your head and ears a break.

Another great feature is the thought that went into the wire.  Many headphones have one wire coming out each ear, whereas these headphones have a single wire on one side.  You don't realize how much the two-wire design gets tangled up until you use a single wire design.  Sennheiser also has a detachable wire at the ear piece.  So if the wire gets caught on something it won't rip the headphones from your head, instead the wire just comes unplugged.  They even include the adapter to let you listen to 1/4" headphone jacks in addition to the standard 1/8" jacks.  And to top it all off, all connectors are plated in gold which prevents them from oxidizing over time.  You could argue that good headphones should be wireless, but a wireless design has circuity in them and, more significantly, lots of battery.  Both of which add weight to the headphones which makes them less comfortable to listen to for long periods of time.  It also adds the hassle of having to charge them.

But the list of top quality features and components doesn't stop there.  The speakers use Neodymium magnets, which are the strongest known magents and produces better sound.  Also, all the wiring in the headphones is oxygen-free copper (OFC).  This is copper that has been smelted in a special way to prevent oxygen from bonding to the copper.  It's a more pure form of copper, it transmits electricity better than regular copper, which again results in better sound quality.  Both OFC and Neodymium cost more money which is why few manufactures use it.

Another great feature of Sennheiser headphones is the company support.  Sennhesier has been around for decades, and they support all of their products for a long time.  You can buy replacement parts for their products decades after the product was last manufactured.

To sum up, these Sennheiser HD 590 headphones are the most comfortable and best sounding headphones I've ever used.  It goes to show you when a company takes the time to design a truly great product, the results speak for themselves.  Of course, headphones like these aren't cheap.  I forget how much I paid for them, but it was about $300.  And that's where Beats headphones rub me the wrong way.  You can spend that much and more on Beats, and do they offer any of these features?

The one thing I've read over and over about Beats is they offer bass and volume.  Well if you want crappy bass and high volume from an overpriced headphone, by all means order some Beats.  But if you want good quality music with properly represented bass then look for a high-quality brand like Sennheiser or Grado.

Recently it was announced that Apple is buying Beats.  To me this perfectly sums up the point I'm trying to make.  To me, Apple is the pinnacle of average hardware that commands extremely high prices because their marketing department has convinced people "it's worth it."

Wednesday, July 9, 2014

PKZip through rose-colored glasses

PKZip is a piece of software that I've looked fondly upon - until recently.  Most computer users are aware of PKZip (a.k.a. just "zip") which is probably the most common and ubiquitous file compression format.  It's been around since the late 80s and is extensively used in computers - so even if you don't directly use this format I can pretty much guaranty many of the software and services you rely on do use this format.  And what's not to love about this format?  It offers very good compression, it's fast, and it's royalty free unlike some other compression software.

Well, it turns out not everything is peachy-keen in Zip-land.  Recently at work I've had the need to directly read and write zip files.  I cannot rely on existing code to read and write the zip file for me, I must do it myself.  Fortunately the actual compression and decompression code I don't have to write, but all the metadata inside the zip file I must write myself.  Basically the internal structure of a zip file is a lot of smaller structures that contain file into such as compressed/uncompressed sizes, filename, attributes, etc.  These structures also point to relative positions of other structures in the file, etc.  This is all standard stuff if you've ever written code to process a binary file.  So what's the problem then?  Simple, the way these structures are laid out is horrible.  You have to start off parsing the file from the end which is counter-intuitive, some structures have signatures ids whereas others do not, the contents of structures varies depending on bit flags, etc.  But by far the biggest headache is the zip64 extensions.  The original zip format cannot handle large files, so they had to extend the format to support 64-bit file addresses.  I understand they wanted to maintain backwards compatibility, but what they should have done was create a new format and zip/unzip tools would adjust accordingly.  It would actually be the same code to maintain backwards compatibility, just where that code goes would have been different.

Oh well, I can't fault them too much.  I mean the zip format became wildly popular, probably more popular than they had ever anticipated.  They might have put more thought into the design had they known.  Also, it would have been hard to foresee the need for 64-bit support back in a time when hard drives were only a few megabytes in size.

PKZip has definitely stood the test of time.  But its age is showing.  Newer formats like Rar and 7Zip offer better compression ratios.  Personally I would recommend 7Zip.  But zip is so ubiquitous it's going to be around for a while.  I just wish the internals of the file weren't so bad.