Wednesday, October 3, 2012

How to open source!

I have heard a lot about open source stuff but haven't really been good enough "with computers" to attempt that. Until now! I am attempting to install an open-source video codec called x264 on my Mac.
  1. Have Xcode installed (got it from Apple; it's a standard installer).
  2. git comes pre-installed on my Mac.
  3. Go to a directory where you can put the source code. I just used the desktop; hopefully there won't be any permissions issues.
  4. Get the repository:
    git clone git://git.videolan.org/x264.git
  5. Go to the branch called "stable" (I don't know if this actually changed anything):
    git checkout stable
  6. Attempt to compile...Oh no! It needs an assembler:
    Found no assembler
    Minimum version is yasm-1.0.0
    If you really want to compile without asm, configure with --disable-asm.
    make: *** [config.mak] Error 1
  7. Get YASM:
    git clone git://github.com/yasm/yasm.git
  8. Compile it:
    ./configure
    make
    sudo make install
  9. Oh no! That didn't work...there isn't a configure file! There is a configure.ac file, though, which suggests maybe we need to generate it using autoconf:
    autoconf
  10. A error! Something about macros:
    configure.ac:14: error: possibly undefined macro: AM_INIT_AUTOMAKE
  11. Apparently there is this thing called aclocal:
    aclocal
    autoconf
  12. Still errors! According to the Internet, there should already be a configure file here. So I downloaded the tarball instead, and that has it. Okay. Let's try compiling it again:
    cd yasm-1.2.0
    ./configure
    make
    sudo make install
  13. That seems to have worked!
    $ which yasm
    /usr/local/bin/yasm
  14. Okay, now we can go back to the x264 folder and try installing it:
    cd ../x264
    ./configure
    make
    sudo make install
  15. It worked! Yay!
UPDATE: I subsequently needed to perform this installation on another computer, which I only have ssh access to at the moment. It turns out you can also install YASM using MacPorts, which is very easy:
sudo port install yasm

UPDATE 2: Later I needed to do this installation on a computer that didn't have ffmpeg installed, and also I'm not a super user for, so I had to install it to my home directory.
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-shared --prefix=/home/username/myBin
make
make install
and then re-install x264 with appropriate flags to tell it where the ffmpeg library is:
cd x264
export LDFLAGS="-L/home/username/myBin/lib"
export CFLAGS="-I/home/username/myBin/include"
export LD_RUN_PATH="/home/username/myBin/lib"
./configure --enable-shared --prefix=/home/username/myBin
make
make install
Then the call to x264 is:
x264 -q0 --preset placebo -o outputFile.mkv inputFile.avi

Friday, September 28, 2012

Macports madness

How to install older versions with MacPorts:
  1. Go to https://trac.macports.org/browser/trunk/dports and find the revision and directory you want. In my case, it was 91935 and devel/automake
  2. Go to some temporary directory (one accessible to everybody; see step 5)
  3. svn co -r 91935 http://svn.macports.org/repository/macports/trunk/dports/devel/automake
  4. cd automake
  5. Change read/write permissions and/or ownership so that macports can access Portfile and potentially files. For example, sudo chown -R macports:macports Portfile files
  6. sudo port install
  7. You can check the newly-installed version with port installed automake

Wednesday, July 4, 2012

More black-and-white photos

I've taken some more photos (3 rolls of 120 and 1 roll of 35mm) since my last post; here are some that I liked:





The last two were with a 20mm lens on 35mm film and I thought the exaggerated sense of perspective was interesting. The last one was a handheld 1/8 second exposure so I took a couple shots (because processing this film is cheap!) and just hoped for the best. I should've turned on the oscilloscope and captured an interesting waveform, though. Note the computer desktop background!

I don't know if this is a limitation of the film format, my equipment, or my scanning, but the medium-format photos (the first three) show a lot more detail and less grain than the 35mm photos.

Sunday, June 24, 2012

Batch image resize

I came back from Vancouver with more than 1000 photos on my digital camera, each of which is 4-6 MB when saved at the camera's maximum 4928 × 3264 resolution (with "normal" jpeg compression).

This is a bit much, and even after pruning out the bad photos (blurry, etc) there were still quite a few that I wanted to keep but had absolutely no intention of printing at poster sizes or substantially cropping. My largest monitor is 1680 × 1050, an HD TV is 1920 × 1080, and even the absurd new MacBook Pro is "only" 2880 × 1800. So I decided that 3056 × 2024 was large enough for these photos.

Next came the task of actually resizing several hundred photos. I am running OS X 10.6 (Snow Leopard). Initially I tried Gimp, but the batch-processing GUI turned out to be extremely difficult to install, and writing my own command-line scripts was more work than I was really looking for right now.

Finally I got ImageMagick, which I installing using MacPorts (a Linux-like package manager for OS X), and its mogrify program turned out to be exactly what I was looking for. The command is simply:

mogrify -resize 3056x3056 *.jpg

And the results look pretty good. This resize dropped the pixel count from 16.1 MP to 6.2 MP and average file size from 5.3 MB to 2.5 MB.

Wednesday, June 13, 2012

Switzer falls

Went hiking Sunday near Switzer falls in the Angeles National Forest. Lots of stream crossings, and this one in particular was guarded by this lizard:

As we got closer, he did some push-ups to warn us off. I crossed first, eventually scaring him off, but he came right back. Here he is standing up to SC:

Not sure what he is. Maybe a Western fence lizard? Apparently the way to tell is to look at their underside.


Saturday, May 26, 2012

AirFish

A fish-shaped airship!
It's an Air Swimmers shark to which I've added a microcontroller, radio, and inertial sensors.

Manresa

For no special occasion in particular, just in a general celebratory mood, we decided to get the tasting menu at Manresa! They're a restaurant in Los Gatos with two Michelin stars.


We got all dressed up and I borrowed a fancy digital camera and we had the most epic dinner ever!

Tuesday, May 1, 2012

Friday, April 27, 2012

SSH keys

If you would like not to type in your password every time you connect to a remote server (and it really does make a difference), this is what you want:
http://en.wikipedia.org/wiki/Ssh-keygen
and if you want multiple private keys:
http://www.karan.org/blog/index.php/2009/08/25/multiple-ssh-private-keys

Tuesday, April 24, 2012

Prevent mouse from waking computer from sleep

On Windows 7:

Control panel → Mouse → Hardware tab → Properties → Change Settings → Power Management tab → uncheck "Allow this device to wake the computer"

Convoluted much?