Saturday, October 22, 2011

Arch Linux on a Pogoplug

The hard drive that I was using for Time Machine died (I/O errors), so I went to Best Buy to get a new one.  While I was there, I noticed that they had a Pogoplug which I also purchased. 

Although the box said the model number was a POGO-P21 (which is the model number for the Pogoplug v3), the sticker on the Pogoplug itself said that it was a POGO-E02 (Pogoplug v2). While the v3 has a faster processor, the v2 has more memory (256 MB vs 128 MB).  I didn't notice until just now that I could have installed Optware on it and kept access to my.pogoplug.com.  Instead, I installed Arch Linux ARM on it (on a 2 GB flash drive).  In retrospect, I probably could have done what I wanted with Optware, but since I already have Arch Linux working, I'll probably leave it as is.

I used pacman to install ffmpeg on the Pogoplug and configured my netcams to upload to it instead of my Western Digital MyBook Live since the ffmpeg binary on Arch Linux includes the mpeg4 and H.264 codecs where as the MyBook does not.  Encoding to H.264 is too slow, so I'm encoding to mpeg4 (I was encoding to motion jpeg on the MyBook).  Although I am storing the images and videos on a 16 GB flash drive (formatted ext2 to reduce flash wear), I'm uploading the compressed files once a night to the MyBook for easier remote access and more permanent storage.

Friday, October 21, 2011

More efficient NAS backups using Carbon Copy Cloner

By default, when backing up to a sparse bundle disk image, Carbon Copy Cloner uses a band size of 8MB. This might be already for use on a local disk, but seems to cause a slow down when reading from a mounted drive on a NAS such as the Western Digital MyBook Live.  This is probably due to have so many files in the band directory of the bundle.  To rectify this, one can create the sparse bundle ahead of time by doing something like this:

hdiutil create -verbose -type SPARSEBUNDLE -size 1T -imagekey sparse-band-size=262144 -fs HFS+J -volname myVolume myVolume
 This will increase the band size to 128 MB which should improve performance.

Point Carbon Copy Cloner to this pre-created disk image when doing the backup.

Friday, September 23, 2011

DD-WRT VPN client with MacOS X and iOS

With build build 14896, the VPN client doesn't seem to work by default with MacOX X 10.7 or iOS 4.3.  To get it working, go to Administrations->Commands, and add the following to what runs on Startup (Save Startup) and then restart the router:

echo 'noaccomp' >> /tmp/pptpd/options.pptpd

Note:  if you make any changes in DD-WRT's web interface that may a cause the options.pptpd file to be rewritten, you might have to restart the router.

Monday, September 19, 2011

Blocking WD MyBook Live incoming connections


The MyBook Live allows remote access the the hard drive via the WD 2go iOS app.  One thing I don't like about it is that it pokes a whole via UPnP on my firewall for ports 80 and 443.  And unfortunately on dd-wrt, UPnP port forwarding takes precedence over any other rules on the FORWARD chain.

So, I manually added a rule via Administration->Commands (Save Firewall) in dd-wrt:

iptables -t nat -I PREROUTING -p tcp -i `get_wanface` -m multiport --dport 80,443 -j DROP

"iptables -L" doesn't show prerouting rules.  Instead, do: "iptables -L -t nat".

Since the MyBook Live runs Linux internally, there might be a way to change the ports through some manual unsupported mechanism, but haven't had a chance to check.  Hopefully Western Digital creates a firmware update that allows the port to be changed via a supported mechanism in the web UI.

Saturday, September 10, 2011

Dripping shower

My upstairs shower was occasionally dripping a little.  A while back, I had fixed a similar problem with my downstairs shower by replacing the Price Pfister valve assembly and cartridge/pressure balance with a combo unit (part number 974-042).  This was evidently the wrong part.  Although it worked alright, it caused the handle and wall flange to stick out a bit.  I think this was due to the fact that the shower is a pre-1997 unit (either model 08, 808, 0X8 or R89).  According to this FAQ, the correct part numbers are actually 971-250 for the valve assembly and 974-291 for the cartridge/pressure balance.

So, I ordered the parts and replaced them.  The shower appears to be working ok.

Monday, September 05, 2011

Compressing network camera images on a WD My Book Live

I have two Panasonic Network Cameras that are setup to ftp images via timed and motion sensor triggers to a Western Digital My Book Live NAS.  This device runs Linux. Information to gain ssh access can be found here.  The device has perl and a stripped down version of ffmpeg pre-installed.

Below is a quick and dirty perl script that will take the images uploaded from the network cameras and generate QuickTime files from them.  Unfortunately the ffmpeg binary that is pre-installed has limited codec support, so the QuickTime file is just using the mjpeg codec.

UPDATE (9/5/2011 1:00pm): Modified framerate of QuickTime file and changed the threshold for including motion image files.


#!/usr/bin/perl -w

use strict;
use Time::Local;
use POSIX;
use File::Copy;

# crontab:
# 5 0 * * * cd /DataVolume/shares/Netcam; perl -w compress_to_mp4.pl >>compress_to_mp4.log 2>&1

my $root = '/DataVolume/shares/Netcam';
my @dirs = ("$root/pancam1/motion",
            "$root/pancam1/timer",
            "$root/pancam2/motion",
            "$root/pancam2/timer");

foreach my $dir (@dirs) {
  my $stoptime;
  $stoptime = time();
  $stoptime = timelocal(0, 0, 0, (localtime($stoptime))[3], (localtime($stoptime))[4], (localtime($stoptime))[5]);
  my $threshold = 60*60*24;
  my ($type) = ($dir =~ m!/([^/]+)$!o);
  if ($type eq 'motion') {
    $threshold = 60*10;
    $stoptime = 0;
  }
  if (opendir (DIR, $dir)) {
    my @filenames;
    while (my $filename = readdir(DIR)) {
      push @filenames, $filename if $filename =~ /\.jpg$/o;
    }
    closedir (DIR);
    @filenames = sort @filenames;
    my %batches;
    my $laststart = 0;
    my $lastts = 0;
    foreach my $filename (@filenames) {
      my ($year,$mon,$mday,$hour,$min,$sec,$msec) = ($filename =~ /(\d{4})(\d{2})(\d{2})s(\d{2})(\d{2})(\d{2})(\d+)\.jpg/o);
      my $ts = timelocal($sec, $min, $hour, $mday, $mon-1, $year);
      next if $stoptime && $ts>$stoptime;
      if ($ts - $lastts > $threshold) {
        $laststart = $ts;
      }
      $lastts = $ts;
      push @{$batches{$laststart}}, $filename;
    }
    foreach my $ts (sort keys %batches) {
      if (! -d "$dir/tmp") {
        mkdir("$dir/tmp");
      }
      my $count = 1;
      my @tmpfiles;
      foreach my $filename (@{$batches{$ts}}) {
        my $tfilename = sprintf("tmp%08d.jpg", $count);
        my $tpath = "$dir/tmp/$tfilename";
        push @tmpfiles, $tpath;
        copy("$dir/$filename",$tpath) or die "copy failed $!";
        $count++;
      }
      next unless scalar(@tmpfiles) > 1;
      my $outdir = "$dir/../$type" . "_video";
      if (! -d $outdir) {
        mkdir($outdir);
      }
      $outdir .= strftime("/%Y%m%d", localtime($ts));
      if (! -d $outdir) {
        mkdir($outdir);
      }
      my $ofilename = strftime("%Y%m%d-%H%M%S.mov", localtime($ts));
      my $out = `ffmpeg -y -r 3 -vcodec copy -i $dir/tmp/tmp%08d.jpg $outdir/$ofilename 2>&1`;
      if ($out =~ /error/om) {
        print "$out\n";
        die;
      }
      foreach my $filename (@tmpfiles) {
        unlink($filename);
      }
      foreach my $filename (@{$batches{$ts}}) {
        unlink("$dir/$filename");
      }
    }
  }
}

Dynamic widths for blog template

Add the following CSS to the template for dynamic widths:


html body .content-outer {
max-width: 90%;
}

Thursday, August 11, 2011

MailRaider

I needed to read an Outlook .msg file that was attached to a Help Desk ticket.  Using MailRaider, I was able to see the message and retreive the attachments inside.

Wednesday, July 20, 2011

Initial MacOS X 10.7 Lion Notes

In System Preferences:
  • To change the mouse scrolling behavior to how it use to behave in prior versions, uncheck "Move content in the direction of finger movement..." in the Mouse panel.  It might be worth leaving it checked if using a track pad or Magic Mouse.
  • To always show scroll bars, change the "Show scroll bars" options in the General panel.  Unfortunately, there isn't a way to add scroll arrows.
In order to show harddrive/directory information (number of items and free disk space) in the Finder, toggle on "Show Status Bar" under the View menu.

The default location which Finder windows opens is now "All My Files".  To change it, look under the Finder preferences, and change the location listed under "New Finder windows show" in the General tab.  I have mine set to Applications, although I used to have it set to my home directory.

To install Java, launch any Java application from the Finder.  For example, Java Preferences under Applications/Utilities.

There are a bunch of new high quality voices in multiple languages when customizing the System Voice in the Speech System Preference panel.  They will auto download if selected and are quite large.  The foreign languages seem to be all high quality.  For U.S. English, Jill and Tom are the high quality ones.

After installing, it takes a long time (and lots of churning of the hard drive) to rebuild the Spotlight database.

Sunday, May 22, 2011

Strange audio problem with Denon AVR-790 Receiver

I was watching a Blu-ray on my PS3 when my Denon AVR-790 receiver started making clicking noises and the audio stopped.  I tried switching to different input sources on the receiver (including the radio tuner) and still no audio output.  I went into the menu, and the option to generate test tones was missing.

After doing some research, I tried blowing into the headphone jack and audio started outputting from the speakers.  Evidently the receiver must have a very sensitive headphone jack and some dust must have caused it to think that headphones were plugged in.  Seems ok now.

Monday, May 09, 2011

The Invasion Begins

Today, the cicadas of Brood XIX started re-emerging in Nashville.  This is the brood that last emerged in 1998.

Saturday, April 02, 2011

Extracting video with subtitles from an MKV file

Although Handbrake can convert MKV files and burn the subtitles into the video stream, it does not handle fancy SSA subtitles very well.  The only program that I've found that seems to render SSA subtitles very well is mplayer.  I used mplayer and x264 to convert by running the following:

mplayer -ass -nosound inputmovie.mkv -vo yuv4mpeg:file=>(x264 --demuxer y4m --qp 15 --bitrate 2500 --profile main --level 5.1 --preset slow  -o outputmovie.mp4 -)
 This also works:

mplayer -ass -nosound inputmovie.mkv -vo yuv4mpeg:file=>(x264 --demuxer y4m --crf 15 --profile main --level 5.1 --preset slow  -o outputmovie.mp4 -)

I used the Main H.264 profile with a high level instead of using the High H.264 profile since the High profile resulted in the video starting with a gray screen and other artifacts when viewing via Quicktime.

Tuesday, March 22, 2011

Firefox 4: Restoring Previous Session

Firefox 4 will automatically reload the tabs and windows from when you last quit if the "When Firefox starts" option is set to "Show my windows and tabs from last time".  Unfortunately, this means that it will always show your last session instead of a blank browser window.

In prior versions, it would only show the windows and tabs from last time if you quit and told it to save.  With Firefox 4, the previous session's state can be restored via History->Restore Previous Session.  Alternatively, the browser.showQuitWarning setting can be set to true in about:config to restore the Firefox 3.x behavior.

Wednesday, March 09, 2011

Open Frame Chrome Extension

With Google Chrome 10, the context menu to open a frame in a new tab was removed.  Luckily, there is an extension called "Open Frame" that adds it back.